pnet benchmarking
이전 댓글 표시
Hello everyone,
I am trying to benchmark pnet toolbox for sending and receiving both tcp/udp messages between the machines. My goal is to measure the throughput and latency for different pay-load sizes.
I wanted some advice on getting the basic loop of the script running. I wrote the following code for the listener:
sPort = '1234';
if ((sPort > 1024))
tcpCon = pnet('tcpsocket', sPort); % only create this socket once
else
tcpCon = -1;
end
serv = pnet(tcpCon,'tcplisten');
try
pnet(tcpCon, 'close');
catch exception
retCode = 1;
end
But I get the error:
??? Error using ==> pnet
Invalid socket for LISTEN, Already open, or UDP?...
Error in ==> test_pnet at 24
serv = pnet(tcpCon,'tcplisten');
Can someone please guide me to what could be the problem. If anyone has a simple working sender/receiver script that I could develop on that would be great!
답변 (5개)
Ian
2011년 4월 3일
Hi, perhaps you have another application that has opened that port? Try a higher port number (9876 for example), or check if that port is open (sudo lsof -i TCP -P in os x/linux, use sysinternals tcpview in windows).
I use pnet for both UDP and TCP communication, wrapping them in an oop object. My ghetto code needs refactoring, but here it is warts and all: https://gist.github.com/899981
To open a server:
sconn=dataConnection(struct('lPort', 8765, 'protocol', 'tcp', 'autoOpen', 1, 'type', 'server'));
To open a client:
cconn=dataConnection(struct('rPort', 8765, 'rAddress', '127.0.0.1', 'protocol', 'tcp', 'autoOpen', 1));
Check connection:
sconn.checkClient; %server needs to check if a client has connected
sconn.write('Ping'); %write data to the connection
cconn.read % (ans='Ping')
See alse http://stackoverflow.com/questions/5104396/controling-a-matlab-script-pause-reset/5148504#5148504 for an example using UDP.
EDIT: as Walter points out, the port number needs to be a number for pnet not a string; the address should be a string.
Walter Roberson
2011년 4월 3일
Your code
sPort = '1234';
sets sPort to be a string. Then in the next line, you try to compare the string to an integer. The result is to compare each character of the string to the integer, and to find the "if" to be true only if all of the comparisons are true. None of the comparisons will be true, though, as '1' is only about value 48...
Priya Bhat
2011년 4월 8일
댓글 수: 4
Walter Roberson
2011년 4월 8일
Could you post the corresponding netperf results over the same machines?
I might have missed it, but at first glance I don't see where you have set buffer sizes? Buffer sizes can make large differences for TCP connections.
Priya Bhat
2011년 4월 8일
Walter Roberson
2011년 4월 8일
It appears the pnet you are using is what I know as tcpudpip, http://www.mathworks.com/matlabcentral/fileexchange/345-tcpudpip-toolbox-2-0-6
I haven't done any benchmarking of that.
Priya Bhat
2011년 4월 8일
Priya Bhat
2011년 4월 8일
Erik Flister
2011년 7월 11일
0 개 추천
you need to set your snd/rcv buff sizes, they are not tuned for fast small messages by default.
also turn off nagle's algorithm. http://blogs.msdn.com/b/windowsazurestorage/archive/2010/06/25/nagle-s-algorithm-is-not-friendly-towards-small-requests.aspx
카테고리
도움말 센터 및 File Exchange에서 TCP/IP Communication에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!