java - Why is the throughput of a network so slow? -


i made 2 threads communicating in simple client-server fashion. here's code sender:

    //open , configure socket        socketchannel channel = socketchannel.open();     inetsocketaddress address = new inetsocketaddress("localhost", 5050);     channel.connect(address);     channel.socket().settcpnodelay(true);     channel.socket().setkeepalive(false);     int count = 0;     outputstream os = channel.socket().getoutputstream();     int amount = 50;      //prepare simple buffer send.     byte[] data = new byte[amount];     arrays.fill(data, (byte)1);      double start = system.currenttimemillis(); //time it.      //send , print throughput each 50000 tuples.     while(true){         count++;         ioutils.write(data, os);         if(count % 50000==0){             double totalsize = count;             double end = system.currenttimemillis();             double time = (end-start)/1000;             system.out.println("writer:"+(totalsize/time)/1000000+"tuples/second");         }     } 

and receiver:

    .....//just accepting channel.      //after accepting channel. read tuples.      readc.socket().settcpnodelay(true);     readc.socket().setkeepalive(false);     byte[] readbuf = new byte[50];     inputstream = readc.socket().getinputstream();     double start = system.currenttimemillis();     while(true){         ioutils.read(is, readbuf);     } 

the output says average tuples per second 0.1 x 10^6, means each tuple = 50 bytes, 5mb/s throughput.

both threads run on local computer, assume ideal throughput far more larger got.

i check wireshark reason, , found, when send 1 tuple, let's say, port 71581 port 5050. there bunch of tcp packets sent, 300 packets!!!!! and, among 300 packets, 1 packet sending data between 71581 5050.

for other 299 packets, weird thing communications between port 71581 , 71580 (neighbor port). body explain why doing such stupid thing? can disable it?

any suggestions, comments, , ideas appreciated!!!!!!!!!!! thank you!


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -