Commit 86cff6db40caf593acc0da836c5b868c12e504f2

Authored by Ajay Mohan
1 parent c12e3e15c4
Exists in master

Final review Push

Showing 15 changed files with 324 additions and 318 deletions Side-by-side Diff

network/ocli View file @ 86cff6d

No preview for this file type

network/oser View file @ 86cff6d

No preview for this file type

network/overhead_client.c View file @ 86cff6d
... ... @@ -39,11 +39,11 @@
39 39 int i;
40 40 int protonum = proto_entry->p_proto;
41 41 for(i=1;i<=BACKLOG;i++){
42   - getTime(starttime);
43 42 //Open an socket end-point for this TCP Server
44 43 if((socket_fd = socket(AF_INET, SOCK_STREAM, protonum))<0){
45 44 handle_error("Socket Error");
46 45 }
  46 + getTime(starttime);
47 47 if(connect(socket_fd, (struct sockaddr*)&server, sizeof(server))<0){
48 48 handle_error("Connection Error");
49 49 }
... ... @@ -60,7 +60,7 @@
60 60  
61 61 so_linger.l_onoff = 1;
62 62 so_linger.l_linger = 0;
63   - /*z = setsockopt(socket_fd,
  63 + z = setsockopt(socket_fd,
64 64 SOL_SOCKET,
65 65 SO_LINGER,
66 66 &so_linger,
67 67  
... ... @@ -68,10 +68,9 @@
68 68  
69 69 if ( z )
70 70 perror("setsockopt(2)");
71   - */
  71 +
72 72 getTime(starttime);
73   - shutdown(socket_fd, SHUT_RDWR);
74   - //close(socket_fd);
  73 + close(socket_fd);
75 74 getTime(endtime);
76 75  
77 76 //Calculate connection overhead server side
network/peak_client.c View file @ 86cff6d
... ... @@ -9,11 +9,32 @@
9 9 //Macro definitions
10 10 #define handle_error(msg) \
11 11 do { perror(msg); exit(1);} while(0);
12   -#define BACKLOG 50
  12 +#define BUFFER_SIZE 1 * MB
  13 +#define MB 1024 * 1024
  14 +#define STRIDE_SIZE 64
  15 +#define BACKLOG 64 //buff size/stride size
  16 +
  17 +//A random string generator of given length
  18 +char* generate_string(int length)
  19 +{
  20 + //Random number seed
  21 + srand((unsigned int) ctime(0));
  22 + char * buff;
  23 + buff=(char *)malloc(sizeof(char)*(length+1));
  24 + int i;
  25 + for(i=0;i< length;i++){
  26 + buff[i] = rand() % rand() % (126 - 33 + 1) + 33;
  27 + }
  28 + buff[i] = '\0';
  29 + return buff;
  30 +}
  31 +
13 32 int main(int argc, char*argv[])
14 33 {
15 34 int socket_fd, rc;
16   - float start_delta = 0, close_delta = 0;
  35 + char buff[BUFFER_SIZE];
  36 + char *msg;
  37 + float delta = 0, min =9999;
17 38 if(argc<2){
18 39 handle_error("<usage>:tcp_client <IP address>");
19 40 }
... ... @@ -27,7 +48,7 @@
27 48 struct sockaddr_in server;
28 49 memset(&server, 0, sizeof(struct sockaddr));
29 50 server.sin_family = AF_INET;
30   - server.sin_port = htons(8000);
  51 + server.sin_port = htons(9);
31 52  
32 53 rc= inet_pton(AF_INET, argv[1], &server.sin_addr);
33 54 if(rc == -1){
34 55  
35 56  
36 57  
37 58  
... ... @@ -38,32 +59,28 @@
38 59 int addr_size = sizeof(struct sockaddr);
39 60 int i;
40 61 int protonum = proto_entry->p_proto;
  62 +
  63 + //Open an socket end-point for this TCP Server
  64 + if((socket_fd = socket(AF_INET, SOCK_STREAM, protonum))<0){
  65 + handle_error("Socket Error");
  66 + }
  67 + if(connect(socket_fd, (struct sockaddr*)&server, sizeof(server))<0){
  68 + handle_error("Connection Error");
  69 + }
  70 + msg = generate_string(BUFFER_SIZE);
41 71 for(i=1;i<=BACKLOG;i++){
42 72 getTime(starttime);
43   - //Open an socket end-point for this TCP Server
44   - if((socket_fd = socket(AF_INET, SOCK_STREAM, protonum))<0){
45   - handle_error("Socket Error");
  73 + if(send(socket_fd, msg, strlen(msg), 0) <0){
  74 + handle_error("Send Error");
46 75 }
47   - if(connect(socket_fd, (struct sockaddr*)&server, sizeof(server))<0){
48   - handle_error("Connection Error");
49   - }
50   - /*The end calculated here will miss time taken for ACK K+1
51   - from the client. And so we have to one way delay
52   - measured using another experiment*/
53 76 getTime(endtime);
54   -
55   - //Calculate connection overhead client
56   - start_delta+=diff(endtime,starttime);
57   -
58   - getTime(starttime);
59   - close(socket_fd);
60   - getTime(endtime);
61   -
62   - //Calculate connection overhead server side
63   - close_delta+=diff(endtime,starttime);
  77 + delta+=(diff(endtime, starttime));
  78 + if(delta < min) min = delta;
  79 + printf("Single Tput %fBps\n",(BUFFER_SIZE/ diff(endtime, starttime)));
64 80 }
65   - printf("Connection Setup =%f us\n", (start_delta + RTT/2 * BACKLOG)/BACKLOG);
66   - printf("Connection Teardown =%f us\n", (close_delta + RTT/2 * BACKLOG)/BACKLOG);
  81 +
  82 + close(socket_fd);
  83 + printf("GoodPut = %f Bps, MaxTput= %f Bps", (BUFFER_SIZE)*(BACKLOG/delta), (BUFFER_SIZE/min));
67 84 return 0;
68 85 }
69 86  
network/peak_server.c View file @ 86cff6d
1   -#include "../rasperf.h"
2   -#include<stdio.h>
3   -#include<stdlib.h>
4   -#include<arpa/inet.h>
5   -#include<sys/types.h>
6   -#include<sys/wait.h>
7   -#include<sys/socket.h>
8   -#include<netdb.h>
9   -#include<string.h>
10   -
11   -//Macro definitions
12   -#define handle_error(msg) \
13   - do { perror(msg); exit(1);} while(0);
14   -#define LISTEN_BACKLOG 50
15   -
16   -int main(int argc, char*argv[])
17   -{
18   - int socket_fd, rc;
19   - float setup_delta, close_delta;
20   - if(argc<1){
21   - handle_error("<usage>:tcp_server");
22   - }
23   - //Retrieve the protocol number mapping
24   - //from /etc/protocols file
25   - struct protoent *proto_entry;
26   - proto_entry = getprotobyname("tcp");
27   -
28   - //Open an socket end-point for this TCP Server
29   - socket_fd = socket(AF_INET, SOCK_STREAM, proto_entry->p_proto);
30   - if(socket_fd == -1){
31   - handle_error("Socket descriptor creation failed");
32   - }
33   -
34   - //My address information to bind to
35   - struct sockaddr_in sock_addr;
36   - memset(&sock_addr, 0, sizeof(struct sockaddr));
37   - sock_addr.sin_family = AF_INET;
38   - sock_addr.sin_addr.s_addr = htonl(INADDR_ANY);
39   - sock_addr.sin_port = htons(8000);
40   -
41   -
42   - rc = bind(socket_fd, (struct sockaddr*)&sock_addr, sizeof(sock_addr));
43   - if(rc == -1){
44   - handle_error("Bind failure");
45   - }
46   - rc = listen(socket_fd, LISTEN_BACKLOG);
47   - if(rc == -1){
48   - handle_error(" Listen Error");
49   - }
50   -
51   - time starttime, endtime;
52   -
53   - //accept incoming connections
54   - int connfd, i, pid, addr_size = sizeof(struct sockaddr);
55   - for(i=1;i<=1000;i++)
56   - {
57   - //getTime(starttime);
58   - printf("Accept Connection\n");
59   - //waitpid(WAIT_ANY, NULL, WNOHANG);
60   - connfd = accept(socket_fd, (struct sockaddr *)NULL, NULL);
61   - /*The end calculated here would have missed SYN time
62   - from the client. And so we have to add one
63   - packet worth round trip time in the overhead*/
64   - //getTime(endtime);
65   - if( connfd == -1){
66   - handle_error("Accept failed");
67   - }
68   - //setup_delta+=diff(endtime,starttime);
69   - if(pid = fork() == 0){
70   - close(socket_fd);
71   - close(connfd);
72   - printf("Connection %d closed in Child\n",i);
73   - //close_delta=diff(endtime, starttime);
74   - //printf("Connection Termination %f", close_delta + RTT);
75   - exit(0);
76   - }
77   - close(connfd);
78   - }
79   - //getTime(starttime);
80   - close(socket_fd);
81   - //getTime(endtime);
82   -
83   - //Calculate connection overhead server side
84   - //setup_delta+=diff(endtime,starttime);
85   - //printf("Connection Overhead:Setup =%f us\n", (setup_delta+ RTT*600)/600);
86   -
87   - return 0;
88   -}
89   -
90   -
network/rand View file @ 86cff6d

No preview for this file type

network/random_str.c View file @ 86cff6d
1   -#include<stdio.h>
2   -#include<stdlib.h>
3   -#include<string.h>
4   -char* generate_string(int length)
5   -{
6   - //Random number seed
7   - srand((unsigned int) ctime(0));
8   - char * buff;
9   - buff=(char *)malloc(sizeof(char)*length);
10   - int i;
11   - for(i=0;i< length-1;i++){
12   - buff[i] = rand() % rand() % (126 - 33 + 1) + 33;
13   - }
14   - buff[i] = '\0';
15   - return buff;
16   -}
17   -int main()
18   -{
19   - char *buf;
20   - buf = generate_string(5);
21   - printf("String of 5: %s, size: %lu\n", buf, strlen(buf));
22   - free(buf);
23   -
24   - buf = generate_string(40);
25   - printf("String of 40: %s, size: %lu\n", buf, strlen(buf));
26   - free(buf);
27   -
28   - buf = generate_string(80);
29   - printf("String of 80: %s,, size: %lu\n", buf, strlen(buf));
30   - free(buf);
31   -
32   - return 0;
33   -}
network/rtt_client.c View file @ 86cff6d
... ... @@ -9,9 +9,9 @@
9 9 //Macro definitions
10 10 #define handle_error(msg) \
11 11 do { perror(msg); exit(1);} while(0);
12   -#define BUFFER_SIZE 2048
13   -#define STRIDE_SIZE 64
14   -#define BACKLOG 32 //buff size/stride size
  12 +#define BUFFER_SIZE 1024 * 1024
  13 +#define STRIDE_SIZE 512
  14 +#define BACKLOG 5 //buff size/stride size
15 15  
16 16 //A random string generator of given length
17 17 char* generate_string(int length)
... ... @@ -47,7 +47,7 @@
47 47 struct sockaddr_in server;
48 48 memset(&server, 0, sizeof(struct sockaddr));
49 49 server.sin_family = AF_INET;
50   - server.sin_port = htons(8000);
  50 + server.sin_port = htons(7);
51 51  
52 52 rc= inet_pton(AF_INET, argv[1], &server.sin_addr);
53 53 if(rc == -1){
network/rtt_server.c View file @ 86cff6d
1   -#include "../rasperf.h"
2   -#include<stdio.h>
3   -#include<stdlib.h>
4   -#include<arpa/inet.h>
5   -#include<sys/types.h>
6   -#include<sys/wait.h>
7   -#include<sys/socket.h>
8   -#include<netdb.h>
9   -#include<string.h>
10   -
11   -//Macro definitions
12   -#define handle_error(msg) \
13   - do { perror(msg); exit(1);} while(0);
14   -#define LISTEN_BACKLOG 100
15   -#define BUFFER_SIZE 2048
16   -#define STRIDE_SIZE 64
17   -#define BACKLOG 32
18   -
19   -int main(int argc, char*argv[])
20   -{
21   - int socket_fd, rc;
22   - char buff[BUFFER_SIZE];
23   - float setup_delta, close_delta;
24   - if(argc<1){
25   - handle_error("<usage>:tcp_server");
26   - }
27   - //Retrieve the protocol number mapping
28   - //from /etc/protocols file
29   - struct protoent *proto_entry;
30   - proto_entry = getprotobyname("tcp");
31   -
32   - //Open an socket end-point for this TCP Server
33   - socket_fd = socket(AF_INET, SOCK_STREAM, proto_entry->p_proto);
34   - if(socket_fd == -1){
35   - handle_error("Socket descriptor creation failed");
36   - }
37   -
38   - //My address information to bind to
39   - struct sockaddr_in sock_addr;
40   - memset(&sock_addr, 0, sizeof(struct sockaddr));
41   - sock_addr.sin_family = AF_INET;
42   - sock_addr.sin_addr.s_addr = htonl(INADDR_ANY);
43   - sock_addr.sin_port = htons(8000);
44   -
45   -
46   - rc = bind(socket_fd, (struct sockaddr*)&sock_addr, sizeof(sock_addr));
47   - if(rc == -1){
48   - handle_error("Bind failure");
49   - }
50   - rc = listen(socket_fd, LISTEN_BACKLOG);
51   - if(rc == -1){
52   - handle_error(" Listen Error");
53   - }
54   -
55   - time starttime, endtime;
56   - //accept incoming connections
57   - int connfd, i, pid, addr_size = sizeof(struct sockaddr);
58   - printf("Accept Connection\n");
59   - connfd = accept(socket_fd, (struct sockaddr *)NULL, NULL);
60   - if( connfd == -1){
61   - handle_error("Accept failed");
62   - }
63   - for(i=1;i<=BACKLOG;i++)
64   - {
65   - printf("%d\n",i);
66   - getTime(starttime);
67   - if(recv(connfd, buff,i* STRIDE_SIZE, 0) != i* STRIDE_SIZE){
68   - printf("String :%s, strlen:%d, stride:%d\n", buff, strlen(buff), i*STRIDE_SIZE);
69   - handle_error("Receive Error/ Data Done");
70   - }
71   - if(send(connfd, buff,i * STRIDE_SIZE, 0)<0){
72   - handle_error("Send Error");
73   - }
74   - getTime(endtime);
75   - }
76   -
77   - close(socket_fd);
78   - close(connfd);
79   - printf("Connection %d closed in Child\n",i);
80   - return 0;
81   -}
82   -
network/standby_servers/peak_server.c View file @ 86cff6d
  1 +#include "../rasperf.h"
  2 +#include<stdio.h>
  3 +#include<stdlib.h>
  4 +#include<arpa/inet.h>
  5 +#include<sys/types.h>
  6 +#include<sys/wait.h>
  7 +#include<sys/socket.h>
  8 +#include<netdb.h>
  9 +#include<string.h>
  10 +
  11 +//Macro definitions
  12 +#define handle_error(msg) \
  13 + do { perror(msg); exit(1);} while(0);
  14 +#define LISTEN_BACKLOG 100
  15 +#define BUFFER_SIZE 5 * MB
  16 +#define MB 1024*1024
  17 +#define STRIDE_SIZE 64
  18 +#define BACKLOG 64
  19 +
  20 +int main(int argc, char*argv[])
  21 +{
  22 + int socket_fd, rc;
  23 + char buff[BUFFER_SIZE];
  24 + float setup_delta, close_delta;
  25 + if(argc<1){
  26 + handle_error("<usage>:tcp_server");
  27 + }
  28 + //Retrieve the protocol number mapping
  29 + //from /etc/protocols file
  30 + struct protoent *proto_entry;
  31 + proto_entry = getprotobyname("tcp");
  32 +
  33 + //Open an socket end-point for this TCP Server
  34 + socket_fd = socket(AF_INET, SOCK_STREAM, proto_entry->p_proto);
  35 + if(socket_fd == -1){
  36 + handle_error("Socket descriptor creation failed");
  37 + }
  38 +
  39 + //My address information to bind to
  40 + struct sockaddr_in sock_addr;
  41 + memset(&sock_addr, 0, sizeof(struct sockaddr));
  42 + sock_addr.sin_family = AF_INET;
  43 + sock_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  44 + sock_addr.sin_port = htons(8000);
  45 +
  46 +
  47 + rc = bind(socket_fd, (struct sockaddr*)&sock_addr, sizeof(sock_addr));
  48 + if(rc == -1){
  49 + handle_error("Bind failure");
  50 + }
  51 + rc = listen(socket_fd, LISTEN_BACKLOG);
  52 + if(rc == -1){
  53 + handle_error(" Listen Error");
  54 + }
  55 +
  56 + time starttime, endtime;
  57 + //accept incoming connections
  58 + int connfd, i, pid, addr_size = sizeof(struct sockaddr);
  59 + printf("Accept Connection\n");
  60 + connfd = accept(socket_fd, (struct sockaddr *)NULL, NULL);
  61 + if( connfd == -1){
  62 + handle_error("Accept failed");
  63 + }
  64 +
  65 + getTime(starttime);
  66 + for(i=1;i<=BACKLOG;i++)
  67 + {
  68 + if(recv(connfd, buff,BUFFER_SIZE, 0) == -1){
  69 + handle_error("Receive Error/ Data Done");
  70 + }
  71 + }
  72 + getTime(endtime);
  73 +
  74 + close(socket_fd);
  75 + close(connfd);
  76 + printf("Data Receided:%d MB, Time:%f s \n",i*BUFFER_SIZE, diff(endtime, starttime));
  77 + return 0;
  78 +}
  79 +
network/standby_servers/random_str.c View file @ 86cff6d
  1 +#include<stdio.h>
  2 +#include<stdlib.h>
  3 +#include<string.h>
  4 +char* generate_string(int length)
  5 +{
  6 + //Random number seed
  7 + srand((unsigned int) ctime(0));
  8 + char * buff;
  9 + buff=(char *)malloc(sizeof(char)*length);
  10 + int i;
  11 + for(i=0;i< length-1;i++){
  12 + buff[i] = rand() % rand() % (126 - 33 + 1) + 33;
  13 + }
  14 + buff[i] = '\0';
  15 + return buff;
  16 +}
  17 +int main()
  18 +{
  19 + char *buf;
  20 + buf = generate_string(5);
  21 + printf("String of 5: %s, size: %lu\n", buf, strlen(buf));
  22 + free(buf);
  23 +
  24 + buf = generate_string(40);
  25 + printf("String of 40: %s, size: %lu\n", buf, strlen(buf));
  26 + free(buf);
  27 +
  28 + buf = generate_string(80);
  29 + printf("String of 80: %s,, size: %lu\n", buf, strlen(buf));
  30 + free(buf);
  31 +
  32 + return 0;
  33 +}
network/standby_servers/rtt_server.c View file @ 86cff6d
  1 +#include "../rasperf.h"
  2 +#include<stdio.h>
  3 +#include<stdlib.h>
  4 +#include<arpa/inet.h>
  5 +#include<sys/types.h>
  6 +#include<sys/wait.h>
  7 +#include<sys/socket.h>
  8 +#include<netdb.h>
  9 +#include<string.h>
  10 +
  11 +//Macro definitions
  12 +#define handle_error(msg) \
  13 + do { perror(msg); exit(1);} while(0);
  14 +#define LISTEN_BACKLOG 100
  15 +#define BUFFER_SIZE 1024 * 1024
  16 +#define STRIDE_SIZE 64
  17 +#define BACKLOG 128
  18 +
  19 +int main(int argc, char*argv[])
  20 +{
  21 + int socket_fd, rc;
  22 + char buff[BUFFER_SIZE];
  23 + float setup_delta, close_delta;
  24 + if(argc<1){
  25 + handle_error("<usage>:tcp_server");
  26 + }
  27 + //Retrieve the protocol number mapping
  28 + //from /etc/protocols file
  29 + struct protoent *proto_entry;
  30 + proto_entry = getprotobyname("tcp");
  31 +
  32 + //Open an socket end-point for this TCP Server
  33 + socket_fd = socket(AF_INET, SOCK_STREAM, proto_entry->p_proto);
  34 + if(socket_fd == -1){
  35 + handle_error("Socket descriptor creation failed");
  36 + }
  37 +
  38 + //My address information to bind to
  39 + struct sockaddr_in sock_addr;
  40 + memset(&sock_addr, 0, sizeof(struct sockaddr));
  41 + sock_addr.sin_family = AF_INET;
  42 + sock_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  43 + sock_addr.sin_port = htons(8000);
  44 +
  45 +
  46 + rc = bind(socket_fd, (struct sockaddr*)&sock_addr, sizeof(sock_addr));
  47 + if(rc == -1){
  48 + handle_error("Bind failure");
  49 + }
  50 + rc = listen(socket_fd, LISTEN_BACKLOG);
  51 + if(rc == -1){
  52 + handle_error(" Listen Error");
  53 + }
  54 +
  55 + time starttime, endtime;
  56 + //accept incoming connections
  57 + int connfd, i, pid, addr_size = sizeof(struct sockaddr);
  58 + printf("Accept Connection\n");
  59 + connfd = accept(socket_fd, (struct sockaddr *)NULL, NULL);
  60 + if( connfd == -1){
  61 + handle_error("Accept failed");
  62 + }
  63 + for(i=1;i<=BACKLOG;i++)
  64 + {
  65 + printf("%d\n",i);
  66 + getTime(starttime);
  67 + if(recv(connfd, buff,i* STRIDE_SIZE, 0) != i* STRIDE_SIZE){
  68 + printf("String :%s, strlen:%d, stride:%d\n", buff, strlen(buff), i*STRIDE_SIZE);
  69 + handle_error("Receive Error/ Data Done");
  70 + }
  71 + if(send(connfd, buff,i * STRIDE_SIZE, 0)<0){
  72 + handle_error("Send Error");
  73 + }
  74 + getTime(endtime);
  75 + }
  76 +
  77 + close(socket_fd);
  78 + close(connfd);
  79 + printf("Connection %d closed in Child\n",i);
  80 + return 0;
  81 +}
  82 +
network/standby_servers/tcp_rtt_client.bul View file @ 86cff6d
  1 +#include "../rasperf.h"
  2 +#include<stdio.h>
  3 +#include<stdlib.h>
  4 +#include<arpa/inet.h>
  5 +#include<sys/types.h>
  6 +#include<sys/socket.h>
  7 +#include<netdb.h>
  8 +#include<string.h>
  9 +//Macro definitions
  10 +#define handle_error(msg) \
  11 + do { perror(msg); exit(1);} while(0);
  12 +#define BACKLOG 1
  13 +int main(int argc, char*argv[])
  14 +{
  15 + int socket_fd, rc;
  16 + float start_delta = 0, close_delta = 0;
  17 + if(argc<2){
  18 + handle_error("<usage>:tcp_client <IP address>");
  19 + }
  20 + //Retrieve the protocol number mapping
  21 + //from /etc/protocols file
  22 + struct protoent *proto_entry;
  23 + proto_entry = getprotobyname("tcp");
  24 +
  25 +
  26 + //My address information to bind to
  27 + struct sockaddr_in server;
  28 + memset(&server, 0, sizeof(struct sockaddr));
  29 + server.sin_family = AF_INET;
  30 + server.sin_port = htons(8000);
  31 +
  32 + rc= inet_pton(AF_INET, argv[1], &server.sin_addr);
  33 + if(rc == -1){
  34 + handle_error("Address Error");
  35 + }
  36 + time starttime, endtime;
  37 + //accept incoming connections
  38 + int addr_size = sizeof(struct sockaddr);
  39 + int i;
  40 + int protonum = proto_entry->p_proto;
  41 + for(i=1;i<=BACKLOG;i++){
  42 + getTime(starttime);
  43 + //Open an socket end-point for this TCP Server
  44 + if((socket_fd = socket(AF_INET, SOCK_STREAM, protonum))<0){
  45 + handle_error("Socket descriptor creation failed");
  46 + }
  47 + if((connect(socket_fd, (struct sockaddr*)&server, sizeof(server)))<0){
  48 + handle_error("Connect failed");
  49 + }
  50 + /*The end calculated here will miss time taken for ACK K+1
  51 + from the client. And so we have to one way delay
  52 + measured using another experiment*/
  53 + getTime(endtime);
  54 +
  55 + //Calculate connection overhead client
  56 + start_delta+=diff(endtime,starttime);
  57 + printf("EndTime: %f usec\n", endtime.tv_sec + endtime.tv_usec*1e6);
  58 + printf("Start time:%f usec\n", starttime.tv_sec +starttime.tv_usec*1e6);
  59 + printf("Setup:%f\n",diff(endtime,starttime) + 25);
  60 +
  61 + getTime(starttime);
  62 + sleep(1);
  63 + close(socket_fd);
  64 + getTime(endtime);
  65 + printf("Endtime %f usec\n", endtime.tv_sec + endtime.tv_usec*1e6);
  66 + printf("Start time:%f usec\n", starttime.tv_sec +starttime.tv_usec*1e6);
  67 + printf("TearDown:%f\n",diff(endtime,starttime) + 25);
  68 + //Calculate connection overhead server side
  69 + close_delta+=diff(endtime,starttime);
  70 + }
  71 + printf("Connection Setup =%f us\n", (start_delta + RTT/2 * BACKLOG)/BACKLOG);
  72 + printf("Connection Teardown =%f us\n", (close_delta + RTT/2 * BACKLOG)/BACKLOG);
  73 + return 0;
  74 +}
  75 +
  76 +
network/tcp_rtt_client.bul View file @ 86cff6d
1   -#include "../rasperf.h"
2   -#include<stdio.h>
3   -#include<stdlib.h>
4   -#include<arpa/inet.h>
5   -#include<sys/types.h>
6   -#include<sys/socket.h>
7   -#include<netdb.h>
8   -#include<string.h>
9   -//Macro definitions
10   -#define handle_error(msg) \
11   - do { perror(msg); exit(1);} while(0);
12   -#define BACKLOG 1
13   -int main(int argc, char*argv[])
14   -{
15   - int socket_fd, rc;
16   - float start_delta = 0, close_delta = 0;
17   - if(argc<2){
18   - handle_error("<usage>:tcp_client <IP address>");
19   - }
20   - //Retrieve the protocol number mapping
21   - //from /etc/protocols file
22   - struct protoent *proto_entry;
23   - proto_entry = getprotobyname("tcp");
24   -
25   -
26   - //My address information to bind to
27   - struct sockaddr_in server;
28   - memset(&server, 0, sizeof(struct sockaddr));
29   - server.sin_family = AF_INET;
30   - server.sin_port = htons(8000);
31   -
32   - rc= inet_pton(AF_INET, argv[1], &server.sin_addr);
33   - if(rc == -1){
34   - handle_error("Address Error");
35   - }
36   - time starttime, endtime;
37   - //accept incoming connections
38   - int addr_size = sizeof(struct sockaddr);
39   - int i;
40   - int protonum = proto_entry->p_proto;
41   - for(i=1;i<=BACKLOG;i++){
42   - getTime(starttime);
43   - //Open an socket end-point for this TCP Server
44   - if((socket_fd = socket(AF_INET, SOCK_STREAM, protonum))<0){
45   - handle_error("Socket descriptor creation failed");
46   - }
47   - if((connect(socket_fd, (struct sockaddr*)&server, sizeof(server)))<0){
48   - handle_error("Connect failed");
49   - }
50   - /*The end calculated here will miss time taken for ACK K+1
51   - from the client. And so we have to one way delay
52   - measured using another experiment*/
53   - getTime(endtime);
54   -
55   - //Calculate connection overhead client
56   - start_delta+=diff(endtime,starttime);
57   - printf("EndTime: %f usec\n", endtime.tv_sec + endtime.tv_usec*1e6);
58   - printf("Start time:%f usec\n", starttime.tv_sec +starttime.tv_usec*1e6);
59   - printf("Setup:%f\n",diff(endtime,starttime) + 25);
60   -
61   - getTime(starttime);
62   - sleep(1);
63   - close(socket_fd);
64   - getTime(endtime);
65   - printf("Endtime %f usec\n", endtime.tv_sec + endtime.tv_usec*1e6);
66   - printf("Start time:%f usec\n", starttime.tv_sec +starttime.tv_usec*1e6);
67   - printf("TearDown:%f\n",diff(endtime,starttime) + 25);
68   - //Calculate connection overhead server side
69   - close_delta+=diff(endtime,starttime);
70   - }
71   - printf("Connection Setup =%f us\n", (start_delta + RTT/2 * BACKLOG)/BACKLOG);
72   - printf("Connection Teardown =%f us\n", (close_delta + RTT/2 * BACKLOG)/BACKLOG);
73   - return 0;
74   -}
75   -
76   -
... ... @@ -3,8 +3,8 @@
3 3 #define NULL '\0'
4 4 #define __RASPERF_H__
5 5 #define RTT 35 //in MicroSec
6   -#define PI 0
7   -#define x86 1
  6 +#define PI 1
  7 +#define x86 0
8 8 #define CPU_CYCLES 900
9 9 #define MHz 1e6
10 10 #if defined(PI) && PI
... ... @@ -18,7 +18,7 @@
18 18 "mrc p15, 0, %0, c9, c14, 0":\
19 19 "=r" (var));
20 20 #define diff(end, begin) \
21   - (end - begin)/ CPU_CYCLES};
  21 + (end - begin)
22 22 #endif
23 23 #if defined(x86) && x86
24 24 #define time struct timeval