So, like I said, the DDK provides a suitable NDIS driver for sending raw packets. Well, enough of the background.on to the code. Now I had to interface with the driver from managed C# code. Great, the hard part down right.yeah, that is what I thought too. Luckily, the Windows Driver Development Kits (DDKs) included samples that would accomplish this for me. After some research, I realized that I needed to create a NDIS Protocol Driver (PassThru and Intermediate drivers will also work) to interface with the network adapters at a very low level. The first problem was that Windows does not include a way to programmatically send a raw Ethernet packet. I did a great deal of research online, and did not find a whole lot of info, just a few hints here and there. The sent packet needed to be exactly like the read packet, Ethernet header and all. To do this, I needed to be able to read a raw Ethernet packet (easy) and then write that same raw Ethernet packet (difficult). My goal was to listen for packets on a network interface and send the exact same packet out of the opposite interface, basically a packet repeater. Well, I was trying to create an application (using C#) that would make a typical Windows computer with 2 NICs act as a Layer 2 Network device. You may be thinking, "Why would anyone want to do this?". Sending a frame like this allows you to manipulate the target and source MAC addresses and the Layer 3 protocol fields. A raw Ethernet packet is the complete Layer 2 network frame that is sent to the physical wire.
This purpose of this article is to explain how to send a raw Ethernet packet using C# on a Microsoft platform.