Raw data with Ethernet

Mar 1, 2011 at 9:32 AM
Edited Mar 2, 2011 at 7:59 PM

I just want to send raw data from ethernet layer, without including upper layer.With reference to the tutorial I created a raw packet and tried to send it using SendPacket, but my system shuts down when the running code reaches the SendPacket line of code.Can anyone help me with this?






Mar 2, 2011 at 8:00 PM

I got it I hadnt framed the packet correctly! THANKS

Aug 8, 2011 at 6:32 PM

Can you please provide a code snippet?  I am trying to do the same thing and getting an error.  Specifically, I am trying to send a raw Ethernet packet that contains:

destination mac,

source mac,

Ethertype/Size - used as size in my case and is always under 300

payload (of length determined by Ethertype field)


An example packet is:


Destination          |    Source           | Len | Payload

Here is my code:


rawPayload = new byte[3] { 0x66, 0x77, 0x88 };
PayloadLayer payload = new PayloadLayer
    Data = new Datagram(rawPayload),

EthernetLayer ethernetLayer = new EthernetLayer
    Source = new MacAddress("00:11:22:33:44:55"),
    Destination = new MacAddress("AA:BB:CC:DD:EE:FF"),

PacketBuilder builder = new PacketBuilder(ethernetLayer, payload);
packet = builder.Build(DateTime.Now);

And here is my error:

{"Can't determine ether type automatically from next layer (PcapDotNet.Packets.PayloadLayer)"}


I am not setting the Ethertype (in this case I want to set it to 3) which is probably my problem.  Trying to figure it out now.  Any suggestions?

Aug 12, 2011 at 6:04 AM

Hi DrCornelius,


If that's what you want, simply set the EtherType to 3 inside the EthernetLayer construction.



Sep 21, 2011 at 5:12 AM

Hi Boaz,


Finally getting back to this, glad I was on the right track.  Per your suggestion, I set Ethertype to the length of the buffer I was using.  For completeness, I added this line:

            ethernetLayer.EtherType = (PcapDotNet.Packets.Ethernet.EthernetType)rawPayload.Length;

before building the packet.


Thanks for the reply.