aboutsummaryrefslogtreecommitdiffstats
path: root/resources/traffic_scripts
diff options
context:
space:
mode:
authorStefan Kobza <skobza@cisco.com>2016-02-10 19:41:09 +0100
committerGerrit Code Review <gerrit@fd.io>2016-02-17 16:29:03 +0000
commit8f285166faf13156a4f7c70adac9a7e20549268f (patch)
tree29a4adb583dcf7feaba301fccedeaaef5d572674 /resources/traffic_scripts
parentda15035461569ea175aabbac1df735cd5598b0b3 (diff)
Test VIRL connection.
Change-Id: I812ff9c8c9669b63907469c643c839e8bd3b419a Signed-off-by: Stefan Kobza <skobza@cisco.com>
Diffstat (limited to 'resources/traffic_scripts')
-rwxr-xr-xresources/traffic_scripts/ipv4_ping_ttl_check.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/resources/traffic_scripts/ipv4_ping_ttl_check.py b/resources/traffic_scripts/ipv4_ping_ttl_check.py
index 2fd9d552ea..54b6aa1ef5 100755
--- a/resources/traffic_scripts/ipv4_ping_ttl_check.py
+++ b/resources/traffic_scripts/ipv4_ping_ttl_check.py
@@ -30,8 +30,8 @@ def check_ttl(ttl_begin, ttl_end, ttl_diff):
def ckeck_packets_equal(pkt_send, pkt_recv):
- pkt_send_raw = str(pkt_send)
- pkt_recv_raw = str(pkt_recv)
+ pkt_send_raw = auto_pad(pkt_send)
+ pkt_recv_raw = auto_pad(pkt_recv)
if pkt_send_raw != pkt_recv_raw:
print "Sent: {}".format(pkt_send_raw.encode('hex'))
print "Received: {}".format(pkt_recv_raw.encode('hex'))
@@ -63,20 +63,21 @@ if dst_if_defined and (src_if_name == dst_if_name):
raise Exception("Source interface name equals destination interface name")
src_if = Interface(src_if_name)
-src_if.send_pkt(create_gratuitous_arp_request(src_mac, src_ip))
+src_if.send_pkt(str(create_gratuitous_arp_request(src_mac, src_ip)))
if dst_if_defined:
dst_if = Interface(dst_if_name)
- dst_if.send_pkt(create_gratuitous_arp_request(dst_mac, dst_ip))
+ dst_if.send_pkt(str(create_gratuitous_arp_request(dst_mac, dst_ip)))
-pkt_req_send = auto_pad(Ether(src=src_mac, dst=first_hop_mac) /
- IP(src=src_ip, dst=dst_ip) /
- ICMP())
-pkt_req_send = Ether(pkt_req_send)
+pkt_req_send = (Ether(src=src_mac, dst=first_hop_mac) /
+ IP(src=src_ip, dst=dst_ip) /
+ ICMP())
src_if.send_pkt(pkt_req_send)
if dst_if_defined:
try:
pkt_req_recv = dst_if.recv_pkt()
+ if pkt_req_recv is None:
+ raise Exception('Timeout waiting for packet')
except:
src_if.close()
if dst_if_defined:
@@ -89,14 +90,15 @@ if dst_if_defined:
del pkt_req_send_mod[IP].chksum # update checksum
ckeck_packets_equal(pkt_req_send_mod[IP], pkt_req_recv[IP])
- pkt_resp_send = auto_pad(Ether(src=dst_mac, dst=pkt_req_recv.src) /
- IP(src=dst_ip, dst=src_ip) /
- ICMP(type=0)) # echo-reply
- pkt_resp_send = Ether(pkt_resp_send)
+ pkt_resp_send = (Ether(src=dst_mac, dst=pkt_req_recv.src) /
+ IP(src=dst_ip, dst=src_ip) /
+ ICMP(type=0)) # echo-reply
dst_if.send_pkt(pkt_resp_send)
try:
pkt_resp_recv = src_if.recv_pkt()
+ if pkt_resp_recv is None:
+ raise Exception('Timeout waiting for packet')
except:
src_if.close()
if dst_if_defined: