<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=text/html;charset=iso-8859-1 http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.7600.16588"></HEAD>
<BODY style="PADDING-LEFT: 10px; PADDING-RIGHT: 10px; PADDING-TOP: 15px"
id=MailContainerBody leftMargin=0 topMargin=0 CanvasTabStop="true"
name="Compose message area">
<DIV><FONT face=Calibri>PacketSetBuff wants a dimension in bytes, not in
kilobytes. The documentation in packet32.c is wrong, but in any case you should
not use the Packet API. It's subject to change without any notice.</FONT></DIV>
<DIV><FONT face=Calibri></FONT> </DIV>
<DIV><FONT face=Calibri>Have a nice day</FONT></DIV>
<DIV><FONT face=Calibri>GV</FONT></DIV>
<DIV style="FONT: 10pt Tahoma">
<DIV><FONT size=3 face=Calibri></FONT><FONT size=3
face=Calibri></FONT><BR></DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=pushkartiwari@gmail.com
href="mailto:pushkartiwari@gmail.com">Pushkar Tiwari</A> </DIV>
<DIV><B>Sent:</B> Thursday, July 29, 2010 1:05 PM</DIV>
<DIV><B>To:</B> <A title=winpcap-users@winpcap.org
href="mailto:winpcap-users@winpcap.org">winpcap-users@winpcap.org</A> </DIV>
<DIV><B>Subject:</B> Re: [Winpcap-users] PacketReceivePacket error out on
allocatingbuffergerater than 4MB</DIV></DIV></DIV>
<DIV><FONT face=Calibri></FONT><FONT face=Calibri></FONT><BR></DIV>Here is the
code snippet for initializing and reading
<DIV><FONT face=Calibri></FONT><FONT face=Calibri></FONT><BR></DIV>
<DIV>
<DIV>int DriverWPcaP::initialize()</DIV>
<DIV>{</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>if ((_adapter =
PacketOpenAdapter(const_cast<PCHAR>(_ifname.c_str()))) == 0)</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>{</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>//Log "Failed to
open adapter "</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>return 0;</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>}</DIV>
<DIV><FONT face=Calibri></FONT><FONT face=Calibri></FONT><BR></DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN></DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>unsigned int
bufferSize = 4194304; //4MB</DIV>
<DIV><FONT face=Calibri></FONT><FONT face=Calibri></FONT><BR></DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>if ((_packet =
PacketAllocatePacket()) == 0)</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>{</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>//Log "Failed to
allocate packet"</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>return 0;</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>}</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>_buffer = new
uint8_t[bufferSize];</DIV>
<DIV><SPAN style="WHITE-SPACE: pre"
class=Apple-tab-span></SPAN>PacketInitPacket(_packet, _buffer,
bufferSize);</DIV>
<DIV><BR></DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>if
(PacketSetHwFilter(_adapter, NDIS_PACKET_TYPE_PROMISCUOUS) == FALSE)</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>{</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>//Log "Failed to
initialize promiscuous mode"</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>return 0;</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>} </DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN></DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>// Set up
buffers for the adapter. PacketSetBuff wants a dimension in 1k blocks.
We divide</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>// BUFFER SIZE
accordingly.</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>unsigned long
bufferDimension = bufferSize / 1024;</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>if
(PacketSetBuff( _adapter, bufferSize) == FALSE)</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>{</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>return 0;</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>}</DIV>
<DIV><BR></DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>if
(PacketSetReadTimeout( _adapter, 1000) == FALSE)</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>{</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>return 0;</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>}</DIV>
<DIV><BR></DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>if
(PacketSetMinToCopy( _adapter, 1) == 7000000)</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>{</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>return 0;</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>}</DIV>
<DIV><BR></DIV>
<DIV><SPAN style="WHITE-SPACE: pre"
class=Apple-tab-span></SPAN>PacketSetSnapLen(_adapter, 1518);</DIV>
<DIV><BR></DIV>
<DIV>}</DIV>
<DIV><BR></DIV>
<DIV>bool DriverWPcaP::read()</DIV>
<DIV>{</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>if
(PacketReceivePacket(_adapter, _packet, TRUE) == FALSE)</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>{</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>return 0;</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>} </DIV>
<DIV><BR></DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>_bytesLeft =
_packet->ulBytesReceived;</DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>_currentFrame =
reinterpret_cast<bpf_hdr*>(_buffer);</DIV>
<DIV><BR></DIV>
<DIV><SPAN style="WHITE-SPACE: pre" class=Apple-tab-span></SPAN>return
(_bytesLeft > 0);</DIV>
<DIV>}</DIV>
<DIV><BR><BR>
<DIV class=gmail_quote>On Thu, Jul 29, 2010 at 11:45 AM, Gianluca Varenni <SPAN
dir=ltr><<A
href="mailto:gianluca.varenni@cacetech.com">gianluca.varenni@cacetech.com</A>></SPAN>
wrote:<BR>
<BLOCKQUOTE
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote>
<DIV style="PADDING-LEFT: 10px; PADDING-RIGHT: 10px; PADDING-TOP: 15px"
name="Compose message area">
<DIV><FONT face=Calibri>Can you please post the code that is
failing?</FONT></DIV>
<DIV><FONT face=Calibri></FONT> </DIV>
<DIV><FONT face=Calibri>Also, bigger buffers don't necessary mean better
performance. They just enlarg</FONT></DIV>
<DIV><FONT face=Calibri>GV</FONT></DIV>
<DIV style="FONT: 10pt Tahoma">
<DIV><BR></DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV><B>From:</B> <A title=pushkartiwari@gmail.com
href="mailto:pushkartiwari@gmail.com" target=_blank>Pushkar Tiwari</A> </DIV>
<DIV><B>Sent:</B> Thursday, July 29, 2010 11:37 AM</DIV>
<DIV><B>To:</B> <A title=winpcap-users@winpcap.org
href="mailto:winpcap-users@winpcap.org"
target=_blank>winpcap-users@winpcap.org</A> </DIV>
<DIV><B>Subject:</B> [Winpcap-users] PacketReceivePacket error out on
allocating buffergerater than 4MB</DIV></DIV></DIV>
<DIV>
<DIV></DIV>
<DIV class=h5>
<DIV><BR></DIV>
<DIV>Hi,</DIV>
<DIV>I have written a piece of code to capture packets at very high speed. I
have writen my code using Packet API.</DIV>
<DIV>To gain better performance I tried allocating large buffer using
"PacketSetBuff" API. PacketSetBuff doesn't return any error on
allocating buffer greater than 4MB.</DIV>
<DIV>But when I call PacketReceivePacket to retrieve the packet, the
call fails.</DIV>
<DIV> </DIV>
<DIV>Is there any restriction on the buffer that can be allocated? Is there
some other wy through which we can allocate higher buffer and get the better
performance.</DIV>
<DIV> </DIV>
<DIV>Whats is the kernel buffer size that winpcap allocate by default?</DIV>
<DIV> </DIV>
<DIV>Here are some of my environment details:</DIV>
<DIV> </DIV>
<DIV>Winpacp Version : 4.1.1</DIV>
<DIV>OS : Win2k3</DIV>
<DIV>Memory : 8GB</DIV>
<DIV> </DIV>
<DIV>Thanks in advance.</DIV>
<DIV><BR></DIV>
<DIV>Pushkar</DIV></DIV></DIV>
<P></P>
<HR>
<P></P>_______________________________________________<BR>Winpcap-users
mailing list<BR><A href="mailto:Winpcap-users@winpcap.org"
target=_blank>Winpcap-users@winpcap.org</A><BR><A
href="https://www.winpcap.org/mailman/listinfo/winpcap-users"
target=_blank>https://www.winpcap.org/mailman/listinfo/winpcap-users</A><BR>
<P></P></DIV><BR>_______________________________________________<BR>Winpcap-users
mailing list<BR><A
href="mailto:Winpcap-users@winpcap.org">Winpcap-users@winpcap.org</A><BR><A
href="https://www.winpcap.org/mailman/listinfo/winpcap-users"
target=_blank>https://www.winpcap.org/mailman/listinfo/winpcap-users</A><BR><BR></BLOCKQUOTE></DIV><BR></DIV></DIV>
<P>
<HR>
<P></P>_______________________________________________<BR>Winpcap-users mailing
list<BR>Winpcap-users@winpcap.org<BR>https://www.winpcap.org/mailman/listinfo/winpcap-users<BR></BODY></HTML>