Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How send raw ethernet packet with C#? [closed]

Is there a way to send raw packet Ethernet to other host via C#? In Windows 7 if it makes difference.

like image 684
Saint Avatar asked Oct 18 '10 22:10

Saint


People also ask

What is raw Ethernet packet?

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.

What is a raw packet?

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.

What is Ip_hdrincl?

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.


1 Answers

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:

  • C# Raw UDP Socket Program Example
  • C# Raw Socket Ping Program Example part A | part B
  • All examples

Not sending packets but maybe interesting: A Network Sniffer in C#, SharpPcap - A Packet Capture Framework for .NET

like image 57
Nick Martyshchenko Avatar answered Sep 17 '22 12:09

Nick Martyshchenko