网络模拟器
我需要构建一个可以通过真实 IP 地址进行通信的设备模拟器,
我需要为设备创建尽可能多的实例。每个模拟器实例都有一个 IP 和 MAC 地址
任何人都可以指导我如何实现这一目标吗?
I need to build a device emulator which can communicate over real IP address
I need to create as many instances I can for the device. With one IP and MAC address for each emulator instance
Can can any one guide me how this can be achieved?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
五六年前,我一直在为 PS2 游戏编写网络模拟层。我被告知必须显示互联网连接的所有经典行为;真实的丢失特性、数据包重新排序、延迟、匆忙引起的数据包丢失。基本上,我被告知要在几周内实现互联网。
我建议将所有游戏流量从远程回显服务器上退回。当我被告知绝对禁止通过公共线路发送开发流量时,我只是创建了一个服务器,每个人都将他们的 PS2 开发套件指向该服务器,该服务器将存储它收到的每个数据包并发送一个 doppleganger(充满原始数据包的 id)加上一堆随机垃圾以使其大小相同)发送到我运行的回显服务器。当收到分身时,我会将原始数据包传递到其原始目的地。
繁荣。网上模拟一切荆棘,不到8小时。
更新:
鉴于此处答案的成功,我不久前重新实现了游戏回声服务。看来 github 可能是一个更好的地方来存放它,所以在这里:如果它适用于你,太好了!如果没有,请告诉我。我预计它目前的状态充其量也只是不稳定。
Five or six years ago, I was stuck writing a network emulation layer for a PS2 game. I was told that all the classic behaviors of an internet connection had to be displayed; realistic loss characteristics, packet reordering, latency, rush-induced packet loss. Essentially, I was told to implement the internet in a couple weeks.
I suggested just bouncing all our game traffic off a remote echo server. When I was told that it was absolutely forbidden to send development traffic out over public wires, I simply created a server that everyone pointed their PS2 devkits at that would store every packet it received and send a doppleganger (full of an id for the original packet plus a bunch of random garbage to make it the same size) out to the echo servers I ran. When the doppleganger was received, I would pass the original packet on to its original destination.
Boom. Internet simulation with all the thorns in less than 8 hours.
UPDATE:
Given the success of the answer here, I reimplemented the game echo service a while back. It seemed that github might be a better place to stash it, so here it is: If it works for you, great! If not, let me know. I expect its current state to be shaky at best.
Virtual PC 2007
http:// /www.microsoft.com/downloads/details.aspx?FamilyID=04d26402-3199-48a3-afa2-2dc0b40a73b6&DisplayLang=en
。
虚拟机网络驱动程序
http: //www.microsoft.com/downloads/details.aspx?FamilyID=dc8332d6-565f-4a57-be8c-1d4718d3af65&displaylang=en
。
VMware Player:Windows
http://www.vmware.com/products/player/
Virtual PC 2007
http://www.microsoft.com/downloads/details.aspx?FamilyID=04d26402-3199-48a3-afa2-2dc0b40a73b6&DisplayLang=en
.
Virtual Machine Network Driver
http://www.microsoft.com/downloads/details.aspx?FamilyID=dc8332d6-565f-4a57-be8c-1d4718d3af65&displaylang=en
.
VMware Player: Windows
http://www.vmware.com/products/player/
添加Windows 中的虚拟 IP 范围
请参阅 gil.elessar 于 2006 年 2 月 21 日下午 1:18 发表的回复
。
供您参考:
接口 IP 的 Netsh 命令
Netsh 命令< /a>
您可以在 Netsh Interface IP 上下文中使用命令来配置 TCP/IP 协议(包括地址、默认网关、DNS 服务器和 WINS 服务器)并显示配置和统计信息。
Add a Range of Virtual IPs in Windows
See the February 21st, 2006, 1:18 pm post reply by gil.elessar
.
For your reference:
Netsh commands for Interface IP
Netsh commands
You can use commands in the Netsh Interface IP context to configure the TCP/IP protocol (including addresses, default gateways, DNS servers, and WINS servers) and to display configuration and statistical information.
一个简单的想法是使用 用户模式 Linux (UML), Linux 内核位于用户空间。它允许多个虚拟 Linux 系统(称为来宾)作为普通 Linux 系统(称为主机)中的应用程序运行。
它的CPU和内存都很轻。例如,我在一台“不太新”的 PC 上同时使用超过 10 个 UML,使用 Netkit,一个基于UML的网络模拟器。 UML 很轻,因为它是本机应用程序,而不是重型虚拟化(vmware、virtualbox、qemu),也不是半虚拟化(xen)。
由于网络接口被实现为能够连接到其他 UML 机器(使用 uml_switch),因此您可以拥有任何您想要的 MAC 地址。如果您需要将这些 UML 机器连接到您的系统或外部主机,您可以使用 TUN/TAP 创建虚拟设备。
PS:如果您使用的是 Windows,您可以尝试 CoLinix,M$ OS 的 Linux 内核端口,我不知道它是否具有与UML相同的特性。
A simple idea woul be to used User-Mode Linux (UML), a port of the Linux kernel in user space. It allows multiple virtual Linux systems (known as guests) to run as an application within a normal Linux system (known as the host).
It very light, in CPU and memory. For instance I'm using more than 10 UML in the same time on a "not-too-recent" PC, using Netkit, a network simulator based on UML. UML is light because it's a native application, not heavy virtualisation (vmware, virtualbox, qemu) neither para-virtualisation (xen).
As the network interfaces are implemented to be able to connect to other UML machines (using uml_switch), you can have any MAC address you want. If you need to connect these UML machines to your system or external hosts, you can create virtual devices using TUN/TAP.
PS: If you're on Windows, you can try CoLinix, port of Linux Kernel for M$ OS, I don't know if it has same characteristics than UML.
您可以尝试使用环回适配器。使用它您可以设置任何 IP 或 MAC 地址。非常适合模拟各种网络连接。
You could try using loopback adapters. Using this you can set any IP or mac address. Works great for emulating various network connections.
你需要在编码部分深入研究数据链路层——然后你才能理解它如何获取mac地址以及mac和ip的黑白通信
you need to study the datalink layer in depth in the part of coding -- then you can understand the how it get mac address and the communication b/w mac and ip
根据您需要的设备类型,您可能会对多个虚拟 PC 引擎感到满意,但开销很高(模拟整个 PC 而不仅仅是网络接口),因此您最终不会拥有 1000 台机器,但这是一个“开箱即用”的解决方案 - 每台虚拟 PC 都可以有多个虚拟网卡。
depending on what kind of device you need, you may be happy with a number of virtual PC engines, the overhead is high (whole PC is emulated instead of just a network interface) so you won't end up with 1000 machines, but this is an "out of the box" solution - and each virtual PC can have a number of virtual network cards.
我建议你最好不要开始重新发明轮子。对于这个特定问题,有硬件和软件解决方案。它们也非常适合网络负载(和吞吐量)测试。
缺点是此类设备相当昂贵。
I suggest you better not start reinventing the wheel. There are hardware as well as software solutions for this particular problem. They are also very well suited to network load (and throughput)-tests.
The downside is such devises are quite expensive.
Cisco pakcet Tracer 允许您使用 GUI 模拟网络流量。我很惊讶没有人提到这一点(它仅限于思科设备,但跨设备的标准是相同的,因此它将学习您的特定设备的命令)。
尝试做一个谷歌搜索,因为在正常情况下它只适用于 ccna 学生,但我保留了一份副本,因为我的老师允许我。
或者您可能会发现有人在互联网上的某个地方发布了他们班级的副本。
Cisco pakcet tracer allows you to emulate network traffic with an gui. Im surpised no one mentioned that (its limited to cisco devices but the standard is same across devices so it would be learning commands for your specific device).
Try doing a google search because under normal circumstances its only available to ccna students but I kept a copy because my teacher let me.
Or you might find someone posted a copy from their class somewhere on the internet.