Is there a way to send raw packet Ethernet to other host via C#? In Windows 7 if it makes difference.
A raw Ethernet packet is the complete Layer 2 network frame that is sent to the physical wire. Sending a frame like this allows you to manipulate the target and source MAC addresses and the Layer 3 protocol fields.
Raw packet is used when you dont have any, the first bytes captured are directly the IPv6 or IPv4 header. Raw IP; the packet begins with an IPv4 or IPv6 header, with the "version" field of the header indicating whether it's an IPv4 or IPv6 header.
The IP_HDRINCL option does the following (from the man page): The IPv4 layer generates an IP header when sending a packet unless the IP_HDRINCL socket option is enabled on the socket. When it is enabled, the packet must contain an IP header. For receiving the IP header is always included in the packet.
Based on suggestion by Saint_pl:
I found probably better solution - similar to SharpPcap. It's Pcap.Net - .NET wrapper for WinPcap. Now I can modify my packets whatever I want.
I have some resources for you that maybe helpful. I don't try that solutions in Windows 7 but maybe it contains some good info to start.
Raw Ethernet Packet Manipulation or mirror on CodeProject
This purpose of this article is to explain how to send a raw Ethernet packet using C# on a Microsoft platform. A raw Ethernet packet is the complete Layer 2 network frame that is sent to the physical wire. Sending a frame like this allows you to manipulate the target and source MAC addresses and the Layer 3 protocol fields.
Also some info on raw sockets (just in case you interesting too):
Client (and Server) Sockets Communication take a look on whole chapter but here key parts:
Not sending packets but maybe interesting: A Network Sniffer in C#, SharpPcap - A Packet Capture Framework for .NET
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With