Skip to content

Commit 536384c

Browse files
Emir ÖzbirEmir Özbir
authored andcommitted
master: The MTU closing IP calculation added
1 parent 8b55ec4 commit 536384c

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ func TcpStream(device string, filter string) {
7676
tcp, ok := tcpLayer.(*layers.TCP)
7777

7878
ip, ok := ipLayer.(*layers.IPv4)
79-
80-
if ip.Flags.String() == "DF" {
81-
dfMetric.WithLabelValues(ip.SrcIP.String(), ip.DstIP.String(), detectedDeviceName).Add(1.0)
79+
if ip.Flags&layers.IPv4DontFragment != 0 {
80+
pktSize := len(ip.Payload) + 20 // IP header
81+
dfPacketSizeHistogram.WithLabelValues(detectedDeviceName).Observe(float64(pktSize))
8282
}
8383

8484
for _, val := range tcp.Options {

prometheus.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ var (
2828
Help: "TCP RST metrics that contains details and error type",
2929
}, []string{"srcIp", "dstIp", "deviceName"})
3030

31+
dfPacketSizeHistogram = promauto.NewHistogramVec(prometheus.HistogramOpts{
32+
Name: "ip_df_packet_size_bytes",
33+
Help: "Size distribution of IP packets with DF flag set",
34+
Buckets: []float64{576, 1280, 1400, 1420, 1450, 1472, 1480, 1500, 1505, 9000},
35+
}, []string{"device"})
36+
3137
dfMetric = promauto.NewCounterVec(prometheus.CounterOpts{
3238
Name: "ip_df_metric",
3339
Help: "Ip layer do not fragment metric",

0 commit comments

Comments
 (0)