Hi,
I have build a network driver wich basically uses the Tdi interfaces and communicates with TCP protocol driver. Now using the TDI call “TdiBuildSetEventHandler” I have registered a callback which basically gives me a callback whenever requested data is available from TCP. Now my smaller requests are serviced in one go, however the larger requests are basically received in a fragmented manner (MAX bytes received at a time equals 1460 which i am guessing is the MAX payload of a single TCP packet).
Now is there any way that I can get a fixed chunk of data after TCP has internally buffered it somehow ? I have read about the TdiBuildReceive to build an IRP to signal TCP for more data. Are there any other efficient ways of collecting data from TCP ?
Also in the prototype of ClientEventReceive
NTSTATUS
ClientEventReceive(
IN PVOID TdiEventContext,
IN CONNECTION_CONTEXT ConnectionContext,
IN ULONG ReceiveFlags,
IN ULONG BytesIndicated,
IN ULONG BytesAvailable,
OUT ULONG *BytesTaken,
IN PVOID Tsdu,
OUT PIRP *IoRequestPacket
);
what exactly is the role of IoRequestPacket ?? Is it just used in “TdiBuildReceive” to signal for more data ?
That is the way that the TDI event handler will work. When data becomes
available, the event handler is called.
In your case you might get the behavior you desire using the TdiBuildReceive
method instead of the event handler.
Good luck,
Thomas F. Divine
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-351877-
xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Wednesday, January 21, 2009 1:24 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to receive entire TCP data using TDI Interface ?
Hi,
I have build a network driver wich basically uses the Tdi interfaces
and communicates with TCP protocol driver. Now using the TDI call
“TdiBuildSetEventHandler” I have registered a callback which basically
gives me a callback whenever requested data is available from TCP. Now
my smaller requests are serviced in one go, however the larger requests
are basically received in a fragmented manner (MAX bytes received at a
time equals 1460 which i am guessing is the MAX payload of a single TCP
packet).
Now is there any way that I can get a fixed chunk of data after TCP has
internally buffered it somehow ? I have read about the TdiBuildReceive
to build an IRP to signal TCP for more data. Are there any other
efficient ways of collecting data from TCP ?
Also in the prototype of ClientEventReceive
NTSTATUS
ClientEventReceive(
IN PVOID TdiEventContext,
IN CONNECTION_CONTEXT ConnectionContext,
IN ULONG ReceiveFlags,
IN ULONG BytesIndicated,
IN ULONG BytesAvailable,
OUT ULONG *BytesTaken,
IN PVOID Tsdu,
OUT PIRP *IoRequestPacket
);
what exactly is the role of IoRequestPacket ?? Is it just used in
“TdiBuildReceive” to signal for more data ?
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
> Now is there any way that I can get a fixed chunk of data after TCP has internally buffered it
somehow ?
No. TCP will return you as much data as it is present in its buffers, regardless of what chunk size do you want.
NTSTATUS
ClientEventReceive(
IN PVOID TdiEventContext,
IN CONNECTION_CONTEXT ConnectionContext,
IN ULONG ReceiveFlags,
IN ULONG BytesIndicated,
IN ULONG BytesAvailable,
OUT ULONG *BytesTaken,
IN PVOID Tsdu,
OUT PIRP *IoRequestPacket
);
what exactly is the role of IoRequestPacket ??
In this case, the receive is 2-phase operation - first ClientEventReceive is called, you do some processing (possibly allocating memory for the incoming data), then you build IRP/MDL pair of TDI_RECEIVE and return this IRP as *IoRequestPacket.
Then, later, the completion routine will be called for the IRP, which will mean - the data received OK.
This “2phaseness” allows you to a) allocate memory for the incoming data on demand and b) allocate a buffer larger then the available data and send it to TDI_RECEIVE.
TDI_RECEIVE is completed when:
a) the incoming data fully filled the IRP
OR
b) the incoming data packet with PSH bit arrived
OR
c) on some timeout like 500ms, provided the IRP is not totally empty and at least some data have arrived to it.
–
Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com