模拟多个IP地址进行测试
我需要模拟多个通常用于电机控制的嵌入式服务器设备。在现实生活中,网络上可能有多个服务器,我们的桌面软件同时充当所有电机服务器的客户端。我们手头有六台这样的电机控制服务器用于基本测试,但使用真实硬件测试更大的系统变得越来越昂贵。我想构建一个模拟器,它看起来像网络上的许多服务器来测试我们的客户端软件。
如何构建一个模拟器,使其看起来在同一端口上有许多 IP 地址,而实际上却没有许多 NIC。例如,客户端软件将尝试在端口 1111 上连接到服务器 192.168.10.1 到 192.168.10.50。模拟器将接受所有这些连接并运行模拟,就好像它正在移动物理电机一样,并在这些套接字连接上发回模拟数据。
我可以使用路由器将所有这些地址映射到单个测试服务器,或者理想情况下,有没有办法使用 localhost 来“欺骗”这些 IP 地址?客户端软件是用.Net编写的,但Python的想法也将受到欢迎。
I need to simulate multiple embedded server devices that are typically used for motor control. In real life, there can be multiple servers on the network and our desktop software acts as a client to all the motor servers simultaneously. We have a half-dozen of these motor control servers on hand for basic testing, but it's getting expensive to test bigger systems with the real hardware. I'd like to build a simulator that can look like many servers on the network to test our client software.
How can I build a simulator that will look like it has many IP addresses on the same port without physically having many NIC's. For example, the client software will try to connect to servers 192.168.10.1 thru 192.168.10.50 on port 1111. The simulator will accept all of those connections and run simulations as if it were moving physical motors and send back simulated data on those socket connections.
Can I use a router to map all of those addresses to a single testing server, or ideally, is there a way to use localhost to 'spoof' those IP addresses? The client software is written in .Net, but Python ideas would be welcomed as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
A. 考虑使用 Bonjour (zeroconf) 进行服务发现
B. 您可以为同一 NIC 分配 1 个或多个 IP 地址:
在 XP 上,开始 ->控制面板->网络连接并选择 NIC 上的属性(通常为“本地连接”)。
向下滚动到 Internet 协议 (TCP/IP),选择它并单击 [属性]。
如果您使用 DHCP,则需要从 IT 部门获取静态基本 IP。
否则,单击 [高级],然后在“IP 地址”下单击 [添加..]
输入您要添加的附加 IP 的 IP 信息。
对每个其他 IP 地址重复此操作。
C. 考虑使用 VMWare,因为您可以在单个逻辑“计算机”网络中配置多个系统和虚拟 IP。
——天空
A. consider using Bonjour (zeroconf) for service discovery
B. You can assign 1 or more IP addresses the same NIC:
On XP, Start -> Control Panel -> Network Connections and select properties on your NIC (usually 'Local Area Connection').
Scroll down to Internet Protocol (TCP/IP), select it and click on [Properties].
If you are using DHCP, you will need to get a static, base IP, from your IT.
Otherwise, click on [Advanced] and under 'IP Addresses' click [Add..]
Enter the IP information for the additional IP you want to add.
Repeat for each additional IP address.
C. Consider using VMWare, as you can configure multiple systems and virtual IPs within a single, logical, network of "computers".
-- sky
您应该设置一个虚拟网络适配器。它们称为 TAP/TUN 设备。如果您使用的是 Windows,则可以轻松设置一些虚拟地址,如下所示:
http ://www.ntkernel.com/w&p.php?id=32
祝你好运!
You should set up a virtual network adapter. They are called TAP/TUN devices. If you are using windows, you can easily setup some dummy addresses with somthing like this:
http://www.ntkernel.com/w&p.php?id=32
Good luck!
通常您只需在 0.0.0.0 上收听即可。这是所有 IP 地址的别名。
Normally you just listen on 0.0.0.0. This is an alias for all IP addresses.
您可以以管理员身份使用以下命令将别名 IP 地址添加到单个网络接口。为您需要的每个 IP 地址运行一次。该命令假定您的网络接口名为“Ethernet 1”,因此请根据需要进行调整:
通过将
add
更改为delete
来删除 IP 地址。使用命令显示 IP 地址:
您也可以通过 GUI 执行相同的操作:
网络连接
属性
Internet协议版本 4 (TCP/IPv4)
高级
IP 地址
部分中的添加
以添加 IP 地址You can add alias IP addresses to a single network interface using the following command as admin. Run once for every IP address you need. The command assumes your network interface is named "Ethernet 1", so adjust as necessary:
Remove an IP address by changing
add
todelete
.Show IP addresses with the command:
You can do the same things through the GUI as well:
Network Connections
Properties
Internet Protocol Version 4 (TCP/IPv4)
Advanced
Add
in theIP addresses
section to add IP addresses