Here is the code snippet for initializing and reading<div><br></div><div><div>int DriverWPcaP::initialize()</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if ((_adapter = PacketOpenAdapter(const_cast&lt;PCHAR&gt;(_ifname.c_str()))) == 0)</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>//Log &quot;Failed to open adapter &quot;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>return 0;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>unsigned int bufferSize = 4194304; //4MB</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if ((_packet = PacketAllocatePacket()) == 0)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>//Log &quot;Failed to allocate packet&quot;</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>return 0;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>_buffer = new uint8_t[bufferSize];</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>PacketInitPacket(_packet, _buffer, bufferSize);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if (PacketSetHwFilter(_adapter, NDIS_PACKET_TYPE_PROMISCUOUS) == FALSE)</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>//Log &quot;Failed to initialize promiscuous mode&quot;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>return 0;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>} </div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>// Set up buffers for the adapter.  PacketSetBuff wants a dimension in 1k blocks.  We divide</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>// BUFFER SIZE accordingly.</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>unsigned long bufferDimension = bufferSize / 1024;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>if (PacketSetBuff( _adapter, bufferSize) == FALSE)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>return 0;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if (PacketSetReadTimeout( _adapter, 1000) == FALSE)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>return 0;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if (PacketSetMinToCopy( _adapter, 1) == 7000000)</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>return 0;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>PacketSetSnapLen(_adapter, 1518);</div><div><br></div><div>}</div><div><br></div><div>bool DriverWPcaP::read()</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if (PacketReceivePacket(_adapter, _packet, TRUE) == FALSE)</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>return 0;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>} </div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>_bytesLeft = _packet-&gt;ulBytesReceived;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>_currentFrame = reinterpret_cast&lt;bpf_hdr*&gt;(_buffer);</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>return (_bytesLeft &gt; 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">&lt;<a href="mailto:gianluca.varenni@cacetech.com">gianluca.varenni@cacetech.com</a>&gt;</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">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&#39;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 
 &quot;PacketSetBuff&quot; API. PacketSetBuff doesn&#39;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>