Open fdevibe opened 2 years ago
Same issue here. And here is my demonstration code:
package main
import (
"log"
"strings"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"github.com/google/gopacket/pcapgo"
)
func main() {
handler, err := pcapgo.NewEthernetHandle("lo")
if err != nil {
log.Fatalf("failed to new handler: %+v", err)
}
packetSource := gopacket.NewPacketSource(handler, layers.LayerTypeEthernet)
for packet := range packetSource.Packets() {
appLayer := packet.ApplicationLayer()
if appLayer == nil {
continue
}
payload := string(appLayer.Payload())
if strings.Contains(payload, "GET / ") {
println(payload)
}
}
}
I have Same issue, do you fixed this?
this issue is only found in 127.0.0.1 , eth0 hasn't this satuation.
if the connection is localhost to localhost, doesn't that mean that it would be the expected behavior to see the same packet twice? once in "source" and one in "dest"?
afpacket.TPacket.ZeroCopyReadPacketData()
seems to return duplicate packets. When running in a loop, the function returns twice (iterating the loop twice) for each packet.By modifying the example in
examples/afpacket/afpacket.go
with the following patch:and then running a netcat server:
with a netcat client:
I get the following output
So it seems like
will actually return the packet data twice,
source
here being aafpacket.TPacket
.Running
at the same time shows only one packet:
System: