pnet benchmarking
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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!
0 comentarios
Respuestas (5)
Ian
el 3 de Abr. de 2011
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.
0 comentarios
Walter Roberson
el 3 de Abr. de 2011
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...
0 comentarios
Priya Bhat
el 8 de Abr. de 2011
4 comentarios
Walter Roberson
el 8 de Abr. de 2011
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.
Erik Flister
el 11 de Jul. de 2011
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
0 comentarios
Ver también
Categorías
Más información sobre MATLAB Parallel Server en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!