Skip to content

For UDP packets, applicationLayer.Payload() is not the same of udpLayer.LayerPayload() #709

@alopumomovia

Description

@alopumomovia

I am observing a strange behaviour while filtering UDP packets from a .pcap file and getting their payload.

`
for packet := range packetSource.Packets() {

    if err := packet.ErrorLayer(); err != nil {
        continue
    }

    udpLayer := packet.Layer(layers.LayerTypeUDP)
    if udpLayer == nil {
      continue
    }

    // Condition A
    if len(udpLayer.LayerPayload()) == 0 {
        continue
    }

   /* Condition B
   appLayer := packet.ApplicationLayer()
   if appLayer == nil || len(appLayer.Payload()) == 0 {
            continue
   }*/

`

With condition A I get 179 packets, with condition B (and A disabled) I get 89 packets. Why?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions