Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Optimizing TCP packet usage with IO::Socket::INET or similarby Bloehdian (Beadle) |
on Oct 06, 2016 at 12:55 UTC ( [id://1173403]=perlquestion: print w/replies, xml ) | Need Help?? |
Bloehdian has asked for the wisdom of the Perl Monks concerning the following question: Hello Monks, this is a design/problem approach question, therefor no code up to now: I want to setup a client-server scenario with IO::Socket::INET (or a similar module) to transfer (textual) data to a remote tcp-port using send() method. The data to be sent is received continuously line by line from a different TCP-port and it should be sent continuously to the target socket as well. To make transfer as efficient as possible in terms of overhead/payload ratio it is necessary to stuff as much data into tcp packets as possible, having at least padding as possible. I.e., if MTU is 1500 and assuming TCP-overhead to be 64 bytes, the payload in each packet should be 1436 bytes for each packet (ideally). Will my original idea $socket->send( $data );with $data comprising exactly 1436 bytes work or am I wrong assuming that each send() will put $data into no more than one tcp-packet? And: as stated, the data to be transmitted comes in line by line as a contiuous stream. It is expected that each line has significantly less bytes than the MTU, but this is not guaranteed. Accumulating enough data lines to fill a tcp-packet and chopping the last line if it would exceed the maximum payload is not that straightforward. Therefor: Is there a way to do this automatically/implicitly (using a Perl module)? Related: I am thinking about further optimization of the data transfer in terms of low bandwith usage by deploying Net::EasyTCP with compression. Am I right with the assumption that the receiving application on the remote side has to apply the same compression modules, e.g., Compress::Zlib, to uncompress the data or is this somewhere done by the TCP-client? Cheers Bloehdian
Back to
Seekers of Perl Wisdom
|
|