[Winpcap-users] PacketReceivePacket error out onallocatingbuffergerater than 4MB
Gianluca Varenni
gianluca.varenni at cacetech.com
Thu Jul 29 13:29:56 PDT 2010
You can change the kernel buffer size with pcap_setbuff. The PACKET buffer and the kernel buffer do not need to be the same size.
Have a nice day
GV
From: Pushkar Tiwari
Sent: Thursday, July 29, 2010 1:22 PM
To: winpcap-users at winpcap.org
Subject: Re: [Winpcap-users] PacketReceivePacket error out onallocatingbuffergerater than 4MB
Thanks Gianluca.
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.
Thanks,
Pushkar
On Thu, Jul 29, 2010 at 1:16 PM, Gianluca Varenni <gianluca.varenni at cacetech.com> wrote:
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.
Have a nice day
GV
From: Pushkar Tiwari
Sent: Thursday, July 29, 2010 1:05 PM
To: winpcap-users at winpcap.org
Subject: Re: [Winpcap-users] PacketReceivePacket error out on allocatingbuffergerater than 4MB
Here is the code snippet for initializing and reading
int DriverWPcaP::initialize()
{
if ((_adapter = PacketOpenAdapter(const_cast<PCHAR>(_ifname.c_str()))) == 0)
{
//Log "Failed to open adapter "
return 0;
}
unsigned int bufferSize = 4194304; //4MB
if ((_packet = PacketAllocatePacket()) == 0)
{
//Log "Failed to allocate packet"
return 0;
}
_buffer = new uint8_t[bufferSize];
PacketInitPacket(_packet, _buffer, bufferSize);
if (PacketSetHwFilter(_adapter, NDIS_PACKET_TYPE_PROMISCUOUS) == FALSE)
{
//Log "Failed to initialize promiscuous mode"
return 0;
}
// Set up buffers for the adapter. PacketSetBuff wants a dimension in 1k blocks. We divide
// BUFFER SIZE accordingly.
unsigned long bufferDimension = bufferSize / 1024;
if (PacketSetBuff( _adapter, bufferSize) == FALSE)
{
return 0;
}
if (PacketSetReadTimeout( _adapter, 1000) == FALSE)
{
return 0;
}
if (PacketSetMinToCopy( _adapter, 1) == 7000000)
{
return 0;
}
PacketSetSnapLen(_adapter, 1518);
}
bool DriverWPcaP::read()
{
if (PacketReceivePacket(_adapter, _packet, TRUE) == FALSE)
{
return 0;
}
_bytesLeft = _packet->ulBytesReceived;
_currentFrame = reinterpret_cast<bpf_hdr*>(_buffer);
return (_bytesLeft > 0);
}
On Thu, Jul 29, 2010 at 11:45 AM, Gianluca Varenni <gianluca.varenni at cacetech.com> wrote:
Can you please post the code that is failing?
Also, bigger buffers don't necessary mean better performance. They just enlarg
GV
From: Pushkar Tiwari
Sent: Thursday, July 29, 2010 11:37 AM
To: winpcap-users at winpcap.org
Subject: [Winpcap-users] PacketReceivePacket error out on allocating buffergerater than 4MB
Hi,
I have written a piece of code to capture packets at very high speed. I have writen my code using Packet API.
To gain better performance I tried allocating large buffer using "PacketSetBuff" API. PacketSetBuff doesn't return any error on allocating buffer greater than 4MB.
But when I call PacketReceivePacket to retrieve the packet, the call fails.
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.
Whats is the kernel buffer size that winpcap allocate by default?
Here are some of my environment details:
Winpacp Version : 4.1.1
OS : Win2k3
Memory : 8GB
Thanks in advance.
Pushkar
----------------------------------------------------------------------------
_______________________________________________
Winpcap-users mailing list
Winpcap-users at winpcap.org
https://www.winpcap.org/mailman/listinfo/winpcap-users
_______________________________________________
Winpcap-users mailing list
Winpcap-users at winpcap.org
https://www.winpcap.org/mailman/listinfo/winpcap-users
------------------------------------------------------------------------------
_______________________________________________
Winpcap-users mailing list
Winpcap-users at winpcap.org
https://www.winpcap.org/mailman/listinfo/winpcap-users
_______________________________________________
Winpcap-users mailing list
Winpcap-users at winpcap.org
https://www.winpcap.org/mailman/listinfo/winpcap-users
--------------------------------------------------------------------------------
_______________________________________________
Winpcap-users mailing list
Winpcap-users at winpcap.org
https://www.winpcap.org/mailman/listinfo/winpcap-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20100729/287968f3/attachment.htm
More information about the Winpcap-users
mailing list