go.ligato.io/vpp-agent/v3@v3.5.0/tests/robot/resources/sendEthernetFrame.py (about)

     1  #!/usr/bin/env python
     2  from socket import socket, AF_PACKET, SOCK_RAW
     3  s = socket(AF_PACKET, SOCK_RAW)
     4  s.bind(("${out_interface}", 0))
     5  
     6  src_mac_addr = "${source_address}".replace(":","").decode("hex")
     7  dst_mac_addr = "${destination_address}".replace(":","").decode("hex")
     8  payload = (${payload})
     9  checksum = "${checksum}".decode("hex")
    10  ethertype = "${ethernet_type}".decode("hex")
    11  
    12  s.send(dst_mac_addr+src_mac_addr+ethertype+payload+checksum)