[dts] [PATCH v1] framework/packet: wait link status ready before transmission packets

Marvin Liu yong.liu at intel.com
Thu Aug 24 09:31:07 CEST 2017


Link status may not be ready when suite calling transmission function.
Now check link status first and then transmit packets.

Signed-off-by: Marvin Liu <yong.liu at intel.com>

diff --git a/framework/packet.py b/framework/packet.py
index 924fd5e..e9a1c41 100755
--- a/framework/packet.py
+++ b/framework/packet.py
@@ -351,7 +351,21 @@ class scapy(object):
 
     def send_pkt(self, intf='', count=1):
         self.print_summary()
+
         if intf != '':
+            # wait few seconds for link ready
+            countdown = 600
+            while countdown:
+                link_st = subprocess.check_output("ip link show %s" % intf,
+                                                  stderr=subprocess.STDOUT,
+                                                  shell=True)
+                if "LOWER_UP" in link_st:
+                    break
+                else:
+                    time.sleep(0.01)
+                    countdown -= 1
+                    continue
+
             # fix fortville can't receive packets with 00:00:00:00:00:00
             if self.pkt.getlayer(0).src == "00:00:00:00:00:00":
                 self.pkt.getlayer(0).src = get_if_hwaddr(intf)
-- 
1.9.3



More information about the dts mailing list