views:

449

answers:

2

Hello,

I try to develop a file transfer application in Java, with an applet as client, and a standalone java app as server (on a dedicated machine hosted in a datacenter). I use DataOutputStream/DataInputStream to transfers the data on both sides. When I send big volumes of data, the bandwith is very variable : all is okay first, then the tcp stream is freezed during 40-50 seconds while nothing is transferring, and then it starts again.

When I look at the tcp stream with Ethereal, I see duplicate acks, fast retransmits, and tcp retransmits. But I don't think that the problem is originating from Java : I have the same problem with FTP transfers in FileZilla. But ... when I try to transfer data using netcat (netcat client + netcat server), all is fine, the bandwith is stable, the tcp lost packets seems to be retransmitted immediately without any pause, no matter of the volume transferred.

It's like if Java was not as talented as netcat to play with tcp streams ...

I tried to play with Socket.setSendBufferSize(), but I didn't see any difference. Any idea ?

Thanks ! And sorry for my bad english ...

A: 

Sounds more like your network is bogged down and you are seeing TCP windowing (I believe that's the correct term) basically limiting your bandwidth.

Gandalf
+1  A: 

Mr amischiefr is right ! It's the same problem that on the other thread. My problem was solved by replacing DataXXXputStream by BufferedXXXputstream. The write(byte[], off, len) methods are the same, and the doc doesn't talk about such different behavior. DataOutputStream is buffered, BufferedOutputStream too, but the second one does it much better. Thanks !

Olivier