3 from scapy.layers.inet import IP, UDP, ICMP
4 from scapy.layers.inet6 import IPv6
5 from scapy.layers.l2 import Ether, GRE
6 from scapy.packet import Raw
8 from framework import VppTestCase
11 """ TestPing is a subclass of VPPTestCase classes.
13 Basic test for sanity check of the ping.
18 class TestPing(VppTestCase):
19 """ Ping Test Case """
23 super(TestPing, cls).setUpClass()
25 cls.create_pg_interfaces(range(2))
26 cls.interfaces = list(cls.pg_interfaces)
28 for i in cls.interfaces:
36 super(TestPing, cls).tearDownClass()
40 super(TestPing, self).tearDown()
42 self.vapi.cli("show hardware")
44 def test_ping_basic(self):
45 """ basic ping test """
47 self.pg_enable_capture(self.pg_interfaces)
49 self.logger.info(self.vapi.cli("show ip arp"))
50 self.logger.info(self.vapi.cli("show ip6 neighbors"))
52 remote_ip4 = self.pg1.remote_ip4
53 ping_cmd = "ping " + remote_ip4 + " interval 0.01 repeat 10"
54 ret = self.vapi.cli(ping_cmd)
56 out = self.pg1.get_capture(10)
61 self.assertEqual(ip.version, 4)
62 self.assertEqual(ip.flags, 0)
63 self.assertEqual(ip.src, self.pg1.local_ip4)
64 self.assertEqual(ip.dst, self.pg1.remote_ip4)
65 self.assertEqual(ip.proto, 1)
66 self.assertEqual(len(ip.options), 0)
67 self.assertGreaterEqual(ip.ttl, 254)
69 self.assertEqual(icmp.type, 8)
70 self.assertEqual(icmp.code, 0)
71 self.assertEqual(icmp.seq, icmp_seq)
72 icmp_seq = icmp_seq + 1
76 self.assertEqual(icmp.id, icmp_id)
78 self.vapi.cli("show error")
80 def test_ping_burst(self):
81 """ burst ping test """
83 self.pg_enable_capture(self.pg_interfaces)
85 self.logger.info(self.vapi.cli("show ip arp"))
86 self.logger.info(self.vapi.cli("show ip6 neighbors"))
88 remote_ip4 = self.pg1.remote_ip4
89 ping_cmd = "ping " + remote_ip4 + " interval 0.01 burst 3"
90 ret = self.vapi.cli(ping_cmd)
92 out = self.pg1.get_capture(3*5)
98 self.assertEqual(ip.version, 4)
99 self.assertEqual(ip.flags, 0)
100 self.assertEqual(ip.src, self.pg1.local_ip4)
101 self.assertEqual(ip.dst, self.pg1.remote_ip4)
102 self.assertEqual(ip.proto, 1)
103 self.assertEqual(len(ip.options), 0)
104 self.assertGreaterEqual(ip.ttl, 254)
106 self.assertEqual(icmp.type, 8)
107 self.assertEqual(icmp.code, 0)
108 self.assertEqual(icmp.seq, icmp_seq)
111 icmp_seq = icmp_seq + 1
116 self.assertEqual(icmp.id, icmp_id)
118 self.vapi.cli("show error")