views:

267

answers:

2

Hi

I have a TCP connection opened between Symbian and a Server machine and I would like to transfer huge chunks of data (around 32K) between these two endpoints. Unfortuantely, the performance figures are pretty poor and I am looking for ideas how I could improve my implementation. One of the things I tried was to increase the number of bytes that can be buffered by the socket for sending & receiving to 64K.

iSocket.SetOpt(KSoTcpSendWinSize, KSolInetTcp, 0x10000);     
iSocket.SetOpt(KSoTcpRecvWinSize, KSolInetTcp, 0x10000);

Are there any other things that could be optimized at a socket level for better throughput?

It is also possible, that my socket code does something stupid. It follows a simple request/response protocol. I have to use the blocking WaitForRequest routine to be sure that the data has been send/received so that I can process it then.

//store requestinfo in reqbuf and send it to server; wait for iStatus
iSocket.Send( reqbuff, 0, iStatus, len );      
User::WaitForRequest(iStatus);

//store 32K file in resbuff; wait for iStatus to be sure that all data has
//been received
iSocket.Recv(resbuff, 0, iStatus, len);
User::WaitForRequest(iStatus);  
//do something with the 32K received

Would be thankful for every comment!

A: 

Are you positive that the

//do something with the 32K received

doesn't take particularily long? Your app appears to be single-threaded so if this is holding up the line, well thats an obvious bottleneck.

Also what do you mean by poor performance? Have you compared the performance to other tcp apps?

Lastly, if performance is a big issue you can switch over to raw sockets/datagram sockets, and optimize your own validation protocol for your specific data.

DeusAduro
Yes, I checked the network traffic with Wireshark: Here it takes 200ms between a request and a response from the server when accessing a file from Symbian. When doing the same operation on Windows (access to a remote file) it takes a few milliseconds
Well, its definitely not the TCP protocol that is slowing you down. Can you time the request/receive portions of the code? Is the server taking really long to respond to the request? Or is the actually data transfer (part2) taking overly long?
DeusAduro
wait .. is this on a symbian based phone via wireless? If its not by wireless then your performance is cellularlimited. If it IS by wireless then it may just be that the wireless controller is crap. The one in my HTC Windows mobile phone certainly is.
Goz
+1  A: 

You can send and receive in parallell if you use active objects. There should be example code in the SDK. Obviously it depends on the application and protocol used whether that will help.

I'm no TCP expert, but I think there are parameters on the socket that can cause your usage pattern (sending one large buffer, then receiveing a large buffer) to not use the network optimally compared to when sending approximately equal amounts of data in both directions. All things about TCP sockets that can be configured in other OS:se should be possible to configure on Symbian as well, but first you need to figure out what. I suggest you ask another question that is TCP general and get some pointers. Then you can figure out how to set that up in Symbian.

Ola
Yes, blocking with `User::WaitForRequest()` is often a bad idea when you could use active objects. Also, `RecvOneOrMore()` instead of `Recv()` would enable the reading part to work in smaller pieces and schedule the active objects better.
laalto
The problem is, that I need to send the data as a request, then wait for the response to receive over the network and when I have received all the bytes I can finally process the data. So this is sequential, can not really do anything with active objects!