【问题标题】:Use iperf and ping at the same time mininet同时使用iperf和ping mininet
【发布时间】:2020-09-15 18:23:21
【问题描述】:

我刚刚开始了计算机网络课程,我的第一个作业为我提供了一个简单星形拓扑的 mininet 脚本,并要求我在 h1 和 h2 之间运行 iperf 测量。在 iperf 运行时,我应该测试 h3 和 h4 之间的 ping。

我的问题是如何让 iperf 测量数据以在后台运行以便我可以测试 ping,因为当 iperf 运行时我无法输入也无法为 mininet 打开新终端。

【问题讨论】:

    标签: linux networking network-programming mininet


    【解决方案1】:

    你有两个选择:

    1 - 使用 python API

    2 - 从 CLI 运行并行进程

    我将解释第二个选项,因为您正在使用 CLI 进行实验。

    第一步:使用单(星形)拓扑运行 Mininet。

    giuseppe@raspberrypi:~ $ sudo mn --topo single,4
    *** Creating network
    *** Adding controller
    *** Adding hosts:
    h1 h2 h3 h4
    *** Adding switches:
    s1
    *** Adding links:
    (h1, s1) (h2, s1) (h3, s1) (h4, s1)
    *** Configuring hosts
    h1 h2 h3 h4
    *** Starting controller
    c0
    *** Starting 1 switches
    s1 ...
    *** Starting CLI:
    mininet>
    

    如果你想从h1->h2做一个iperf,你需要h2的IP,你可以用ifconfig找到它

    mininet> h2 ifconfig
    h2-eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 10.0.0.2  netmask 255.0.0.0  broadcast 10.255.255.255
            inet6 fe80::b87a:eaff:fec1:64a0  prefixlen 64  scopeid 0x20<link>
            ether ba:7a:ea:c1:64:a0  txqueuelen 1000  (Ethernet)
            RX packets 98  bytes 14845 (14.4 KiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 11  bytes 866 (866.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
            inet 127.0.0.1  netmask 255.0.0.0
            inet6 ::1  prefixlen 128  scopeid 0x10<host>
            loop  txqueuelen 1000  (Local Loopback)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    

    在h2中启动服务器并将stdout end stderr记录在h2.log文件中

    mininet> h2 iperf -s &> h2.log &
    

    将iperf客户端从h1运行到h2(ip=10.0.0.2)并将输出保存在h1.log文件中(本例中我运行120秒,但你可以调整)

    mininet> h1 iperf -t 120 -c 10.0.0.2 &> h1.log &
    

    现在您可以运行 ping,而 iperf 在后台执行

    mininet> h3 ping h4
    

    您可以在打开另一个shell或完成实验后查看日志

    mininet> h3 ping h4
    PING 10.0.0.4 (10.0.0.4) 56(84) bytes of data.
    64 bytes from 10.0.0.4: icmp_seq=1 ttl=64 time=30.7 ms
    64 bytes from 10.0.0.4: icmp_seq=2 ttl=64 time=1.84 ms
    64 bytes from 10.0.0.4: icmp_seq=3 ttl=64 time=0.393 ms
    64 bytes from 10.0.0.4: icmp_seq=4 ttl=64 time=0.387 ms
    ^C
    --- 10.0.0.4 ping statistics ---
    4 packets transmitted, 4 received, 0% packet loss, time 73ms
    rtt min/avg/max/mdev = 0.387/8.327/30.692/12.925 ms
    mininet> exit
    *** Stopping 1 controllers
    c0
    *** Stopping 4 links
    ....
    *** Stopping 1 switches
    s1
    *** Stopping 4 hosts
    h1 h2 h3 h4
    *** Done
    completed in 473.135 seconds
    giuseppe@raspberrypi:~ $
    giuseppe@raspberrypi:~ $ ls
    h1.log  h2.log
    

    【讨论】:

    • 非常感谢!
    • 当我尝试在 mininet RYU sdn 中的两台主机之间使用 UDP iperf 时。控制器收到多个数据包输入消息?为什么会这样?
    【解决方案2】:

    你可以使用 xterm:

    xterm h1 h2 h3 h4

    您将为每个节点获得四个 xterm 终端。然后,您可以在 h1 和 h2 之间运行 iperf,并在 h3 和 h4 之间运行 ping。

    在 h1 上,运行: iperf -s &amp;

    在 h2 上,运行: iperf -s 10.0.0.1 -i 10 -t 60 连接h1。

    在 h3 上,运行:ping 10.0.0.4 -c 10 以 ping h4, 或者在 h4 上,运行 ping 10.0.0.3 -c 10 来 ping h3。

    Here is an example

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-21
      • 1970-01-01
      • 1970-01-01
      • 2014-08-26
      • 2016-04-22
      • 1970-01-01
      • 2016-09-05
      相关资源
      最近更新 更多