//api is the object of CNdisApi
if(api.SendPacketToAdapter(&EthRequest))// returning TRUE here
WriteToLog("Successfully sent Raw UDP");//I can see this
else
WriteToLog("Failed to send Raw UDP");
api.FlushAdapterPacketQueue(hEvent);

I can’t say what exactly may be wrong with your code, proofreading someones code is beyond support obligations, however here is the simple sample code which is confirmed to work:

Your sample code is working infact, I did the same test before I try to send UDP packet it works fine but when I try to send UDP/TCP its not going out.
I suspect I am doing something wrong in following line of code.

iph.ip_len = htons (sizeof(iphdr) + sizeof(udphdr) + datalen);

Is it the correct way of calculating the IP Length?

Is there any chance of other sniffers can sniff the packet and WinPkFilter can’t sniff?
If so, I would like to know in what instance it may happen?

Hi,
If I use this code and trace it using packet sniffer it sends the packets. I am sending the packet to local PC itself. But in the sniffed packet I see Frame check sequence error. Will it create any problem. Can u please tell me why the error occurring ? And what I am missing here ?
Thanks in advance

If I use this code and trace it using packet sniffer it sends the packets. I am sending the packet to local PC itself. But in the sniffed packet I see Frame check sequence error. Will it create any problem. Can u please tell me why the error occurring ? And what I am missing here ?

The code above initializes only Ethernet header and sets next protocol as IP without initializing the IP header. This may cause sniffers to show this packet as a bogus one.

If I use this code and trace it using packet sniffer it sends the packets. I am sending the packet to local PC itself. But in the sniffed packet I see Frame check sequence error. Will it create any problem. Can u please tell me why the error occurring ? And what I am missing here ?

The code above initializes only Ethernet header and sets next protocol as IP without initializing the IP header. This may cause sniffers to show this packet as a bogus one.

Can you please tell me how to set IP header. I tried to create one and send it to my own PC, I am able to sniff it but its not like a typical IP, TCP header packet. Instead it shows as Logical Link Control packet. Can winpkfilter be used to send packet as if it is coming from remote PC ( internet remote host like yahoo ? ) Please please help me out. I am in deep trouble …

Can winpkfilter be used to send packet as if it is coming from remote PC ( internet remote host like yahoo ? )

Sure. The easiest way for you to start is take and parse the normally received packet (intercepted from the network). You can do it with one of the network sniffers (like Network Monitor or Ethereal). Then just build your own packet with WinpkFilter on the same way. Of course it requires some understanding of how TCP/IP works..

Can winpkfilter be used to send packet as if it is coming from remote PC ( internet remote host like yahoo ? )

Sure. The easiest way for you to start is take and parse the normally received packet (intercepted from the network). You can do it with one of the network sniffers (like Network Monitor or Ethereal). Then just build your own packet with WinpkFilter on the same way. Of course it requires some understanding of how TCP/IP works..

Thanks for the reply serpertine, I am able to send the packet to local host it self. But its not TCP/IP packet. It becomes LLC packet. I want to send the packet to my PC itself but as if its coming from remote server with IP, TCP and Ether header. Can I do it using winpkfilter ? If yes how can I do that ?