1 台带有两个网卡的 Linux PC 无法为测试系统产生网络流量
这些问题涉及网络基础知识,但我还没有找到答案!
问题 1: 100Mbps 交换机可以同时处理 2 个以 100Mbps 运行的 TCP 流吗?为了说明这一点,如果您在 1 个交换机上有 4 台 PC(100Mbps,没有其他连接)并且您有两个独立的流,它们会达到什么速度?一个流是否会影响其他流的速度,或者交换机内部的速度是否足以处理许多流?
问题 2: 我在专用网络交换机上设置了 1 台 PC(Linux),该 PC 有 2 个网络接口卡(NIC)。两个网卡都有不同的 IP 地址,并且工作正常。如果我从一个网卡向另一网卡发送任何数据,网络交换机上绝对不会发送任何流量。看来内核是智能的,并且发现不需要在网络上发送任何内容,因为 IP 位于同一台 PC 上。我该如何关闭此功能?
由于我无法访问 4 台 PC,因此无法在现实世界中测试问题 1。这些都是非常简单的问题,但同时又很难回答。
谢谢!
These questions relate to the basics of networking, but I have not found an answer yet!
Question 1:
Can a 100Mbps switch handle 2 simultaneous TCP streams running at 100Mbps? To illustrate this if you have 4 PC's on 1 switch (100Mbps with no other connections) and you had two separate streams, what speed would they reach? Would one stream impact on the others speed, or is a switch fast enough internally to deal with many streams?
Question 2:
I have set up 1 PC (Linux) on a dedicated network switch, the PC has 2 Network Interface Cards (NIC). Both NIC's have different IP address' and work fine. If I send any data from one NIC to the other absolutely no traffic is send on the network switch. It seams that the kernel is intelligent and works out there's no need to send anything on the network as the IP's are on the same PC. How do I turn this off?
As I don't have access to 4 PC's I cannot test question 1 in the real world. These are very simple questions, but at the same time very difficult to answer.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题 1:是的,任何 100Mb/s 交换机都应该能够处理两个独立的 100Mb/s 流,因为每个端口都是 100Mb/s,而不是交换机本身。除非绝对需要,否则流量不会到达 CPU,此时交换机可能会出现瓶颈并减慢速度。不过正常交通应该没问题。
问题2:需要自己写一个程序手动完成,或者网上找一个。我建议查看 Libnet。
问题是内核知道它拥有这两张卡,因此它实际上并不需要在网络上发送数据。使用 Libnet,您可以手动构造数据包并将其从特定接口发送出去。
不过,主要的技巧是您需要在两个方向上发送流量(不多;您不应该需要每分钟在一个方向上发送超过 1 个数据包,而其他所有数据都在另一个方向上发送)。问题是交换机不知道数据包应该去哪里,并将它们淹没到所有端口,从而减慢一切。
Question 1: Yes, any 100Mb/s switch should be able to handle two independent 100Mb/s streams, as each port is 100Mb/s and not the switch itself. Traffic does not hit the CPU unless it absolutely needs to, at which point the switch may bottleneck and slow down. Normal traffic should be fine, though.
Question 2: You need to write a program to do it manually, or find one online. I recommend looking at Libnet.
The problem is that the kernel knows that it owns both of those cards, so it doesn't bother actually sending the data out on the network. Using Libnet, you can manually construct packets and send them out of a specific interface.
The main trick, though, is that you need to send traffic in both directions (not much; you shouldn't need more than 1 packet a minute going in one direction, with everything else going in the other direction). The problem is that the switch will not know where the packets are supposed to go and will flood them to all ports, slowing everything down.
问题 1 的答案取决于交换机的背板带宽 - 这是它可以在内部处理的总流量速率。如果它具有至少 200Mbps 的背板带宽,则可以支持两个独立的 100Mbps 流。
与更昂贵的“大铁”交换机相比,更便宜的交换机往往具有更少的背板带宽。
至于问题 2,您可以尝试将手动路由添加到您自己的 IP 地址,明确指定外部设备(如果您检查
route -C
,您将看到路由缓存具有通过您自己的 IP 地址的环回设备)。The answer to question 1 depends upon the backplane bandwidth of the switch - this is the total rate of traffic it can handle internally. If it has at least 200Mbps of backplane bandwidth, it can sustain two independent 100Mbps streams.
Cheaper switches tend to have less backplane bandwidth than more expensive "big iron" switches.
As for question 2, you could try and add manual routes to your own IP addresses, explicitly specifying the external devices (if you check
route -C
, you'll see that the routing cache has routes via the loopback device for your own IP addresses).