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?
Asked
Active
Viewed 638 times
1 Answers
2
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

Kartavya Ramnani
- 800
- 9
- 17
-
1thanks, It helps me a lot. I create a UDP packet like [link](https://gist.github.com/chrisnc/0ff3d1c20cb6687454b0), and use layers.VXLAN.Contents and layers.VXLAN.Payload as the payload of UDP packet.Then send the UDP packet with unix raw socket.It work well. – consteven Aug 16 '20 at 03:35
-
Glad I could help @consteven, All the best. – Kartavya Ramnani Aug 16 '20 at 08:26