NDIS ProtocolReceive - Is It Dead Yet?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I remember reading somewhere recently in this group that the
"abomination" of partial receives has been eliminated in Vista. Is
this true?

Also, it appears in the NDISPROT sample in the 2003 Server DDK that
the ProtocolReceive is doing unnecessary buffer allocation and
chaining in preparation to call NdisTransferData. Specifically, it
looks as if the ByteOffset field of NdisTransferData is not being
used. Instead, if a partial receive occurs, a new buffer is allocated
and chained to the packet even though the original buffer is large
enough to contain the entire packet. Why is the code written this
way? See code below:

-Le Chaud Lapin-

// Allocate resources for queueing this up.
//
pRcvPacket = ndisprotAllocateReceivePacket(
pOpenContext,
PacketSize + HeaderBufferSize, // <<<<<<<<<<
IS THIS NOT BIG ENOUGH?
&pRcvData
);

if (pRcvPacket == NULL)
{
Status = NDIS_STATUS_NOT_ACCEPTED;
break;
}

NdisMoveMappedMemory(pRcvData, pHeaderBuffer,
HeaderBufferSize);

//
// Check if the entire packet is within the lookahead.
//
if (PacketSize == LookaheadBufferSize)
{
NdisCopyLookaheadData(pRcvData+HeaderBufferSize,
pLookaheadBuffer,
LookaheadBufferSize,
pOpenContext->MacOptions);
//
// Queue this up for receive processing, and
// try to complete some read IRPs.
//
ndisprotQueueReceivePacket(pOpenContext, pRcvPacket);
}
else
{
//
// Allocate an NDIS buffer to map the receive area
// at an offset "HeaderBufferSize" from the current
// start. This is so that NdisTransferData can copy
// in at the right point in the destination buffer.
//

NdisAllocateBuffer(
&Status,
&pPartialNdisBuffer,
pOpenContext->RecvBufferPool,
pRcvData + HeaderBufferSize,
PacketSize);

if (Status == NDIS_STATUS_SUCCESS)
{
//
// Unlink and save away the original NDIS Buffer
// that maps the full receive buffer.
//
NdisUnchainBufferAtFront(pRcvPacket,
&pOriginalNdisBuffer);
NPROT_RCV_PKT_TO_ORIGINAL_BUFFER(pRcvPacket) =
pOriginalNdisBuffer;

//
// Link in the partial buffer for NdisTransferData to
// operate on.
//
NdisChainBufferAtBack(pRcvPacket, pPartialNdisBuffer);

DEBUGP(DL_LOUD, ("Receive: setting up for
TransferData:";
" Pkt %p, OriginalBuf %p, PartialBuf %p\n",
pRcvPacket, pOriginalNdisBuffer,
pPartialNdisBuffer));

NdisTransferData(
&Status,
pOpenContext->BindingHandle,
MacReceiveContext,
0, // ByteOffset
PacketSize,
pRcvPacket,
&BytesTransferred);
}
else
{
//
// Failure handled below in TransferDataComplete.
//
BytesTransferred = 0;
}

.



Relevant Pages

  • Re: NDIS ProtocolReceive - Is It Dead Yet?
    ... Certainly the NDIS 5 NDISPROT sample includes logic to deal with the abomination. ... The "unnecessary" buffer allocation is due to a fault in NdisTransferData. ... NdisTransferData does not feature an offset into the destination packet. ...
    (microsoft.public.development.device.drivers)
  • Re: Interesting TCP behaviour with large sends/small buffers
    ... My current workaround is simply setting the send buffer to a larger ... The server, upon connection, sends a configurable number of bytes to ... packet before sending the next packet. ... ACK, according to the delayed ACK algorithm - 50KB bytes means 34 MSS- ...
    (microsoft.public.win32.programmer.networks)
  • Re: Interesting TCP behaviour with large sends/small buffers
    ... The server, upon connection, sends a configurable number of bytes to ... I set the client's receive buffer size to 1MBps, ... packet before sending the next packet. ... ACK, according to the delayed ACK algorithm - 50KB bytes means 34 MSS- ...
    (microsoft.public.win32.programmer.networks)
  • Re: Fundamentals question, is this how it works?
    ... You maintain a buffer for the last incomplete packet. ... receiving that many bytes i then break and wait for the next set of data ... With a tcp stream socket what happens when it is reading say 4000bytes ...
    (microsoft.public.win32.programmer.networks)
  • Re: Design of a Router
    ... packet forward it and than close the port and move to the next and so ... would ideally like the router as small and as fast as possible. ... size of your buffer (just keep in mind that if you have 4 ports than ...
    (comp.lang.verilog)