Good point.  
as a comparison: tcpdump -w /dev/null can handle up to 750Mbps, where 
sending machine's  speed limit reached. I think it should be able to handle 
line rate.

Are those two packages lighter/faster than gopacket?


Thanks,
Chun

On Friday, May 26, 2017 at 12:37:55 PM UTC-4, Egon wrote:
>
> As a baseline measurement I suggest writing the same code in C; this shows 
> how much your VM / config / machine can handle.
>
> With gopacket -- use src.NextPacket instead of Packets.
>
> There are also: https://github.com/akrennmair/gopcap and 
> https://github.com/miekg/pcap
>
> + Egon
>
> On Friday, 26 May 2017 19:01:20 UTC+3, Chun Zhang wrote:
>>
>> 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 golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to