Commit bcd0dad561e84f0fd939f04faab37b2ebb2a92a8
1 parent
8a0c6a1f72
Exists in
master
Network Benchmarks
Showing 16 changed files with 609 additions and 58 deletions Inline Diff
- cpu/a.out
- network/ocli
- network/oser
- network/overhead_client.c
- network/overhead_server.c
- network/peak_client.c
- network/peak_server.c
- network/rand
- network/random_str.c
- network/rtt_client.c
- network/rtt_server.c
- network/run_script.sh
- network/tcp_rtt_client.bul
- network/tcp_rtt_server.c
- osproject_task.c
- rasperf.h
cpu/a.out
View file @
bcd0dad
network/ocli
View file @
bcd0dad
network/oser
View file @
bcd0dad
network/overhead_client.c
View file @
bcd0dad
File was created | 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 50 | |||
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 Error"); | |||
46 | } | |||
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 | getTime(endtime); | |||
54 | ||||
55 | //Calculate connection overhead client | |||
56 | start_delta+=diff(endtime,starttime); | |||
57 | ||||
58 | getTime(starttime); | |||
59 | shutdown(socket_fd, SHUT_RDWR); | |||
60 | getTime(endtime); | |||
61 | ||||
62 | //Calculate connection overhead server side |
network/overhead_server.c
View file @
bcd0dad
File was created | 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 | ||||
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 | printf("Accept Connection\n"); | |||
58 | waitpid(WAIT_ANY, NULL, WNOHANG); | |||
59 | connfd = accept(socket_fd, (struct sockaddr *)NULL, NULL); | |||
60 | if( connfd == -1){ | |||
61 | handle_error("Accept failed"); | |||
62 | } | |||
63 | if(pid = fork() == 0){ | |||
64 | //close the copy of socket descriptor | |||
65 | //child should not medle with it.. | |||
66 | close(socket_fd); | |||
67 | close(connfd); |
network/peak_client.c
View file @
bcd0dad
File was created | 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 50 | |||
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 Error"); | |||
46 | } | |||
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 | 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 |
network/peak_server.c
View file @
bcd0dad
File was created | 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 | } |
network/rand
View file @
bcd0dad
network/random_str.c
View file @
bcd0dad
File was created | 1 | #include<stdio.h> | ||
2 | #include<stdlib.h> | |||
3 | char* generate_string(int length) | |||
4 | { | |||
5 | //Random number seed | |||
6 | srand((unsigned int) ctime(0)); | |||
7 | char * buff; | |||
8 | buff=(char *)malloc(sizeof(char)*length); | |||
9 | int i; | |||
10 | for(i=0;i< length-1;i++){ | |||
11 | buff[i] = rand() % rand() % (126 - 33 + 1) + 33; | |||
12 | } | |||
13 | buff[i] = '\0'; | |||
14 | return buff; | |||
15 | } | |||
16 | int main() | |||
17 | { | |||
18 | char *buf; | |||
19 | buf = generate_string(5); | |||
20 | printf("String of 5: %s", buf); | |||
21 | free(buf); | |||
22 | ||||
23 | buf = generate_string(40); | |||
24 | printf("String of 5: %s", buf); | |||
25 | free(buf); | |||
26 | ||||
27 | buf = generate_string(80); | |||
28 | printf("String of 5: %s", buf); | |||
29 | free(buf); |
network/rtt_client.c
View file @
bcd0dad
File was created | 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 BUFFER_SIZE 2048 | |||
13 | #define STRIDE_SIZE 64 | |||
14 | #define BACKLOG 32 //buff size/stride size | |||
15 | ||||
16 | //A random string generator of given length | |||
17 | char* generate_string(int length) | |||
18 | { | |||
19 | //Random number seed | |||
20 | srand((unsigned int) ctime(0)); | |||
21 | char * buff; | |||
22 | buff=(char *)malloc(sizeof(char)*length); | |||
23 | int i; | |||
24 | for(i=0;i< length-1;i++){ | |||
25 | buff[i] = rand() % rand() % (126 - 33 + 1) + 33; | |||
26 | } | |||
27 | buff[i] = '\0'; | |||
28 | return buff; | |||
29 | } | |||
30 | ||||
31 | int main(int argc, char*argv[]) | |||
32 | { | |||
33 | int socket_fd, rc; | |||
34 | char buf[BUFFER_SIZE]; | |||
35 | char *msg; | |||
36 | float start_delta = 0, close_delta = 0; | |||
37 | if(argc<2){ | |||
38 | handle_error("<usage>:tcp_client <IP address>"); | |||
39 | } | |||
40 | //Retrieve the protocol number mapping | |||
41 | //from /etc/protocols file | |||
42 | struct protoent *proto_entry; | |||
43 | proto_entry = getprotobyname("tcp"); | |||
44 | ||||
45 | ||||
46 | //My address information to bind to | |||
47 | struct sockaddr_in server; | |||
48 | memset(&server, 0, sizeof(struct sockaddr)); | |||
49 | server.sin_family = AF_INET; | |||
50 | server.sin_port = htons(8000); | |||
51 | ||||
52 | rc= inet_pton(AF_INET, argv[1], &server.sin_addr); | |||
53 | if(rc == -1){ | |||
54 | handle_error("Address Error"); | |||
55 | } | |||
56 | time starttime, endtime; | |||
57 | //accept incoming connections | |||
58 | int addr_size = sizeof(struct sockaddr); | |||
59 | int i; | |||
60 | int protonum = proto_entry->p_proto; | |||
61 | ||||
62 | //Open an socket end-point for this TCP Server | |||
63 | if((socket_fd = socket(AF_INET, SOCK_STREAM, protonum))<0){ | |||
64 | handle_error("Socket Error"); | |||
65 | } | |||
66 | if(connect(socket_fd, (struct sockaddr*)&server, sizeof(server))<0){ | |||
67 | handle_error("Connection Error"); | |||
68 | } | |||
69 | ||||
70 | for(i=1;i<=BACKLOG;i++){ | |||
71 | //increase the sent message in strides of 64 | |||
72 | //look for for peak rtt | |||
73 | msg = generate_string(STRIDE_SIZE * i); | |||
74 | printf("String Generated: \"%s\"",msg); | |||
75 | getTime(starttime); | |||
76 | if(send(socket_fd, msg, sizeof(msg), 0) <0){ | |||
77 | handler_error("Send Error"); | |||
78 | } | |||
79 | //The recv buffer size is same as the one we sent | |||
80 | if(recv(socket_fd, buff, sizeof(msg), 0) != sizeof(msg)){ | |||
81 | handle_error("Data over/ Receive Error"); | |||
82 | } | |||
83 | getTime(endtime); |
network/rtt_server.c
View file @
bcd0dad
File was created | 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 | ||||
17 | int main(int argc, char*argv[]) | |||
18 | { | |||
19 | int socket_fd, rc; | |||
20 | char buff[BUFFER_SIZE], msg[BUFFER_SIZE]; | |||
21 | char | |||
22 | float setup_delta, close_delta; | |||
23 | if(argc<1){ | |||
24 | handle_error("<usage>:tcp_server"); | |||
25 | } | |||
26 | //Retrieve the protocol number mapping | |||
27 | //from /etc/protocols file | |||
28 | struct protoent *proto_entry; | |||
29 | proto_entry = getprotobyname("tcp"); | |||
30 | ||||
31 | //Open an socket end-point for this TCP Server | |||
32 | socket_fd = socket(AF_INET, SOCK_STREAM, proto_entry->p_proto); | |||
33 | if(socket_fd == -1){ | |||
34 | handle_error("Socket descriptor creation failed"); | |||
35 | } | |||
36 | ||||
37 | //My address information to bind to | |||
38 | struct sockaddr_in sock_addr; | |||
39 | memset(&sock_addr, 0, sizeof(struct sockaddr)); | |||
40 | sock_addr.sin_family = AF_INET; | |||
41 | sock_addr.sin_addr.s_addr = htonl(INADDR_ANY); | |||
42 | sock_addr.sin_port = htons(8000); | |||
43 | ||||
44 | ||||
45 | rc = bind(socket_fd, (struct sockaddr*)&sock_addr, sizeof(sock_addr)); | |||
46 | if(rc == -1){ | |||
47 | handle_error("Bind failure"); | |||
48 | } | |||
49 | rc = listen(socket_fd, LISTEN_BACKLOG); | |||
50 | if(rc == -1){ | |||
51 | handle_error(" Listen Error"); | |||
52 | } | |||
53 | ||||
54 | time starttime, endtime; | |||
55 | //accept incoming connections | |||
56 | int connfd, i, pid, addr_size = sizeof(struct sockaddr); | |||
57 | printf("Accept Connection\n"); | |||
58 | connfd = accept(socket_fd, (struct sockaddr *)NULL, NULL); | |||
59 | if( connfd == -1){ | |||
60 | handle_error("Accept failed"); | |||
61 | } | |||
62 | for(i=1;i<=BACKLOG;i++) | |||
63 | { | |||
64 | getTime(starttime); | |||
65 | if(recv(connfd, buff, sizeof(i* STRIDE_SIZE), 0)!= sizeof(i* STRIDE_SIZE)){ | |||
66 | handle_error("Receive Error/ Data Done"); | |||
67 | } | |||
68 | if(send(connfd, buff, sizeof(i * STRIDE_SIZE), 0)<0){ | |||
69 | handle_error("Send Error"); | |||
70 | } |
network/run_script.sh
View file @
bcd0dad
File was created | 1 | #!/bin/bash | ||
2 | for i in `seq 1 10`; | |||
3 | do | |||
4 | ./tcp_client localhost | |||
5 | done |
network/tcp_rtt_client.bul
View file @
bcd0dad
File was created | 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); |
network/tcp_rtt_server.c
View file @
bcd0dad
#include "../rasperf.h" | 1 | File was deleted | ||
#include<arpa/inet.h> | 2 | |||
#include<sys/typesh> | 3 | |||
#include<sys/socket.h> | 4 | |||
#include<netdb.h> | 5 | |||
6 | ||||
//Macro definitions | 7 | |||
#define handle_error(msg) \ | 8 | |||
do { perror(msg); exit(EXIT_FAILURE);} while(0) | 9 | |||
#define LISTEN_BACKLOG 5 | 10 | |||
int main(int argc, char*argv[]) | 11 | |||
{ | 12 | |||
int socket_fd, rc; | 13 | |||
if(argc<1){ | 14 | |||
handle_error("<usage>:"); | 15 | |||
} | 16 | |||
//Retrieve the protocol number mapping | 17 | |||
//from /etc/protocols file | 18 | |||
struct protoent *proto_entry; | 19 | |||
proto_entry = getprotobyname("tcp"); | 20 | |||
21 | ||||
//Open an socket end-point for this TCP Server | 22 | |||
socket_fd = socket(AF_INET, SOCK_STREAM, proto_entry->p_proto); | 23 | |||
if(socket_fd == -1){ | 24 | |||
handle_error("Errno: %d,Socket descriptor creation failed", errorno); | 25 | |||
} | 26 | |||
27 | ||||
//My address information to bind to | 28 | |||
struct sockaddr sock_addr; | 29 | |||
memset(&sock_addr, 0, sizeof(struct sockaddr)); | 30 | |||
sock_addr.sa_family = AF_INET; | 31 | |||
sock_addr.sin_addr.s_addr = htonl(INADDR_ANY); | 32 | |||
sock_addr.sin_port = htons(8000); | 33 | |||
34 | ||||
35 | ||||
rc = bind(sock_fd, &sock_addr, sizeof(sock_addr)); | 36 | |||
if(rc == -1){ | 37 | |||
handle_error("Errno: %d, Bind failure", errorno); | 38 | |||
} | 39 | |||
rc = listen(socket_fd, LISTEN_BACKLOG); | 40 | |||
if(rc == -1){ | 41 | |||
handle_error("Errno: %d, Listen Error", errorno); | 42 | |||
} | 43 |
osproject_task.c
View file @
bcd0dad
#include <stdio.h> | 1 | 1 | #include <stdio.h> | |
#include <stdlib.h> | 2 | 2 | #include <stdlib.h> | |
3 | 3 | |||
int main() | 4 | 4 | int main() | |
{ | 5 | 5 | { | |
unsigned int regr; | 6 | 6 | unsigned int regr; | |
unsigned int a, b; | 7 | 7 | unsigned int a, b; | |
unsigned int avg; | 8 | 8 | unsigned int avg; | |
int status; | 9 | 9 | int status; | |
asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (regr)); | 10 | 10 | readCCNT(regr); | |
printf("regr: %x\n", regr); | 11 | 11 | printf("regr: %x\n", regr); | |
12 | 12 | getTime(a); | ||
asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (a)); | 13 | |||
int pid = fork(); | 14 | 13 | int pid = fork(); | |
if (pid) { | 15 | 14 | if (pid) { | |
asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (b)); | 16 | 15 | getTime(b); | |
printf("Time for fork: %u\n", b - a); | 17 | 16 | printf("Time for fork: %u\n", b - a); | |
} | 18 | 17 | } | |
19 | 18 | |||
return 0; | 20 | 19 | return 0; | |
} | 21 | 20 | } |
rasperf.h
View file @
bcd0dad
1 | ||||
#ifndef __RASPERF_H__ | 1 | 2 | #ifndef __RASPERF_H__ | |
3 | #define NULL '\0' | |||
#define __RASPERF_H__ | 2 | 4 | #define __RASPERF_H__ | |
#define PI 1 | 3 | 5 | #define RTT 35 //in MicroSec | |
#define x86 0 | 4 | 6 | #define PI 0 | |
7 | #define x86 1 | |||
8 | #define CPU_CYCLES 900 | |||
9 | #define MHz 1e6 | |||
#if defined(PI) && PI | 5 | 10 | #if defined(PI) && PI | |
#define time unsigned int | 6 | 11 | #define time unsigned int | |
#define getTime(var) \ | 7 | 12 | #define getTime(var) \ | |
asm volatile (\ | 8 | 13 | asm volatile (\ | |
"mrc p15, 0, %0, c9, c13, 0":\ | 9 | 14 | "mrc p15, 0, %0, c9, c13, 0":\ | |
"=r" (var)); | 10 | 15 | "=r" (var)); | |
#define readCCNTStatus(var) \ | 11 | 16 | #define readCCNTStatus(var) \ | |
asm volatile (\ | 12 | 17 | asm volatile (\ | |
"mrc p15, 0, %0, c9, c14, 0":\ | 13 | 18 | "mrc p15, 0, %0, c9, c14, 0":\ | |
"=r" (var)); | 14 | 19 | "=r" (var)); | |
#define diff(end, begin) (end - begin) | 15 | 20 | #define diff(end, begin) \ | |
21 | (end - begin)/ CPU_CYCLES}; | |||
#endif | 16 | 22 | #endif | |
#if defined(x86) && x86 | 17 | 23 | #if defined(x86) && x86 | |
#define time struct timeval | 18 | 24 | #define time struct timeval | |
#define getTime(var) gettimeofday(&var, NULL) | 19 | 25 | #define getTime(var) gettimeofday(&var, NULL) | |
#define diff(end, begin) \ | 20 | 26 | #define diff(end, begin) \ | |
(end.tv_sec*1e6+end.tv_usec - begin.tv_sec*1e6+ begin.tv_usec) | 21 | 27 | ((end.tv_sec*1e6+end.tv_usec) - (begin.tv_sec*1e6+ begin.tv_usec)) | |
#endif | 22 | 28 | #endif | |
#endif | 23 | 29 | #endif | |
24 | 30 | |||
25 | 31 | |||