开发者

simulate different PC with different IP addresses in linux environment

im new to linux environment and any help/feedback would be appreciated. Im actually trying to develop a client-server (MULTICAST) program, so, i would like to test one client sending information to different servers (one-to-many relationship). thus, i would like to simulate different server side in linux开发者_JAVA技巧 with different IP addresses in one computer.


Did you try using different ports instead? I didn't try it myself, but perhaps that can help you in the mid-time.


If you're really multicasting, you don't need to worry about physical host-specific IP:s, all you should need to do is make sure all the programs (clients and servers) are using the same multicast group addresses. Then they should all see each other's traffic automatically.

There's nothing stopping you from running multiple clients on the same machine that also runs the server, in this case.


I sounds like you want to test your code with different IP's. You can create IP aliases on your interface and simulate multiple IP's on one computer.

for e.g. if eth0 is you're active interface with IP, say 192.168.5.11 you can assign another IP to eth0:0 (an alias to eth0) as below.

ifconfig eth0:0 192.168.5.12 netmask255.255.255.0 up

ifconfig eth0:1 192.168.5.13 netmask255.255.255.0 up

run your server on one of the IP's and distribute clients to all your aliases


Use either of the following when you do not have sufficient hardware:

  1. Multicast loop which has the IP stack redirect outbound packets to local receivers.
  2. Virtual machines.

Be aware that semantics of the socket option for #1 change depending on the operating system; for #2 only some virtual machines support multicast, refer to the vendor for details.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms739161(v=vs.85).aspx

Ultimately though you must test with different machines due to specific artifacts of how hosts manage multicast groups. You can for instance create send-only membership which will block every other application on the host. Also consider that an internet, lower case 'I', will introduce further artifacts regarding group joining and propagation delays and drops that your application may need to be aware of.


You can create multiple IP for same machine with help of IP alias. As mentioned above. But to create multiple Server at one PC you must need different port for each server if you want to simulate the all server behavior with network as well.

I mean for one port multicast traffic always goes to that and some process in the PC will be receiving the packet and has to serve for all server in the PC, Means you have one packet only and all server is receiving with locally manipulation.

But really simulation would be you have multiple server at 1 PC and all are receiving multicast traffic from network rather then from local process.

my Solution: You keep number for server == number of port at the PC. Client send the multicast traffic over all port simultaneously and all server at the PC end will be receiving multicast packet from corresponding port from the Network.

Please correct me if my understanding is wrong.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜