gonetwork-programminggopacket

how to create and send a vxlan packet wit gopacket?


I had seen some example for creating and sending TCP/UDP packet with gopacket.Now I need to catch and forward udp vxlan multicast packet, and I don't know how to construct vxlan layer and its payload.how to create and send a vxlan packet wit gopacket?


Solution

  • gopacket takes in packet data as a []byte and decodes it into a packet with a non-zero number of "layers". Each layer corresponds to a protocol within the bytes.

    Since, there is not a lot of context here and you have not provided the base code which you have written, I can only forward you to the documentation.

    So,

    Reading a packet from source : https://godoc.org/github.com/google/gopacket#hdr-Reading_Packets_From_A_Source

    Use layer type which you want to use while decoding :

    For vxlan : https://godoc.org/github.com/google/gopacket/layers#VXLAN