[Winpcap-users] Problems with send queues

Gianluca Varenni gianluca.varenni at cacetech.com
Wed Apr 8 08:39:33 PDT 2009


----- Original Message ----- 
From: "Janne Heikkinen" <janne.m.heikkinen at helsinki.fi>
To: <winpcap-users at winpcap.org>
Sent: Wednesday, April 08, 2009 4:39 AM
Subject: [Winpcap-users] Problems with send queues


>
> I made small test programs that uses pcap_sendpacket() and it works
> otherwise ok but troughput is quite low (something like 17 - 23 Mbytes/s
> depending on NIC on gigabit Ethernet).
>
> So I was trying to convert the program to use send queues hoping to
> get better troughtput but I wasn't able to get it working. Code is like
> this:
>
>   squeue = pcap_sendqueue_alloc(packet_count * packet_size);
>
>   struct pcap_pkthdr pktheader;
>
>   for(int i=0; i < packet_count; i++)
>   {
>      memset(&pktheader, 0, sizeof(pktheader));
>      pktheader.len = packet_size;
>
>      if (pcap_sendqueue_queue(squeue, &pktheader, pktdata) == -1)
>         show_error_message();
>   }
>
>
>   if ((res = pcap_sendqueue_transmit(outdesc, squeue, sync)) < 
> squeue->len)
>      show_error_messsage();
>
>   pcap_sendqueue_destroy(squeue);
>
> Where pktdata is same packet that I've sent earlier with
> pcap_send_packet(). On Vista computer pcap_sendque_transmit()
> doesn't send all the bytes and on XP computer pcap_sendqueue_queue()
> returns errror but pcap_geterr() return empty string.

Both on Vista and XP sendqueue_queue will probably fail because whenever you 
enqueue a packet, a small header is prepended to each packet itself, 
accounting for more bytes in the internal queue buffer.

There are two workarounds for that:
1. transmit the queue when sendqueue_queue fails or
2. when you allocate the buffer, you need to allocate

squeue = pcap_sendqueue_alloc(packet_count * (packet_size + sizeof(struct 
pcap_pkthdr)));



>
> Oh, and the program runs pcap_loop() in another thread.
>

I would probably use two different pcap instances for transmitting and 
receiving.

Have a nice day
GV


> - Janne
>
> _______________________________________________
> Winpcap-users mailing list
> Winpcap-users at winpcap.org
> https://www.winpcap.org/mailman/listinfo/winpcap-users 



More information about the Winpcap-users mailing list