summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-02-25 02:23:04 +0000
committerirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-02-25 02:23:04 +0000
commitdef4e5ec7ef1fcafa4e6a622344a643f31694dee (patch)
treec9a0a9e50299974d5f9efd9ab21c78335fe34363 /apps
parentaf7676611676e030ce4c1c3f3cc115b86ccf36f0 (diff)
downloadATCD-def4e5ec7ef1fcafa4e6a622344a643f31694dee.tar.gz
*** empty log message ***
Diffstat (limited to 'apps')
-rw-r--r--apps/JAWS/clients/client.h6
-rw-r--r--apps/JAWS/clients/config16
-rw-r--r--apps/JAWS/clients/connection.cpp92
-rw-r--r--apps/JAWS/clients/connection.h20
-rw-r--r--apps/JAWS/clients/cp.h18
-rw-r--r--apps/JAWS/clients/global.h39
-rw-r--r--apps/JAWS/clients/http.h14
-rw-r--r--apps/JAWS/clients/http_tester.cpp156
-rw-r--r--apps/JAWS/clients/stats.cpp80
-rw-r--r--apps/JAWS/clients/stats.h29
-rw-r--r--apps/JAWS/clients/util.cpp62
-rw-r--r--apps/JAWS/clients/util.h32
12 files changed, 564 insertions, 0 deletions
diff --git a/apps/JAWS/clients/client.h b/apps/JAWS/clients/client.h
new file mode 100644
index 00000000000..3e5967c548d
--- /dev/null
+++ b/apps/JAWS/clients/client.h
@@ -0,0 +1,6 @@
+#include "global.h"
+#include "util.h"
+#include "http.h"
+#include "cp.h"
+#include "stats.h"
+
diff --git a/apps/JAWS/clients/config b/apps/JAWS/clients/config
new file mode 100644
index 00000000000..1f502fb9c32
--- /dev/null
+++ b/apps/JAWS/clients/config
@@ -0,0 +1,16 @@
+1.0 5 1 http://mambo:2222/~sumedh/testdata/bigfile.txt 1 url2 0 url3 0 1 65536
+2.0 5 2 http://mambo:2222/~sumedh/testdata/bigfile.txt 1 url2 0 url3 0 1 65536
+3.0 5 3 http://mambo:2222/~sumedh/testdata/bigfile.txt 1 url2 0 url3 0 1 65536
+4.0 5 4 http://mambo:2222/~sumedh/testdata/bigfile.txt 1 url2 0 url3 0 1 65536
+5.0 5 5 http://mambo:2222/~sumedh/testdata/bigfile.txt 1 url2 0 url3 0 1 65536
+6.0 5 6 http://mambo:2222/~sumedh/testdata/bigfile.txt 1 url2 0 url3 0 1 65536
+7.0 5 7 http://mambo:2222/~sumedh/testdata/bigfile.txt 1 url2 0 url3 0 1 65536
+8.0 5 8 http://mambo:2222/~sumedh/testdata/bigfile.txt 1 url2 0 url3 0 1 65536
+9.0 5 9 http://mambo:2222/~sumedh/testdata/bigfile.txt 1 url2 0 url3 0 1 65536
+10.0 5 10 http://mambo:2222/~sumedh/testdata/bigfile.txt 1 url2 0 url3 0 1 65536
+11.0 5 11 http://mambo:2222/~sumedh/testdata/bigfile.txt 1 url2 0 url3 0 1 65536
+12.0 5 12 http://mambo:2222/~sumedh/testdata/bigfile.txt 1 url2 0 url3 0 1 65536
+13.0 5 13 http://mambo:2222/~sumedh/testdata/bigfile.txt 1 url2 0 url3 0 1 65536
+14.0 5 14 http://mambo:2222/~sumedh/testdata/bigfile.txt 1 url2 0 url3 0 1 65536
+15.0 5 15 http://mambo:2222/~sumedh/testdata/bigfile.txt 1 url2 0 url3 0 1 65536
+
diff --git a/apps/JAWS/clients/connection.cpp b/apps/JAWS/clients/connection.cpp
new file mode 100644
index 00000000000..727d96167ea
--- /dev/null
+++ b/apps/JAWS/clients/connection.cpp
@@ -0,0 +1,92 @@
+// connection.cc Sumedh Mungee <sumedh@cs>
+#include "connection.h"
+
+
+// Make the connection to the WEB server
+
+int connection::connect(char *hostname_opt_port, int tcp_nodelay, int sockbufsiz) {
+ if(!hostname_opt_port) return 1;
+
+ char *hostname_with_port;
+ // Check to see if portnumber is specified in the hostnameport
+ // If not, append :80
+ if(!ACE_OS::strchr(hostname_opt_port,':')) {
+ hostname_with_port = new char[ACE_OS::strlen(hostname_opt_port) + 3];
+ sprintf(hostname_with_port, "%s:%d", hostname_opt_port, 80);
+ }
+ else {
+ hostname_with_port = hostname_opt_port;
+ }
+
+ // Beyond this point, hostname_with_port is of the form hostname:port
+
+ ACE_INET_Addr server_addr(hostname_with_port);
+
+ // Connect to server
+
+ ACE_SOCK_Connector con;
+
+ if(con.connect(stream_, server_addr) == -1) {
+ perror("ACE_SOCK_Connector::connect");
+ return 1;
+ }
+
+
+ // tcp_nodelay processing.
+
+ // turn off weird ack things
+ if(tcp_nodelay) {
+ struct protoent *p = ACE_OS::getprotobyname ("tcp");
+ int one = 1;
+
+ if (p && stream_.set_option (p->p_proto,
+ TCP_NODELAY,
+ (char *)& one,
+ sizeof (one))) {
+ perror("tcp_nodelay");
+ return 1;
+ }
+ }
+
+ if(sockbufsiz)
+ if (stream_.set_option (SOL_SOCKET,
+ SO_RCVBUF,
+ (char *) &sockbufsiz,
+ sizeof sockbufsiz) == -1) {
+ perror("socket_queue_size");
+ return 1;
+ }
+
+ return 0;
+}
+
+int connection::read(void *buffer, size_t maxlen, unsigned int timeout_seconds) {
+ return stream_.recv(buffer, maxlen);
+}
+
+int connection::write(const void *buffer, size_t maxlen, unsigned int timeout_seconds) {
+ return stream_.send(buffer, maxlen);
+}
+
+int connection::write_n(const void *buffer, size_t len, unsigned int timeout_seconds) {
+ if(stream_.send_n(buffer, len) == -1)
+ ACE_ERROR_RETURN((LM_ERROR, "Write failed for %s", buffer),1);
+ return 0;
+}
+
+int connection::read_n(void *buffer, size_t maxlen, unsigned int timeout_seconds) {
+ if(stream_.recv_n(buffer, maxlen) == -1)
+ ACE_ERROR_RETURN((LM_ERROR, "Read failed.."),1);
+ return 1;
+}
+
+int connection::close(void) {
+ stream_.close_reader();
+ stream_.close_writer();
+ stream_.close();
+ return 0;
+}
+
+connection::~connection(void) {
+ this->close();
+}
diff --git a/apps/JAWS/clients/connection.h b/apps/JAWS/clients/connection.h
new file mode 100644
index 00000000000..54d7a451ac9
--- /dev/null
+++ b/apps/JAWS/clients/connection.h
@@ -0,0 +1,20 @@
+#include "global.h"
+
+#ifndef _D_connection
+#define _D_connection
+class connection {
+
+public:
+ int connect(char *hostname_opt_port, int tcp_nodelay, int sockbufsiz);
+ read(void *buffer, size_t maxlen, unsigned int timeout_seconds = 60);
+ write(const void *buffer, size_t maxlen, unsigned int timeout_seconds = 60);
+ write_n(const void *buffer, size_t len, unsigned int timeout_seconds = 60);
+ read_n(void *buffer, size_t maxlen, unsigned int timeout_seconds = 60);
+ int close(void);
+ ~connection(void);
+
+private:
+ ACE_SOCK_Stream stream_;
+ char sockbuf[66000];
+};
+#endif
diff --git a/apps/JAWS/clients/cp.h b/apps/JAWS/clients/cp.h
new file mode 100644
index 00000000000..df1a4af1e34
--- /dev/null
+++ b/apps/JAWS/clients/cp.h
@@ -0,0 +1,18 @@
+#include "util.h"
+#include "stats.h"
+
+class Client_Parameters {
+public:
+ Client_Parameters(int);
+ URL *url;
+ static Stats *stats;
+ static int tcp_nodelay;
+ static int sockbufsiz;
+ int id;
+};
+
+Client_Parameters::Client_Parameters(int i) {
+
+ id = i;
+
+}
diff --git a/apps/JAWS/clients/global.h b/apps/JAWS/clients/global.h
new file mode 100644
index 00000000000..bde46b6ba36
--- /dev/null
+++ b/apps/JAWS/clients/global.h
@@ -0,0 +1,39 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <string.h>
+#include <iostream.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <signal.h>
+
+#include <ace/OS.h>
+#include <ace/SOCK_Connector.h>
+#include <ace/SOCK_Stream.h>
+#include <ace/INET_Addr.h>
+#include <ace/Profile_Timer.h>
+#include <ace/Thread.h>
+#include <ace/Thread_Manager.h >
+#include <ace/Service_Config.h>
+
+#include <math.h>
+
+
+#ifndef extern_c_symbols
+#define extern_c_symbols
+extern "C" {
+
+ int usleep(unsigned int useconds);
+}
+#endif
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/JAWS/clients/http.h b/apps/JAWS/clients/http.h
new file mode 100644
index 00000000000..0ea53bf8c1d
--- /dev/null
+++ b/apps/JAWS/clients/http.h
@@ -0,0 +1,14 @@
+#include "global.h"
+
+#define CONTENT_ENCODING_HEADER "Content-encoding: "
+#define CONTENT_TYPE_HEADER "Content-type: "
+#define INCOMING_FILE_NAME "/tmp/sumedh.web.inc"
+#define TEMPORARY_FILE_NAME "/tmp/sumedh.web.tmp"
+
+#define ENCODING_TAB "./encoding.tab"
+#define CONTENT_TAB "./content.tab"
+
+int demime(void);
+int decode(char *encoding);
+int view(char *content);
+
diff --git a/apps/JAWS/clients/http_tester.cpp b/apps/JAWS/clients/http_tester.cpp
new file mode 100644
index 00000000000..f2421b9af04
--- /dev/null
+++ b/apps/JAWS/clients/http_tester.cpp
@@ -0,0 +1,156 @@
+// http_tester.cc sumedh@cs.wustl.edu
+#include "client.h"
+
+
+int Client_Parameters::tcp_nodelay;
+int Client_Parameters::sockbufsiz;
+Stats *Client_Parameters::stats;
+
+
+static void *client_thread(void *data) {
+ ACE_Thread_Control tc(ACE_Service_Config::thr_mgr());
+ Client_Parameters *cp = (Client_Parameters *) data;
+ float latency, throughput;
+ URL *u = cp->url;
+
+ // Check for presence of protocol, hostname and filename.
+
+ if(!(u->get_protocol() && u->get_hostname() && u->get_filename())) {
+ cerr << "Invalid URL" << endl;
+ return NULL;
+ }
+
+ cp->stats->i_have_started(cp->id);
+
+ // Attempt connection
+ connection webserver;
+
+ if(webserver.connect(u->get_hostname(), cp->tcp_nodelay, cp->sockbufsiz)) return NULL;
+ // Send the request now.
+
+
+ char request[BUFSIZ];
+
+ ACE_Profile_Timer throughput_timer, latency_timer;
+ throughput_timer.start();
+ latency_timer.start();
+ sprintf(request,"GET /%s HTTP/1.0\r\n\r\n",u->get_filename());
+ webserver.write_n(request, strlen(request)) ;
+
+ char buffer[BUFSIZ];
+ ssize_t num_read = 0, total_read = 0;
+ unsigned int first_time = 1;
+ for(;;) {
+ num_read = webserver.read(buffer, sizeof buffer);
+ if(first_time) {
+ ACE_Profile_Timer::ACE_Elapsed_Time et;
+ latency_timer.stop();
+ latency_timer.elapsed_time(et);
+ latency = et.real_time;
+ first_time = 0;
+ }
+ if(num_read <= 0)
+ break;
+ total_read += num_read;
+ }
+ cp->stats->i_am_done(cp->id);
+ ACE_Profile_Timer::ACE_Elapsed_Time et;
+ throughput_timer.stop();
+ throughput_timer.elapsed_time(et);
+ throughput = (8 * total_read/et.real_time) / pow(10,6) ;
+ cp->stats->log(cp->id, throughput, latency);
+ webserver.close();
+}
+
+int driver(char *id, int total_num, float requests_sec, char *url1, float p1, char *url2, float p2, char *url3, float p3, int tcp_nodelay, int sockbufsiz) {
+
+ // construct the client parameters packet
+
+ Client_Parameters::tcp_nodelay = tcp_nodelay;
+ Client_Parameters::sockbufsiz = sockbufsiz;
+
+ Client_Parameters::stats = new Stats(total_num);
+
+
+ // sleep_time is in microseconds, and requests_sec is per second, hence the pow(10,6)
+ float sleep_time = (1/requests_sec) * pow(10,6);
+ float delta = 0;
+ srand(time(NULL));
+ for(int i = 0; i < total_num; i++) { // i is used as a id for threads
+ ACE_Profile_Timer timer;
+ if(sleep_time < delta) {
+ cerr << "Requested rate is too high, sorry! " << endl;
+ return 2;
+ }
+ ACE_Time_Value tv(0, sleep_time - delta);
+ ACE_OS::sleep(tv);
+ timer.start();
+
+ Client_Parameters *cp = new Client_Parameters(i);
+
+ double r = ((double)rand()/(double)RAND_MAX);
+ // cerr << " choosing between " << url1 << url2 << url3 << " with r == " << r;
+ if(r <= p1) cp->url = new URL(url1);
+ if( (r > p1) && (r <= (p1 + p2))) cp->url = new URL(url2);
+ if( (r > (p1 + p2))) cp->url = new URL(url3);
+ // cerr << "The URL being requested is " << cp->url->get_filename() << endl;
+
+
+ (ACE_Service_Config::thr_mgr())->spawn(client_thread, (void *) cp);
+ timer.stop();
+ ACE_Profile_Timer::ACE_Elapsed_Time et;
+ timer.elapsed_time(et);
+ delta = ( (0.8 * fabs(et.real_time * pow(10,6))) + (0.2 * delta) );
+ }
+
+ // Join the other threads..
+ (ACE_Service_Config::thr_mgr())->wait();
+ // Now output the data for this test
+ cout << id;
+ Client_Parameters::stats->output();
+ cout << endl;
+ return 0;
+}
+
+
+main(int argc, char **argv) {
+
+ if(argc < 3) {
+ cerr << "Usage: " << argv[0] << " infile outfile " << endl;
+ cerr << "The input file contains lines, with the following fields: " << endl;
+ cerr << "experiment_id total_number_of_requests request_rate url1 p1 url2 p2 url3 p3 TCP_NODELAY SOCKET_RECV_BUFSIZ " << endl;
+
+ return 1;
+ }
+
+ FILE *fp = fopen(argv[1],"r");
+ if(fp == NULL) {
+ perror("fopen");
+ return 2;
+ }
+ close(1);
+ int fd = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, 0644);
+ if(fd == -1) {
+ perror("open");
+ return 3;
+ }
+
+
+ int total_num, tcp, sock;
+ char *id = new char[BUFSIZ];
+ float rate, p1, p2, p3;
+ char *url1 = new char[BUFSIZ];
+ char *url2 = new char[BUFSIZ];
+ char *url3 = new char[BUFSIZ];
+
+
+ while(!feof(fp)) {
+ fscanf(fp,"%s %d %f %s %f %s %f %s %f %d %d\n", id, &total_num, &rate, url1, &p1, url2, &p2, url3, &p3, &tcp, &sock);
+ fprintf(stderr,"----\n");
+ fprintf(stderr,"\tNow performing experiment:%s\n\tSending %d requests at %f requests/second\n", id, total_num, rate);
+ driver(id, total_num, rate, url1, p1, url2, p2, url3, p3, tcp, sock);
+ }
+ fclose(fp);
+ close(fd);
+ return 0;
+}
diff --git a/apps/JAWS/clients/stats.cpp b/apps/JAWS/clients/stats.cpp
new file mode 100644
index 00000000000..da15632998e
--- /dev/null
+++ b/apps/JAWS/clients/stats.cpp
@@ -0,0 +1,80 @@
+#include "stats.h"
+
+
+Stats::Stats(int size) {
+ throughput_ = new float[size];
+ latency_ = new float[size];
+ thread_count_ = size;
+ init_fini_ = new Init_Fini_t[2*size];
+ for(int i = 0; i < size; i++)
+ throughput_[i] = latency_[i] = 0;
+}
+
+void Stats::log(int id, float throughput, float latency) {
+ throughput_[id] = throughput;
+ latency_[id] = latency;
+}
+
+void Stats::print(char *message) {
+ char time_buf[64];
+ long ltime;
+ time(&ltime);
+ ACE_OS::ctime_r(&ltime, time_buf, sizeof time_buf);
+
+ if(ACE_OS::gettimeofday() == -1) {
+ perror("gettimeofday");
+ }
+ time_buf[strlen(time_buf)-1] = 0;
+ //printf("%010ld%09ld \t %s %s\n", tp.tv_sec, tp.tv_usec, time_buf, message);
+}
+
+
+int comp(const void *a, const void *b) {
+
+ Init_Fini_t *A = (Init_Fini_t *)a;
+ Init_Fini_t *B = (Init_Fini_t *)b;
+
+ return (A->timestamp < B->timestamp) ? -1 : (A->timestamp > B->timestamp);
+}
+
+
+void Stats::output() {
+ int i;
+ float tavg = 0, lavg = 0;
+
+ qsort(init_fini_, 2*thread_count_, sizeof(Init_Fini_t), comp);
+
+ int max = 0,thread_peak = 0;
+
+ for(i = 0; i < 2*thread_count_; i++) {
+ // cerr << " " << ((init_fini_[i].type == THREAD_START) ? "START": "END") << " " << init_fini_[i].timestamp.sec() << "." << init_fini_[i].timestamp.usec() << endl;
+ if(init_fini_[i].type == THREAD_START) {
+ if(++thread_peak > max)
+ max = thread_peak;
+ }
+ else thread_peak--;
+ }
+ for(i = 0; i < thread_count_; i++) {
+ tavg += throughput_[i];
+ lavg += latency_[i];
+ }
+ cout << " " << tavg/thread_count_ << " " << lavg/thread_count_ << " " << max;
+}
+
+
+void Stats::i_have_started(int id) {
+
+ init_fini_[2*id].type = THREAD_START;
+ init_fini_[2*id].timestamp = ACE_OS::gettimeofday();
+
+}
+
+void Stats::i_am_done(int id) {
+
+ init_fini_[(2*id)+1].type = THREAD_END;
+
+ init_fini_[(2*id)+1].timestamp = ACE_OS::gettimeofday();
+
+}
+
+
diff --git a/apps/JAWS/clients/stats.h b/apps/JAWS/clients/stats.h
new file mode 100644
index 00000000000..39f719c4cec
--- /dev/null
+++ b/apps/JAWS/clients/stats.h
@@ -0,0 +1,29 @@
+#include "global.h"
+
+#ifndef _D_Stats
+#define _D_Stats
+
+#define THREAD_START 42
+#define THREAD_END 43
+
+class Init_Fini_t {
+public:
+ int type; // 0 is start, 1 is end
+ ACE_Time_Value timestamp;
+};
+
+class Stats {
+public:
+ Stats(int);
+ void log(int, float, float);
+ void i_have_started(int);
+ void i_am_done(int);
+ void print (char *);
+ void output();
+private:
+ float *throughput_;
+ float *latency_;
+ Init_Fini_t *init_fini_; // Array (2n deep) to count peak no. of active threads
+ int thread_count_;
+};
+#endif
diff --git a/apps/JAWS/clients/util.cpp b/apps/JAWS/clients/util.cpp
new file mode 100644
index 00000000000..69b88c8509a
--- /dev/null
+++ b/apps/JAWS/clients/util.cpp
@@ -0,0 +1,62 @@
+#include "util.h"
+
+
+
+URL::URL(char *input_buf) {
+
+ char *buffer = new char[BUFSIZ];
+
+ ACE_OS::strcpy(buffer,input_buf);
+ if(buffer == NULL)
+ return;
+
+ char *temp;
+ char *lasts;
+
+ if(temp = ACE_OS::strtok_r(buffer,": ",&lasts)) {
+ protocol_ = (char *) ACE_OS::malloc(strlen(temp));
+ ACE_OS::strcpy(protocol_, temp);
+ }
+
+ if(temp = ACE_OS::strtok_r(NULL,"/",&lasts)) {
+ hostname_ = (char *) ACE_OS::malloc(strlen(temp));
+ ACE_OS::strcpy(hostname_, temp);
+ }
+ if(temp = ACE_OS::strtok_r(NULL,"\0",&lasts)) {
+ filename_ = (char *) malloc(strlen(temp));
+ ACE_OS::strcpy(filename_, temp);
+ }
+ else {
+ filename_ = (char *) malloc(strlen(INDEX_NAME));
+ ACE_OS::strcpy(filename_,INDEX_NAME);
+ }
+}
+
+char *URL::get_protocol(void) {
+ return protocol_;
+}
+
+char *URL::get_hostname(void) {
+ return hostname_;
+}
+
+char *URL::get_filename(void) {
+ return filename_;
+}
+
+
+
+
+
+void cleanup(void) {
+ unlink(TEMPORARY_FILE_NAME);
+ unlink(INCOMING_FILE_NAME);
+}
+
+void sigint(int) {
+ cleanup();
+}
+
+
+
+
diff --git a/apps/JAWS/clients/util.h b/apps/JAWS/clients/util.h
new file mode 100644
index 00000000000..ea5b29da104
--- /dev/null
+++ b/apps/JAWS/clients/util.h
@@ -0,0 +1,32 @@
+#include "connection.h"
+
+#ifndef _D_URL
+#define _D_URL
+class URL {
+
+public:
+
+ URL(char *buffer);
+
+ char *get_protocol();
+ char *get_hostname();
+ char *get_filename();
+
+private:
+ char *protocol_;
+ char *hostname_;
+ char *filename_;
+};
+
+void cleanup(void);
+void sigint(int);
+int copier(connection in);
+
+#define INDEX_NAME "/index.html"
+#define INCOMING_FILE_NAME "/tmp/sumedh.web.inc"
+#define TEMPORARY_FILE_NAME "/tmp/sumedh.web.tmp"
+#endif
+
+
+
+