From bcd0dad561e84f0fd939f04faab37b2ebb2a92a8 Mon Sep 17 00:00:00 2001 From: Ajay Mohan Date: Sat, 12 Mar 2016 07:35:09 -0800 Subject: [PATCH] Network Benchmarks --- cpu/a.out | Bin 6251 -> 0 bytes network/ocli | Bin 0 -> 9160 bytes network/oser | Bin 0 -> 13496 bytes network/overhead_client.c | 70 +++++++++++++++++++++++++++++++++ network/overhead_server.c | 78 +++++++++++++++++++++++++++++++++++++ network/peak_client.c | 70 +++++++++++++++++++++++++++++++++ network/peak_server.c | 90 +++++++++++++++++++++++++++++++++++++++++++ network/rand | Bin 0 -> 8852 bytes network/random_str.c | 32 +++++++++++++++ network/rtt_client.c | 94 +++++++++++++++++++++++++++++++++++++++++++++ network/rtt_server.c | 80 ++++++++++++++++++++++++++++++++++++++ network/run_script.sh | 6 +++ network/tcp_rtt_client.bul | 76 ++++++++++++++++++++++++++++++++++++ network/tcp_rtt_server.c | 50 ------------------------ osproject_task.c | 7 ++-- rasperf.h | 14 +++++-- 16 files changed, 609 insertions(+), 58 deletions(-) delete mode 100755 cpu/a.out create mode 100755 network/ocli create mode 100755 network/oser create mode 100644 network/overhead_client.c create mode 100644 network/overhead_server.c create mode 100644 network/peak_client.c create mode 100644 network/peak_server.c create mode 100755 network/rand create mode 100644 network/random_str.c create mode 100644 network/rtt_client.c create mode 100644 network/rtt_server.c create mode 100755 network/run_script.sh create mode 100644 network/tcp_rtt_client.bul delete mode 100644 network/tcp_rtt_server.c diff --git a/cpu/a.out b/cpu/a.out deleted file mode 100755 index 42ff03228098fea0de181c79488b2422125b5273..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6251 zcmd5=U2I%O6`s5P=_a+Cjq5gUoL0BQRH^9RUB_;SDxh{8=MOtg6Z1epy1Bc1?OnRN zce#6AoT{i!(@2#lq@_lJ67T|f2vU$D5s3;lC~BfUpaPXBFR0M9lU3bTpj1>)ewXi? zx#L{BsRVC5tFtrToHOUl-uGtk3=7<=~fh6c|w(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>*~GQq(r*SY$=NSgjEzT%kP_=nfb7b9xf_BMesUQC_h#3`cjBj2wpb| z@o9qBgF<|Ie&1Y(&&bc;h4@U&$C?w8ai5r#f0uG5`Y@yLJX(kcL~y3&gk;=@!NT*N zGtno|yLdixB=~TX&hwN5MnCwP;Q6NzuflxN=7eP2C+6ZEsTh7;{+`*XPVp!qs zbL9QNJq|m0d~`~DvOf>2eE3`nR)!zp>nYMM!@!Hxi^?g6|54^MTU>Ru`&$y9><7R_ z^Ld{VV2`^$dBx_LlluX$#&qC z=s)g$VgfJrUbIKzlgHPSCFFln0zX~?f3*buP6_;C34AsjLiKWwiv_@o`KK26Y;Uy~ zbd8slgky)n^9JvKnt&JcPn*OsFU`pAWh6&#=5}9PKTUKb=b`A9s5l zRr%2UKLvT01p12-`MeA~NP@2LW(oO!mB6n8C%?JvDZ{!KbmdL#0^oCSV&Z)|i!72j za}L^(veH%tH%9O)cw<2^Y1jZzKn`MBBSfK^Fn`qp2`Vc`Ly0 zubRehsPuBGa&kT5PRP{Ruf7uiDcKLZg_!eIw=l(i|1HEOz4N-0o%R>L0HYbxNuw*8 zh@qNB(>*Xf7Ec(Nv>BUtdv<4+cO1DI9!bFewyO&tpxt`7Nl|k0G1`9nb_uO}#Mq>I oX=8UZokka>=kh`+^;}*E8V1^o`wBHCckP0vl-)x;#24!S7ir&syZ`_I literal 0 HcmV?d00001 diff --git a/network/oser b/network/oser new file mode 100755 index 0000000000000000000000000000000000000000..4ccfe1e8552aec7988de0f0cb0e449e90b5aa572 GIT binary patch literal 13496 zcmeHOZ){uD6~DIICZ(<8mJC7*%^OgbR*IXJPy!5iPU`lhN=s=|U_kof*e{8xV_Wt! zO*^FonIf#LEFaJm7}Gkbo4Son(Nv*`55%RYsnD1L8*Caws}O(eGNf#js_Fpmocr!^ z-h1(r&^}C>HvA+2vi>yJn zdJUE+V-g2Y58LWn%UPhkJVSI+v|~z8(nA*YnuK1H&?7o48b*}v5AO|s-NIhCTLun! z8426Uuk#dTG41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YzmU8b7R0jSLZAGf6#H^g=>N1VX=KQM1fR6&Q~VLdCAE^Ep!WJ-w&^P? zWG<_(Fdk6L#qR60wvFps;abYECcCHxI;XC;%pGMV7i*e4eH z0ShbH`H*X^S}-2I0Nhof-@g{}_V%xYhPv3oe*X^OtHA#l)r5)Gu-gHbIAXo*<@myJ zvY*?r$|9Ep+y`&f)Gs7)kjpQeUn357o_D}sa=`Nr_#YkcPaN@32|X9x4><6g&mA{!^C4qfd1COPTm23#{n+_E}>yt`pQ9mrKfT{@lAlEpY846 z2)Jakjclibokuyoa3AS&kk=h>7EbADJp&O=VF(1?(XmJE>fGC{sw|?Vv;ho8N~!vg z3V}s&EzK%Gsv1eC1F=M3D5gdrzA3GSGQ$ksypu6a*CPHccies}Sgs(X;u(PPMz6wK zdg>4}&Hy5rp`k;dV&YUhIt5vJ%OD;HMnalG~c)v%3IVUOx^mu zU4fmQ9Ux^Y;UUpX-QIOyd!S3bZ`-!L!EUuX(B2h9b3AG~oX+r8GqtmOr#kPV?wuXz zpzcs#Ok;QeVMJ5&SZ-OSh-!?ZRyBS;A*|Q}yyrz*jhOIx0CkPHZ!5+F$gPkO7jDIP zV3-wJ5D0EBHr#&^olplu@d(_m+Ib(`MkE?nGieBCGkFSqD`M7dwlxS@7cR1f zr`zOIIK~ljJX9TH-K`=b@ZAa;k@Qwf-SN1(M~vu>SSX!_;cUdoTjek;--@UzbT17n b?01?4mR{$<_BKWC01V}~;>JG!Sh4>AQ5b?h literal 0 HcmV?d00001 diff --git a/network/overhead_client.c b/network/overhead_client.c new file mode 100644 index 0000000..241fa1a --- /dev/null +++ b/network/overhead_client.c @@ -0,0 +1,70 @@ +#include "../rasperf.h" +#include +#include +#include +#include +#include +#include +#include +//Macro definitions +#define handle_error(msg) \ + do { perror(msg); exit(1);} while(0); +#define BACKLOG 50 +int main(int argc, char*argv[]) +{ + int socket_fd, rc; + float start_delta = 0, close_delta = 0; + if(argc<2){ + handle_error(":tcp_client "); + } + //Retrieve the protocol number mapping + //from /etc/protocols file + struct protoent *proto_entry; + proto_entry = getprotobyname("tcp"); + + + //My address information to bind to + struct sockaddr_in server; + memset(&server, 0, sizeof(struct sockaddr)); + server.sin_family = AF_INET; + server.sin_port = htons(8000); + + rc= inet_pton(AF_INET, argv[1], &server.sin_addr); + if(rc == -1){ + handle_error("Address Error"); + } + time starttime, endtime; + //accept incoming connections + int addr_size = sizeof(struct sockaddr); + int i; + int protonum = proto_entry->p_proto; + for(i=1;i<=BACKLOG;i++){ + getTime(starttime); + //Open an socket end-point for this TCP Server + if((socket_fd = socket(AF_INET, SOCK_STREAM, protonum))<0){ + handle_error("Socket Error"); + } + if(connect(socket_fd, (struct sockaddr*)&server, sizeof(server))<0){ + handle_error("Connection Error"); + } + /*The end calculated here will miss time taken for ACK K+1 + from the client. And so we have to one way delay + measured using another experiment*/ + getTime(endtime); + + //Calculate connection overhead client + start_delta+=diff(endtime,starttime); + + getTime(starttime); + shutdown(socket_fd, SHUT_RDWR); + getTime(endtime); + + //Calculate connection overhead server side + close_delta+=diff(endtime,starttime); + } + printf("Connection Setup =%f us\n", (start_delta + RTT/2 * BACKLOG)/BACKLOG); + printf("Connection Teardown =%f us\n", (close_delta + RTT/2 * BACKLOG)/BACKLOG); + return 0; +} + + diff --git a/network/overhead_server.c b/network/overhead_server.c new file mode 100644 index 0000000..db3c1f2 --- /dev/null +++ b/network/overhead_server.c @@ -0,0 +1,78 @@ +#include "../rasperf.h" +#include +#include +#include +#include +#include +#include +#include +#include + +//Macro definitions +#define handle_error(msg) \ + do { perror(msg); exit(1);} while(0); +#define LISTEN_BACKLOG 100 + +int main(int argc, char*argv[]) +{ + int socket_fd, rc; + float setup_delta, close_delta; + if(argc<1){ + handle_error(":tcp_server"); + } + //Retrieve the protocol number mapping + //from /etc/protocols file + struct protoent *proto_entry; + proto_entry = getprotobyname("tcp"); + + //Open an socket end-point for this TCP Server + socket_fd = socket(AF_INET, SOCK_STREAM, proto_entry->p_proto); + if(socket_fd == -1){ + handle_error("Socket descriptor creation failed"); + } + + //My address information to bind to + struct sockaddr_in sock_addr; + memset(&sock_addr, 0, sizeof(struct sockaddr)); + sock_addr.sin_family = AF_INET; + sock_addr.sin_addr.s_addr = htonl(INADDR_ANY); + sock_addr.sin_port = htons(8000); + + + rc = bind(socket_fd, (struct sockaddr*)&sock_addr, sizeof(sock_addr)); + if(rc == -1){ + handle_error("Bind failure"); + } + rc = listen(socket_fd, LISTEN_BACKLOG); + if(rc == -1){ + handle_error(" Listen Error"); + } + + time starttime, endtime; + + //accept incoming connections + int connfd, i, pid, addr_size = sizeof(struct sockaddr); + for(i=1;i<=1000;i++) + { + printf("Accept Connection\n"); + waitpid(WAIT_ANY, NULL, WNOHANG); + connfd = accept(socket_fd, (struct sockaddr *)NULL, NULL); + if( connfd == -1){ + handle_error("Accept failed"); + } + if(pid = fork() == 0){ + //close the copy of socket descriptor + //child should not medle with it.. + close(socket_fd); + close(connfd); + printf("Connection %d closed in Child\n",i); + exit(0); + } + close(connfd); + } + close(socket_fd); + + return 0; +} + + diff --git a/network/peak_client.c b/network/peak_client.c new file mode 100644 index 0000000..3527121 --- /dev/null +++ b/network/peak_client.c @@ -0,0 +1,70 @@ +#include "../rasperf.h" +#include +#include +#include +#include +#include +#include +#include +//Macro definitions +#define handle_error(msg) \ + do { perror(msg); exit(1);} while(0); +#define BACKLOG 50 +int main(int argc, char*argv[]) +{ + int socket_fd, rc; + float start_delta = 0, close_delta = 0; + if(argc<2){ + handle_error(":tcp_client "); + } + //Retrieve the protocol number mapping + //from /etc/protocols file + struct protoent *proto_entry; + proto_entry = getprotobyname("tcp"); + + + //My address information to bind to + struct sockaddr_in server; + memset(&server, 0, sizeof(struct sockaddr)); + server.sin_family = AF_INET; + server.sin_port = htons(8000); + + rc= inet_pton(AF_INET, argv[1], &server.sin_addr); + if(rc == -1){ + handle_error("Address Error"); + } + time starttime, endtime; + //accept incoming connections + int addr_size = sizeof(struct sockaddr); + int i; + int protonum = proto_entry->p_proto; + for(i=1;i<=BACKLOG;i++){ + getTime(starttime); + //Open an socket end-point for this TCP Server + if((socket_fd = socket(AF_INET, SOCK_STREAM, protonum))<0){ + handle_error("Socket Error"); + } + if(connect(socket_fd, (struct sockaddr*)&server, sizeof(server))<0){ + handle_error("Connection Error"); + } + /*The end calculated here will miss time taken for ACK K+1 + from the client. And so we have to one way delay + measured using another experiment*/ + getTime(endtime); + + //Calculate connection overhead client + start_delta+=diff(endtime,starttime); + + getTime(starttime); + close(socket_fd); + getTime(endtime); + + //Calculate connection overhead server side + close_delta+=diff(endtime,starttime); + } + printf("Connection Setup =%f us\n", (start_delta + RTT/2 * BACKLOG)/BACKLOG); + printf("Connection Teardown =%f us\n", (close_delta + RTT/2 * BACKLOG)/BACKLOG); + return 0; +} + + diff --git a/network/peak_server.c b/network/peak_server.c new file mode 100644 index 0000000..87de305 --- /dev/null +++ b/network/peak_server.c @@ -0,0 +1,90 @@ +#include "../rasperf.h" +#include +#include +#include +#include +#include +#include +#include +#include + +//Macro definitions +#define handle_error(msg) \ + do { perror(msg); exit(1);} while(0); +#define LISTEN_BACKLOG 50 + +int main(int argc, char*argv[]) +{ + int socket_fd, rc; + float setup_delta, close_delta; + if(argc<1){ + handle_error(":tcp_server"); + } + //Retrieve the protocol number mapping + //from /etc/protocols file + struct protoent *proto_entry; + proto_entry = getprotobyname("tcp"); + + //Open an socket end-point for this TCP Server + socket_fd = socket(AF_INET, SOCK_STREAM, proto_entry->p_proto); + if(socket_fd == -1){ + handle_error("Socket descriptor creation failed"); + } + + //My address information to bind to + struct sockaddr_in sock_addr; + memset(&sock_addr, 0, sizeof(struct sockaddr)); + sock_addr.sin_family = AF_INET; + sock_addr.sin_addr.s_addr = htonl(INADDR_ANY); + sock_addr.sin_port = htons(8000); + + + rc = bind(socket_fd, (struct sockaddr*)&sock_addr, sizeof(sock_addr)); + if(rc == -1){ + handle_error("Bind failure"); + } + rc = listen(socket_fd, LISTEN_BACKLOG); + if(rc == -1){ + handle_error(" Listen Error"); + } + + time starttime, endtime; + + //accept incoming connections + int connfd, i, pid, addr_size = sizeof(struct sockaddr); + for(i=1;i<=1000;i++) + { + //getTime(starttime); + printf("Accept Connection\n"); + //waitpid(WAIT_ANY, NULL, WNOHANG); + connfd = accept(socket_fd, (struct sockaddr *)NULL, NULL); + /*The end calculated here would have missed SYN time + from the client. And so we have to add one + packet worth round trip time in the overhead*/ + //getTime(endtime); + if( connfd == -1){ + handle_error("Accept failed"); + } + //setup_delta+=diff(endtime,starttime); + if(pid = fork() == 0){ + close(socket_fd); + close(connfd); + printf("Connection %d closed in Child\n",i); + //close_delta=diff(endtime, starttime); + //printf("Connection Termination %f", close_delta + RTT); + exit(0); + } + close(connfd); + } + //getTime(starttime); + close(socket_fd); + //getTime(endtime); + + //Calculate connection overhead server side + //setup_delta+=diff(endtime,starttime); + //printf("Connection Overhead:Setup =%f us\n", (setup_delta+ RTT*600)/600); + + return 0; +} + + diff --git a/network/rand b/network/rand new file mode 100755 index 0000000000000000000000000000000000000000..ebd6e6eb4e94a6316ade822f6b4d268c202fb4b5 GIT binary patch literal 8852 zcmeHMeQaCR6~DIg)i1~C$`&YV-dHQ8NHJ|FCFNs0Cvp1Hr5|e@C?DyI6FZ5)u_ODr zv`m9ap=DNE)<3GLRGL8h1F;Ql42h}gA2ey8Wz+sh853;lHdeKhQ()>ufovMhe&@b> z;^!ATMnmgT@GJ0558y~oc<3Dk2|dZP|p71 zd2oTa_EQ+wi)<#Eiiwd-B4rJTek(B?7sJtHGTkpslcdb770p=Ya5Rw;1DSXn@ZfMd zrC?KR?CNZ7Gn<3W!8^z+@9fXc6GkznAI62`gvi~LzzFh+Zz_JewpZq;Z#nx{eZa=6 zfs;Nb&4JGjB@{L~aQfdlt#RPom#M79fjh^$?!cY?7!I6#;IPEpa!`?U@G2s=R>%a2d{AaCSP8{?PnGdz>Vx#=8~Pm-Xq|847PkC8uP>t9g% z`|hoSzam%H4b8%naHQu<<+TNx@O(T$@iRv6eW@A(){0pdmUW-fFsnj-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qNalUG<>Bvv zv(SgtHqY~=_@deQyA)q6cwR2Wm(1QXmEwNE^JpnvD|mh^#RIeVBc*tq;Q6c+UphNa zmEvC#JpYv9%P^nxIw6_&i5qY)R1W{L;CaBQS zRkX)dh4?!S$C5@QNkkeb;(DsPI6Qj$AQ?kR^HdzL3^89*3ViJ_aN{ zH=c);9o}bxmFYRWJ-8|1{i1^9S!ua;Q9b4GH>I6A9Hi=OLek$zd~O`5u$-MgORc4I z`ok4zXYT+04<+yRe=!{Ol=f<$+J>8@E73Zr@R0E4Y=lXP~|@d zUgxbBy{>Vw5CN>iN`mJHUMJlMoZ>80oa4&QYKhOS;9lSX^yd+m{Z?g%*N3dxspQ>p z?pE@2A4BPR`4-|K;F`)iNeVc%%Wdb0dE}2u`*Y{p;}UmTR{8#nm9=s>iKpwsO>NuF zuFf41(-g6ICO(+RV$*C|!)AXnor-5g8OStaX>%}{?u#bPn3c|C&1i0qz)o}|8MorG z;Q9@B-VV!UgiP8K+dEtnyVlHJ+*Z<_IF=h8-U}56XVO->M3nA8)5Eya%t*&Owud%{ z&G43Xcy2d?^Cg-wVYWZGCA7J-4N{I0d1ETfja^$?LtW<9j*cDSh#3jBc7@5Dyj1Pa z=A^^&N>$gLm#AiEWV2a}S7dV=MJp2ROU4E5&h495VaDZFUEbKb49L>~`$pGQ;=a)> zEtXforO;qJ70*PiIE4ncCve~CLg`H~%Cc#52%&_hX6IJu#1bhpmyIJ(#b#5W)D?4S zUHID|sDfwW2twuM)w8*2x4B()p|)f+n??UIO$3MkCW;z&sFIk;e@4(hTw2|~0VfMW AtN;K2 literal 0 HcmV?d00001 diff --git a/network/random_str.c b/network/random_str.c new file mode 100644 index 0000000..7f765d5 --- /dev/null +++ b/network/random_str.c @@ -0,0 +1,32 @@ +#include +#include +char* generate_string(int length) +{ + //Random number seed + srand((unsigned int) ctime(0)); + char * buff; + buff=(char *)malloc(sizeof(char)*length); + int i; + for(i=0;i< length-1;i++){ + buff[i] = rand() % rand() % (126 - 33 + 1) + 33; + } + buff[i] = '\0'; + return buff; +} +int main() +{ + char *buf; + buf = generate_string(5); + printf("String of 5: %s", buf); + free(buf); + + buf = generate_string(40); + printf("String of 5: %s", buf); + free(buf); + + buf = generate_string(80); + printf("String of 5: %s", buf); + free(buf); + + return 0; +} diff --git a/network/rtt_client.c b/network/rtt_client.c new file mode 100644 index 0000000..3a743d6 --- /dev/null +++ b/network/rtt_client.c @@ -0,0 +1,94 @@ +#include "../rasperf.h" +#include +#include +#include +#include +#include +#include +#include +//Macro definitions +#define handle_error(msg) \ + do { perror(msg); exit(1);} while(0); +#define BUFFER_SIZE 2048 +#define STRIDE_SIZE 64 +#define BACKLOG 32 //buff size/stride size + +//A random string generator of given length +char* generate_string(int length) +{ + //Random number seed + srand((unsigned int) ctime(0)); + char * buff; + buff=(char *)malloc(sizeof(char)*length); + int i; + for(i=0;i< length-1;i++){ + buff[i] = rand() % rand() % (126 - 33 + 1) + 33; + } + buff[i] = '\0'; + return buff; +} + +int main(int argc, char*argv[]) +{ + int socket_fd, rc; + char buf[BUFFER_SIZE]; + char *msg; + float start_delta = 0, close_delta = 0; + if(argc<2){ + handle_error(":tcp_client "); + } + //Retrieve the protocol number mapping + //from /etc/protocols file + struct protoent *proto_entry; + proto_entry = getprotobyname("tcp"); + + + //My address information to bind to + struct sockaddr_in server; + memset(&server, 0, sizeof(struct sockaddr)); + server.sin_family = AF_INET; + server.sin_port = htons(8000); + + rc= inet_pton(AF_INET, argv[1], &server.sin_addr); + if(rc == -1){ + handle_error("Address Error"); + } + time starttime, endtime; + //accept incoming connections + int addr_size = sizeof(struct sockaddr); + int i; + int protonum = proto_entry->p_proto; + + //Open an socket end-point for this TCP Server + if((socket_fd = socket(AF_INET, SOCK_STREAM, protonum))<0){ + handle_error("Socket Error"); + } + if(connect(socket_fd, (struct sockaddr*)&server, sizeof(server))<0){ + handle_error("Connection Error"); + } + + for(i=1;i<=BACKLOG;i++){ + //increase the sent message in strides of 64 + //look for for peak rtt + msg = generate_string(STRIDE_SIZE * i); + printf("String Generated: \"%s\"",msg); + getTime(starttime); + if(send(socket_fd, msg, sizeof(msg), 0) <0){ + handler_error("Send Error"); + } + //The recv buffer size is same as the one we sent + if(recv(socket_fd, buff, sizeof(msg), 0) != sizeof(msg)){ + handle_error("Data over/ Receive Error"); + } + getTime(endtime); + delta+=diff(endtime, starttime); + printf("Single RTT %f", diff(endtime, starttime)); + + } + + close(socket_fd); + printf("Averaged RTT =%f us\n", delta/BACKLOG); + return 0; +} + + diff --git a/network/rtt_server.c b/network/rtt_server.c new file mode 100644 index 0000000..2ff16a1 --- /dev/null +++ b/network/rtt_server.c @@ -0,0 +1,80 @@ +#include "../rasperf.h" +#include +#include +#include +#include +#include +#include +#include +#include + +//Macro definitions +#define handle_error(msg) \ + do { perror(msg); exit(1);} while(0); +#define LISTEN_BACKLOG 100 +#define BUFFER_SIZE 2048 + +int main(int argc, char*argv[]) +{ + int socket_fd, rc; + char buff[BUFFER_SIZE], msg[BUFFER_SIZE]; + char + float setup_delta, close_delta; + if(argc<1){ + handle_error(":tcp_server"); + } + //Retrieve the protocol number mapping + //from /etc/protocols file + struct protoent *proto_entry; + proto_entry = getprotobyname("tcp"); + + //Open an socket end-point for this TCP Server + socket_fd = socket(AF_INET, SOCK_STREAM, proto_entry->p_proto); + if(socket_fd == -1){ + handle_error("Socket descriptor creation failed"); + } + + //My address information to bind to + struct sockaddr_in sock_addr; + memset(&sock_addr, 0, sizeof(struct sockaddr)); + sock_addr.sin_family = AF_INET; + sock_addr.sin_addr.s_addr = htonl(INADDR_ANY); + sock_addr.sin_port = htons(8000); + + + rc = bind(socket_fd, (struct sockaddr*)&sock_addr, sizeof(sock_addr)); + if(rc == -1){ + handle_error("Bind failure"); + } + rc = listen(socket_fd, LISTEN_BACKLOG); + if(rc == -1){ + handle_error(" Listen Error"); + } + + time starttime, endtime; + //accept incoming connections + int connfd, i, pid, addr_size = sizeof(struct sockaddr); + printf("Accept Connection\n"); + connfd = accept(socket_fd, (struct sockaddr *)NULL, NULL); + if( connfd == -1){ + handle_error("Accept failed"); + } + for(i=1;i<=BACKLOG;i++) + { + getTime(starttime); + if(recv(connfd, buff, sizeof(i* STRIDE_SIZE), 0)!= sizeof(i* STRIDE_SIZE)){ + handle_error("Receive Error/ Data Done"); + } + if(send(connfd, buff, sizeof(i * STRIDE_SIZE), 0)<0){ + handle_error("Send Error"); + } + getTime(endtime); + } + + close(socket_fd); + close(connfd); + printf("Connection %d closed in Child\n",i); + return 0; +} + + diff --git a/network/run_script.sh b/network/run_script.sh new file mode 100755 index 0000000..8d32350 --- /dev/null +++ b/network/run_script.sh @@ -0,0 +1,6 @@ +#!/bin/bash +for i in `seq 1 10`; +do + ./tcp_client localhost +done + diff --git a/network/tcp_rtt_client.bul b/network/tcp_rtt_client.bul new file mode 100644 index 0000000..82bf516 --- /dev/null +++ b/network/tcp_rtt_client.bul @@ -0,0 +1,76 @@ +#include "../rasperf.h" +#include +#include +#include +#include +#include +#include +#include +//Macro definitions +#define handle_error(msg) \ + do { perror(msg); exit(1);} while(0); +#define BACKLOG 1 +int main(int argc, char*argv[]) +{ + int socket_fd, rc; + float start_delta = 0, close_delta = 0; + if(argc<2){ + handle_error(":tcp_client "); + } + //Retrieve the protocol number mapping + //from /etc/protocols file + struct protoent *proto_entry; + proto_entry = getprotobyname("tcp"); + + + //My address information to bind to + struct sockaddr_in server; + memset(&server, 0, sizeof(struct sockaddr)); + server.sin_family = AF_INET; + server.sin_port = htons(8000); + + rc= inet_pton(AF_INET, argv[1], &server.sin_addr); + if(rc == -1){ + handle_error("Address Error"); + } + time starttime, endtime; + //accept incoming connections + int addr_size = sizeof(struct sockaddr); + int i; + int protonum = proto_entry->p_proto; + for(i=1;i<=BACKLOG;i++){ + getTime(starttime); + //Open an socket end-point for this TCP Server + if((socket_fd = socket(AF_INET, SOCK_STREAM, protonum))<0){ + handle_error("Socket descriptor creation failed"); + } + if((connect(socket_fd, (struct sockaddr*)&server, sizeof(server)))<0){ + handle_error("Connect failed"); + } + /*The end calculated here will miss time taken for ACK K+1 + from the client. And so we have to one way delay + measured using another experiment*/ + getTime(endtime); + + //Calculate connection overhead client + start_delta+=diff(endtime,starttime); + printf("EndTime: %f usec\n", endtime.tv_sec + endtime.tv_usec*1e6); + printf("Start time:%f usec\n", starttime.tv_sec +starttime.tv_usec*1e6); + printf("Setup:%f\n",diff(endtime,starttime) + 25); + + getTime(starttime); + sleep(1); + close(socket_fd); + getTime(endtime); + printf("Endtime %f usec\n", endtime.tv_sec + endtime.tv_usec*1e6); + printf("Start time:%f usec\n", starttime.tv_sec +starttime.tv_usec*1e6); + printf("TearDown:%f\n",diff(endtime,starttime) + 25); + //Calculate connection overhead server side + close_delta+=diff(endtime,starttime); + } + printf("Connection Setup =%f us\n", (start_delta + RTT/2 * BACKLOG)/BACKLOG); + printf("Connection Teardown =%f us\n", (close_delta + RTT/2 * BACKLOG)/BACKLOG); + return 0; +} + + diff --git a/network/tcp_rtt_server.c b/network/tcp_rtt_server.c deleted file mode 100644 index 2e2fbd0..0000000 --- a/network/tcp_rtt_server.c +++ /dev/null @@ -1,50 +0,0 @@ -#include "../rasperf.h" -#include -#include -#include -#include - -//Macro definitions -#define handle_error(msg) \ - do { perror(msg); exit(EXIT_FAILURE);} while(0) -#define LISTEN_BACKLOG 5 -int main(int argc, char*argv[]) -{ - int socket_fd, rc; - if(argc<1){ - handle_error(":"); - } - //Retrieve the protocol number mapping - //from /etc/protocols file - struct protoent *proto_entry; - proto_entry = getprotobyname("tcp"); - - //Open an socket end-point for this TCP Server - socket_fd = socket(AF_INET, SOCK_STREAM, proto_entry->p_proto); - if(socket_fd == -1){ - handle_error("Errno: %d,Socket descriptor creation failed", errorno); - } - - //My address information to bind to - struct sockaddr sock_addr; - memset(&sock_addr, 0, sizeof(struct sockaddr)); - sock_addr.sa_family = AF_INET; - sock_addr.sin_addr.s_addr = htonl(INADDR_ANY); - sock_addr.sin_port = htons(8000); - - - rc = bind(sock_fd, &sock_addr, sizeof(sock_addr)); - if(rc == -1){ - handle_error("Errno: %d, Bind failure", errorno); - } - rc = listen(socket_fd, LISTEN_BACKLOG); - if(rc == -1){ - handle_error("Errno: %d, Listen Error", errorno); - } - - int addr_size = sizeof(struct sockaddr); - rc= accept(sock_fd, &sock_addr, &addr_size); - if( rc == -1){ - handle_error("Error: %d,Accept failed", errorno); - } - diff --git a/osproject_task.c b/osproject_task.c index 64432f5..5b68269 100644 --- a/osproject_task.c +++ b/osproject_task.c @@ -7,13 +7,12 @@ int main() unsigned int a, b; unsigned int avg; int status; - asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (regr)); + readCCNT(regr); printf("regr: %x\n", regr); - - asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (a)); + getTime(a); int pid = fork(); if (pid) { - asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (b)); + getTime(b); printf("Time for fork: %u\n", b - a); } diff --git a/rasperf.h b/rasperf.h index e0e76b4..8a57704 100644 --- a/rasperf.h +++ b/rasperf.h @@ -1,7 +1,12 @@ + #ifndef __RASPERF_H__ +#define NULL '\0' #define __RASPERF_H__ -#define PI 1 -#define x86 0 +#define RTT 35 //in MicroSec +#define PI 0 +#define x86 1 +#define CPU_CYCLES 900 +#define MHz 1e6 #if defined(PI) && PI #define time unsigned int #define getTime(var) \ @@ -12,13 +17,14 @@ asm volatile (\ "mrc p15, 0, %0, c9, c14, 0":\ "=r" (var)); -#define diff(end, begin) (end - begin) +#define diff(end, begin) \ + (end - begin)/ CPU_CYCLES}; #endif #if defined(x86) && x86 #define time struct timeval #define getTime(var) gettimeofday(&var, NULL) #define diff(end, begin) \ - (end.tv_sec*1e6+end.tv_usec - begin.tv_sec*1e6+ begin.tv_usec) + ((end.tv_sec*1e6+end.tv_usec) - (begin.tv_sec*1e6+ begin.tv_usec)) #endif #endif -- 1.9.1