virtual network adapter receive packet simulation

Hi all!

I have the following problem:

I have modified the vnetmini ddk sample. I have an
application who generates an ip packet and pushes it
to the vnetmini driver via ioctl. So now the vnetmini
driver
have to simulate a receive packet, so as it arrives
from network.

Short:

  1. App generates IP Packet
  2. App pushes it to vnetmini driver
  3. Vnetmini driver simulate an receive packet
    (push to tcp ip stack)

so here is my code, it crashes after 2-3 sec.

NdisAllocatePacket(&Status,&MyPacket,Adapter->RecvPacketPoolHandle);
NdisAllocateBuffer(&Status,&MyContent,Adapter->SendBufferPoolHandle,&HighAddress,
NIC_BUFFER_SIZE);
NDIS_SET_PACKET_HEADER_SIZE(MyPacket,14);
NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(MyPacket, NULL,
0); NdisChainBufferAtBack(MyPacket,MyContent);
NdisMIndicateReceivePacket(Adapter->AdapterHandle,&MyPacket,1);

MyPacket has no content. Later I will fill it with the
ether header,ip header, content… etc


Gesendet von Yahoo! Mail - Jetzt mit 250MB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de

What crash do you get? That would be extremely helpful in identifying the
problem…

Also, how many PACKETS have you processed at the point of the crash?


Mats
xxxxx@lists.osr.com wrote on 02/23/2005 03:18:27 PM:

Hi all!

I have the following problem:

I have modified the vnetmini ddk sample. I have an
application who generates an ip packet and pushes it
to the vnetmini driver via ioctl. So now the vnetmini
driver
have to simulate a receive packet, so as it arrives
from network.

Short:

  1. App generates IP Packet
  2. App pushes it to vnetmini driver
  3. Vnetmini driver simulate an receive packet
    (push to tcp ip stack)

so here is my code, it crashes after 2-3 sec.

NdisAllocatePacket(&Status,&MyPacket,Adapter->RecvPacketPoolHandle);
NdisAllocateBuffer(&Status,&MyContent,Adapter->SendBufferPoolHandle,
&HighAddress,
NIC_BUFFER_SIZE);
NDIS_SET_PACKET_HEADER_SIZE(MyPacket,14);
NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(MyPacket, NULL,
0); NdisChainBufferAtBack(MyPacket,MyContent);
NdisMIndicateReceivePacket(Adapter->AdapterHandle,&MyPacket,1);

MyPacket has no content. Later I will fill it with the
ether header,ip header, content… etc


Gesendet von Yahoo! Mail - Jetzt mit 250MB Speicher kostenlos -
Hieranmelden:
http://mail.yahoo.de


Questions? First check the Kernel Driver FAQ at http://www.
osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@3dlabs.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

ForwardSourceID:NT0000D8D6

I will send one packet. The system freezes. :frowning:

— Mats PETERSSON
schrieb:
>
>
>
>
>
> What crash do you get? That would be extremely
> helpful in identifying the
> problem…
>
> Also, how many PACKETS have you processed at the
> point of the crash?
>
> –
> Mats
> xxxxx@lists.osr.com wrote on
> 02/23/2005 03:18:27 PM:
>
> >
> >
> > Hi all!
> >
> > I have the following problem:
> >
> > I have modified the vnetmini ddk sample. I have an
> > application who generates an ip packet and pushes
> it
> > to the vnetmini driver via ioctl. So now the
> vnetmini
> > driver
> > have to simulate a receive packet, so as it
> arrives
> > from network.
> >
> > Short:
> >
> > 1. App generates IP Packet
> > 2. App pushes it to vnetmini driver
> > 3. Vnetmini driver simulate an receive packet
> > (push to tcp ip stack)
> >
> >
> > so here is my code, it crashes after 2-3 sec.
> >
> >
> >
>
NdisAllocatePacket(&Status,&MyPacket,Adapter->RecvPacketPoolHandle);
> >
>
NdisAllocateBuffer(&Status,&MyContent,Adapter->SendBufferPoolHandle,
> > &HighAddress,
> > NIC_BUFFER_SIZE);
> > NDIS_SET_PACKET_HEADER_SIZE(MyPacket,14);
> > NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(MyPacket,
> NULL,
> > 0);
> NdisChainBufferAtBack(MyPacket,MyContent);
> >
>
NdisMIndicateReceivePacket(Adapter->AdapterHandle,&MyPacket,1);
> >
> > MyPacket has no content. Later I will fill it with
> the
> > ether header,ip header, content… etc
> >
> >
> >
> >
> >
> >
> >
>

> > Gesendet von Yahoo! Mail - Jetzt mit 250MB
> Speicher kostenlos -
> Hieranmelden:
> > http://mail.yahoo.de
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> http://www.
> > osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as:
> xxxxx@3dlabs.com
> > To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>
> > ForwardSourceID:NT0000D8D6
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@yahoo.com
> To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>


Gesendet von Yahoo! Mail - Jetzt mit 250MB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de

Allocating Ndis_PACKET and NDIS_BUFFER on the fly is not a good idea in
terms of performance, but that’s ok.

Do NOT indicate packet until the packet is ready (content is valid). Once
you indicated the packet(s), all bounded protocols will receive and may
process the packet(s).

Once you indicate packet(s), you don’t own the packets(s). Do NOT touch them
until you regain ownership of the packet(s). By regaining ownership, I mean
either:

  1. The packet was returned through your MiniportReturnPacket callback
  2. You indicate the packet(s) with NDIS_STATUS_RESOURCES, and
    NdisMIndicateReceivePacket has returned. (MiniportReturnPacket won’t get
    called in this case).

Post the !analyze -v output, please.

Calvin Guan Software Engineer
ATI Technologies Inc. www.ati.com

-----Original Message-----
From: Bruce Raynold [mailto:xxxxx@yahoo.com]
Sent: February 23, 2005 10:18 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] virtual network adapter receive packet simulation

Hi all!

I have the following problem:

I have modified the vnetmini ddk sample. I have an
application who generates an ip packet and pushes it
to the vnetmini driver via ioctl. So now the vnetmini
driver
have to simulate a receive packet, so as it arrives
from network.

Short:

  1. App generates IP Packet
  2. App pushes it to vnetmini driver
  3. Vnetmini driver simulate an receive packet
    (push to tcp ip stack)

so here is my code, it crashes after 2-3 sec.

NdisAllocatePacket(&Status,&MyPacket,Adapter->RecvPacketPoolHandle);
NdisAllocateBuffer(&Status,&MyContent,Adapter-
>SendBufferPoolHandle,&HighAddress,
NIC_BUFFER_SIZE);
NDIS_SET_PACKET_HEADER_SIZE(MyPacket,14);
NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(MyPacket, NULL,
0); NdisChainBufferAtBack(MyPacket,MyContent);
NdisMIndicateReceivePacket(Adapter->AdapterHandle,&MyPacket,1);

MyPacket has no content. Later I will fill it with the
ether header,ip header, content… etc


Gesendet von Yahoo! Mail - Jetzt mit 250MB Speicher kostenlos - Hier
anmelden: http://mail.yahoo.de


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@ati.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Hi Bruce,

Take a look at http://www.ndis.com/pcakb/KB01060101.htm
There may be a problem with the buffer size.

Good luck,
Andrei

Bruce Raynold wrote:

I will send one packet. The system freezes. :frowning:

— Mats PETERSSON
>schrieb:
>
>
>>
>>
>>
>>What crash do you get? That would be extremely
>>helpful in identifying the
>>problem…
>>
>>Also, how many PACKETS have you processed at the
>>point of the crash?
>>
>>–
>>Mats
>>xxxxx@lists.osr.com wrote on
>>02/23/2005 03:18:27 PM:
>>
>>
>>
>>>Hi all!
>>>
>>>I have the following problem:
>>>
>>>I have modified the vnetmini ddk sample. I have an
>>>application who generates an ip packet and pushes
>>>
>>>
>>it
>>
>>
>>>to the vnetmini driver via ioctl. So now the
>>>
>>>
>>vnetmini
>>
>>
>>>driver
>>>have to simulate a receive packet, so as it
>>>
>>>
>>arrives
>>
>>
>>>from network.
>>>
>>>Short:
>>>
>>>1. App generates IP Packet
>>>2. App pushes it to vnetmini driver
>>>3. Vnetmini driver simulate an receive packet
>>> (push to tcp ip stack)
>>>
>>>
>>>so here is my code, it crashes after 2-3 sec.
>>>
>>>
>>>
>>>
>>>
>NdisAllocatePacket(&Status,&MyPacket,Adapter->RecvPacketPoolHandle);
>
>
>NdisAllocateBuffer(&Status,&MyContent,Adapter->SendBufferPoolHandle,
>
>
>>>&HighAddress,
>>>NIC_BUFFER_SIZE);
>>>NDIS_SET_PACKET_HEADER_SIZE(MyPacket,14);
>>>NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(MyPacket,
>>>
>>>
>>NULL,
>>
>>
>>>0);
>>>
>>>
>>NdisChainBufferAtBack(MyPacket,MyContent);
>>
>>
>NdisMIndicateReceivePacket(Adapter->AdapterHandle,&MyPacket,1);
>
>
>>>MyPacket has no content. Later I will fill it with
>>>
>>>
>>the
>>
>>
>>>ether header,ip header, content… etc
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>
>
>
>>>Gesendet von Yahoo! Mail - Jetzt mit 250MB
>>>
>>>
>>Speicher kostenlos -
>>Hieranmelden:
>>
>>
>>>http://mail.yahoo.de
>>>
>>>—
>>>Questions? First check the Kernel Driver FAQ at
>>>
>>>
>>http://www.
>>
>>
>>>osronline.com/article.cfm?id=256
>>>
>>>You are currently subscribed to ntdev as:
>>>
>>>
>>xxxxx@3dlabs.com
>>
>>
>>>To unsubscribe send a blank email to
>>>
>>>
>>xxxxx@lists.osr.com
>>
>>
>>
>>>ForwardSourceID:NT0000D8D6
>>>
>>>
>>—
>>Questions? First check the Kernel Driver FAQ at
>>http://www.osronline.com/article.cfm?id=256
>>
>>You are currently subscribed to ntdev as:
>>xxxxx@yahoo.com
>>To unsubscribe send a blank email to
>>xxxxx@lists.osr.com
>>
>>
>>
>
>
>
>
>

>Gesendet von Yahoo! Mail - Jetzt mit 250MB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de
>
>—
>Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
>
>You are currently subscribed to ntdev as: xxxxx@bitdefender.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>


Ignorance more frequently begets confidence than does knowledge.
— Charles Darwin


This message was scanned for spam and viruses by BitDefender.
For more information please visit http://linux.bitdefender.com/

So now the code is:

unsigned char echo_reply = “\xfb\xa1\x3d\xd3\x08\x00\x45\x00\xe6\xdc\xd8\xef\x39\x68\xc0\xa8\x05\x00\x61\x62\x63\x64\x65\x66\x6f\x70\x71\x72\x73\x74\x75\x76\x68\x69”;

NdisAllocatePacket(&Status, &MyPacket,Adapter->RecvPacketPoolHandle);
NdisAllocateBuffer(&Status, &MyContent,Adapter->SendBufferPoolHandle, &HighAddress, NIC_BUFFER_SIZE);
NDIS_SET_PACKET_HEADER_SIZE(MyPacket,14);
NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(MyPacket, NULL, 0 );
NDIS_SET_PACKET_STATUS(MyPacket,NDIS_STATUS_RESOURCES);
memset(&MyContent,0,NIC_BUFFER_SIZE);
memcpy(&MyContent,&echo_reply,sizeof(echo_reply));
NdisChainBufferAtBack(MyPacket,MyContent);
NdisMIndicateReceivePacket(Adapter->AdapterHandle, &MyPacket,1);

echo_reply is an sample packet received over network, for testing my driver…

My system freezes after 2-3 seconds or the application that generates the ioctl freezes.
Where is the error?!? :frowning:

Calvin Guan wrote:
Allocating Ndis_PACKET and NDIS_BUFFER on the fly is not a good idea in terms of performance, but that’s ok.

Do NOT indicate packet until the packet is ready (content is valid). Once you indicated the packet(s), all bounded protocols will receive and may process the packet(s).

Once you indicate packet(s), you don’t own the packets(s). Do NOT touch them until you regain ownership of the packet(s). By regaining ownership, I mean either:

1) The packet was returned through your MiniportReturnPacket callback
2) You indicate the packet(s) with NDIS_STATUS_RESOURCES, and NdisMIndicateReceivePacket has returned. (MiniportReturnPacket won’t get called in this case).

Post the !analyze -v output, please.

-
Calvin Guan Software Engineer
ATI Technologies Inc. www.ati.com

> -----Original Message-----
> From: Bruce Raynold [mailto:xxxxx@yahoo.com]
> Sent: February 23, 2005 10:18 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] virtual network adapter receive packet simulation
>
>
>
> Hi all!
>
> I have the following problem:
>
> I have modified the vnetmini ddk sample. I have an
> application who generates an ip packet and pushes it
> to the vnetmini driver via ioctl. So now the vnetmini
> driver
> have to simulate a receive packet, so as it arrives
> from network.
>
> Short:
>
> 1. App generates IP Packet
> 2. App pushes it to vnetmini driver
> 3. Vnetmini driver simulate an receive packet
> (push to tcp ip stack)
>
>
> so here is my code, it crashes after 2-3 sec.
>
>
> NdisAllocatePacket(&Status,&MyPacket,Adapter->RecvPacketPoolHandle);
> NdisAllocateBuffer(&Status,&MyContent,Adapter-
> >SendBufferPoolHandle,&HighAddress,
> NIC_BUFFER_SIZE);
> NDIS_SET_PACKET_HEADER_SIZE(MyPacket,14);
> NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(MyPacket, NULL,
> 0); NdisChainBufferAtBack(MyPacket,MyContent);
> NdisMIndicateReceivePacket(Adapter->AdapterHandle,&MyPacket,1);
>
> MyPacket has no content. Later I will fill it with the
> ether header,ip header, content… etc
>
>
>
>
>
>
> ___________________________________________________________
> Gesendet von Yahoo! Mail - Jetzt mit 250MB Speicher kostenlos - Hier
> anmelden: http://mail.yahoo.de
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@ati.com
> To unsubscribe send a blank email to %%email.unsub%%

Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

---------------------------------
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.

“Bruce Raynold” wrote in message news:xxxxx@ntdev…

So now the code is:

unsigned char echo_reply = “\xfb\xa1\x3d\xd3\x08\x00\x45\x00\xe6\xdc\xd8\xef\x39\x68\xc0\xa8\x05\x00\x61\x62\x63\x64\x65\x66\x6f\x70\x71\x72\x73\x74\x75\x76\x68\x69”;

NdisAllocatePacket(&Status, &MyPacket,Adapter->RecvPacketPoolHandle);
NdisAllocateBuffer(&Status, &MyContent,Adapter->SendBufferPoolHandle, &HighAddress, NIC_BUFFER_SIZE);
NDIS_SET_PACKET_HEADER_SIZE(MyPacket,14);
NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(MyPacket, NULL, 0 );
NDIS_SET_PACKET_STATUS(MyPacket,NDIS_STATUS_RESOURCES);
memset(&MyContent,0,NIC_BUFFER_SIZE);
memcpy(&MyContent,&echo_reply,sizeof(echo_reply));
NdisChainBufferAtBack(MyPacket,MyContent);
NdisMIndicateReceivePacket(Adapter->AdapterHandle, &MyPacket,1);

echo_reply is an sample packet received over network, for testing my driver…

My system freezes after 2-3 seconds or the application that generates the ioctl freezes.
Where is the error?!? :frowning:

First of all, the 35-byte buffer that you are sending doesn’t make sense. Here is a HEX dump:

000000: FB A1 3D D3 08 00 45 00 : E6 DC D8 EF 39 68 C0 A8 …=…E…9h…
000010: 05 00 61 62 63 64 65 66 : 6F 70 71 72 73 74 75 76 …abcdefopqrstuv
000020: 68 69 00 : hi…

It doesn’t look like it includes the 14-byte Ethernet header. A higher-level protocol would interpret the Ethernet header (frist 14 bytes) as:

Ethernet Dest: FB.A1.3D.D3.08.00
Ethernet Src: 45.00.E6.DC.EF.38
Ether Type: 3968

Probably would just be tossed by any protocol that looked at it.

The call to NdisAllocateBuffer seems strange. The fourth paremeter should be a pointer to a non-paged memory array that you have allocated beforehand. How do you allocate the memory at “HighAddress”?

The “NDIS Packet Discussion” ar NDIS.com may help. See:

http://www.ndis.com/papers/default.htm

Good luck,

Thomas F. Divine
http://www.rawether.net