Created
June 22, 2023 09:05
-
-
Save rbbratta/2db58dac46722bedfc20d0f3d18f79cf to your computer and use it in GitHub Desktop.
encapOverhead
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/google/gopacket" | |
"github.com/google/gopacket/layers" | |
"github.com/google/gopacket/pcap" | |
"os" | |
) | |
func layerOffset(packet gopacket.Packet, layer gopacket.LayerType) int { | |
offset := 0 | |
for _, l := range packet.Layers() { | |
offset += len(l.LayerContents()) | |
if l.LayerType() == layer { | |
return offset | |
} | |
} | |
return -1 | |
} | |
func analyzePacket(packetFile string) { | |
handle, _ := pcap.OpenOffline(packetFile) | |
packetSource := gopacket.NewPacketSource(handle, handle.LinkType()) | |
for packet := range packetSource.Packets() { | |
if packet.Layer(layers.LayerTypeGeneve) != nil { | |
offset := layerOffset(packet, layers.LayerTypeGeneve) | |
fmt.Println("GENEVE offset =", offset) | |
} | |
} | |
} | |
func main() { | |
analyzePacket(os.Args[1]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OVN GENEVE Encap overhead