Hi, All,
I am trying to write a small program to handle packets coming from a GigE
wire. The testing code snip is as below.
The problem I am facing is that this is extremely slow, can only handle up
to 250Mbps-ish traffic with normal ipv4 sized packets, anything above that
resulting significant packet drop. Note that I am doing nothing with the
packet at this moment. If I try to do any packet processing, then
apparently it gets slower.
Has anybody measured the efficiency of the gopacket package? Is there any
other faster alternatives?
PS: the host machine is an ubuntu VM with 12-core and 12G memory, but looks
only 2 cores are used for this program.
Thanks,
Chun
// Open device
handle, err = pcap.OpenLive(device, snapshot_len, promiscuous, timeout)
if err == nil {
Info.Println("Open interface ", device, "successfully")
}
defer handle.Close()
//fmt.Println("In the deafult reading case ", time.Now())
// Use the handle as a packet source to process all packets
packetSource := gopacket.NewPacketSource(handle, handle.LinkType())
Info.Println("pcketsourc is ", packetSource, time.Now())
for packet := range packetSource.Packets() {
Debug.Println("-------------------------------------------------------------------")
count++
Warning.Println("packet count ", count)
// write to a pcap for testing
/*err = w.WritePacket(packet.Metadata().CaptureInfo,
packet.Data())
if err != nil {
fmt.Println(err)
}*/
continue
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.