Thanks Gianluca.<div>I will modify code to pass the value in Bytes rather in KB. You mentioned that we should not be using Packet API, it's subject to change. Can you please provide me some alternative way supported by winpcap API, so that I can allocate the higher buffer size.</div>
<div><br></div><div>Thanks,</div><div>Pushkar<br><br><div class="gmail_quote">On Thu, Jul 29, 2010 at 1:16 PM, Gianluca Varenni <span dir="ltr"><<a href="mailto:gianluca.varenni@cacetech.com">gianluca.varenni@cacetech.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div style="padding-left:10px;padding-right:10px;padding-top:15px" 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><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 1:05 PM</div><div class="im">
<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><div><b>Subject:</b> Re: [Winpcap-users] PacketReceivePacket error out on
allocatingbuffergerater than 4MB</div></div></div><div><div></div><div class="h5">
<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-wrap"></span>if ((_adapter =
PacketOpenAdapter(const_cast<PCHAR>(_ifname.c_str()))) == 0)</div>
<div><span style="white-space:pre-wrap"></span>{</div>
<div><span style="white-space:pre-wrap"></span>//Log "Failed to
open adapter "</div>
<div><span style="white-space:pre-wrap"></span>return 0;</div>
<div><span style="white-space:pre-wrap"></span>}</div>
<div><font face="Calibri"></font><font face="Calibri"></font><br></div>
<div><span style="white-space:pre-wrap"></span></div>
<div><span style="white-space:pre-wrap"></span>unsigned int
bufferSize = 4194304; //4MB</div>
<div><font face="Calibri"></font><font face="Calibri"></font><br></div>
<div><span style="white-space:pre-wrap"></span>if ((_packet =
PacketAllocatePacket()) == 0)</div>
<div><span style="white-space:pre-wrap"></span>{</div>
<div><span style="white-space:pre-wrap"></span>//Log "Failed to
allocate packet"</div>
<div><span style="white-space:pre-wrap"></span>return 0;</div>
<div><span style="white-space:pre-wrap"></span>}</div>
<div><span style="white-space:pre-wrap"></span>_buffer = new
uint8_t[bufferSize];</div>
<div><span style="white-space:pre-wrap"></span>PacketInitPacket(_packet, _buffer,
bufferSize);</div>
<div><br></div>
<div><span style="white-space:pre-wrap"></span>if
(PacketSetHwFilter(_adapter, NDIS_PACKET_TYPE_PROMISCUOUS) == FALSE)</div>
<div><span style="white-space:pre-wrap"></span>{</div>
<div><span style="white-space:pre-wrap"></span>//Log "Failed to
initialize promiscuous mode"</div>
<div><span style="white-space:pre-wrap"></span>return 0;</div>
<div><span style="white-space:pre-wrap"></span>} </div>
<div><span style="white-space:pre-wrap"></span></div>
<div><span style="white-space:pre-wrap"></span>// Set up
buffers for the adapter. PacketSetBuff wants a dimension in 1k blocks.
We divide</div>
<div><span style="white-space:pre-wrap"></span>// BUFFER SIZE
accordingly.</div>
<div><span style="white-space:pre-wrap"></span>unsigned long
bufferDimension = bufferSize / 1024;</div>
<div><span style="white-space:pre-wrap"></span>if
(PacketSetBuff( _adapter, bufferSize) == FALSE)</div>
<div><span style="white-space:pre-wrap"></span>{</div>
<div><span style="white-space:pre-wrap"></span>return 0;</div>
<div><span style="white-space:pre-wrap"></span>}</div>
<div><br></div>
<div><span style="white-space:pre-wrap"></span>if
(PacketSetReadTimeout( _adapter, 1000) == FALSE)</div>
<div><span style="white-space:pre-wrap"></span>{</div>
<div><span style="white-space:pre-wrap"></span>return 0;</div>
<div><span style="white-space:pre-wrap"></span>}</div>
<div><br></div>
<div><span style="white-space:pre-wrap"></span>if
(PacketSetMinToCopy( _adapter, 1) == 7000000)</div>
<div><span style="white-space:pre-wrap"></span>{</div>
<div><span style="white-space:pre-wrap"></span>return 0;</div>
<div><span style="white-space:pre-wrap"></span>}</div>
<div><br></div>
<div><span style="white-space:pre-wrap"></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-wrap"></span>if
(PacketReceivePacket(_adapter, _packet, TRUE) == FALSE)</div>
<div><span style="white-space:pre-wrap"></span>{</div>
<div><span style="white-space:pre-wrap"></span>return 0;</div>
<div><span style="white-space:pre-wrap"></span>} </div>
<div><br></div>
<div><span style="white-space:pre-wrap"></span>_bytesLeft =
_packet->ulBytesReceived;</div>
<div><span style="white-space:pre-wrap"></span>_currentFrame =
reinterpret_cast<bpf_hdr*>(_buffer);</div>
<div><br></div>
<div><span style="white-space:pre-wrap"></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" target="_blank">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>
<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" 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>
<br></blockquote></div><br></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></div></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>