2015-10-13 107 views
1

使用Mininet和OpenFlow開始上課。我想要做的是給ping數據包添加一些延遲。我有一個基本的Python腳本,將增加帶寬和延遲限制如下:瞭解ping延遲

self.addLink(host1, switch1, bw=10, delay='10ms') 
self.addLink(host2, switch1, bw=10, delay='10ms') 
self.addLink(host3, switch1, bw=10, delay='10ms') 

現在,什麼是困惑我的是,對每一個ping包的時候,似乎是對我來說有點不可思議。 沒有延遲我的包是這樣的:

mininet> h1 ping h2 
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data. 
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=1.22 ms 
64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=1.51 ms 
64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=1.53 ms 
64 bytes from 10.0.0.2: icmp_seq=4 ttl=64 time=1.27 ms 
64 bytes from 10.0.0.2: icmp_seq=5 ttl=64 time=1.25 ms 
64 bytes from 10.0.0.2: icmp_seq=6 ttl=64 time=0.760 ms 
64 bytes from 10.0.0.2: icmp_seq=7 ttl=64 time=1.04 ms 
^C 
--- 10.0.0.2 ping statistics --- 
7 packets transmitted, 7 received, 0% packet loss, time 6013ms 
rtt min/avg/max/mdev = 0.760/1.230/1.534/0.247 ms 

我期待延遲到「添加10ms的每個數據包」,但我得到下面的輸出,當我跑平與10ms的延遲:

mininet> h1 ping h2 
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data. 
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=85.1 ms 
64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=46.3 ms 
64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=43.5 ms 
64 bytes from 10.0.0.2: icmp_seq=4 ttl=64 time=43.9 ms 
64 bytes from 10.0.0.2: icmp_seq=5 ttl=64 time=42.3 ms 
64 bytes from 10.0.0.2: icmp_seq=6 ttl=64 time=43.1 ms 
64 bytes from 10.0.0.2: icmp_seq=7 ttl=64 time=45.0 ms 
64 bytes from 10.0.0.2: icmp_seq=8 ttl=64 time=43.2 ms 
64 bytes from 10.0.0.2: icmp_seq=9 ttl=64 time=45.5 ms 
64 bytes from 10.0.0.2: icmp_seq=10 ttl=64 time=44.5 ms 
64 bytes from 10.0.0.2: icmp_seq=11 ttl=64 time=43.3 ms 
^C 
--- 10.0.0.2 ping statistics --- 
11 packets transmitted, 11 received, 0% packet loss, time 10019ms 
rtt min/avg/max/mdev = 42.373/47.836/85.146/11.851 ms 

我不能看到包已經由「10毫秒」

是否有一個原因,我的包的時間有這麼大的價值明確延遲?是否因爲交換機和兩臺主機都在加入延遲時間,因此會增加時間?

回答

1

我說你做了什麼你是添加了10ms的延遲到每個主機,這樣既h1h2,因此做數學:10ms的傳遞從h1switch1,10ms的傳遞從switch1h2 ,響應時間爲10ms,從h2switch1,10ms從switch1h210+10+10+10=40。對我來說似乎合法。

0

在h1和h2之間有兩條鏈路,每條鏈路延遲10ms。所以它需要大約20ms的數據包在一個方向上傳輸。所以往返需要40ms左右。由於ping由一對數據包 - ICMP Echo Request(由源發送)和ICMP Echo reply(由目標發送)組成,因此從第二個ping開始,所有ping都會延遲約40ms。

第一次ping延遲較長的原因稍微有點棘手。對於一對主機在局域網中交換IP級別的消息(例如通過交換機),他們必須知道彼此的MAC地址。在第一個數據包之前,h1不知道h2的MAC,因此必須解析它。該解決方案由一對數據包組成 - 一個是由h1發送的ARP請求,另一個是由h2發送的ARP響應。這些消息也在局域網中傳播了40毫秒。只有收到響應後,才能發送第一個ICMP數據包。這就是你如何獲得80毫秒的延遲。