[clug] multiple network ports on one machine

Robert Edwards bob at cs.anu.edu.au
Mon Mar 30 11:27:40 GMT 2009

Adrian wrote:
> To do some testing I wish to send UDP packets out on one Ethernet
> interface, through a switch, and back in on another interface of a 4
> port machine.  What would be the basic server and client code to do this
> or point me to some basic docs.
> Adrian

Not really all that easy from the set-up point of view as the (Linux?)
IP routing code (UDP runs over IP) will detect that the outgoing
datagram is destined for an IP address on the same kernel instance
and so will route it directly internally instead of sending it out
on the physical link. You may be able to do it with virtual machines
etc. but then all the virtualisation overheads will hurt any
performance measurements etc.

Writing code to send/receive UDP datagrams is generally trivial. NetCat
(nc) can do it for you with no code involved, otherwise see Beej's
network programming guide for examples in C and elsewhere on the web
for examples in Java, Python, Perl etc.


Bob Edwards.

More information about the linux mailing list