How to add fcs(4 bytes) of ethernet packet using packet builder?

290 views
Skip to first unread message

nagrajs...@gmail.com

unread,
Mar 17, 2016, 3:25:19 AM3/17/16
to Pcap.Net Q&A
I want to send a ethernet packet using pcap as ethernet layer header and payload layer. So I am providing these layers to packet builder. So why it does not calculate the crc of complete packet and add at the end? Or it have to take care manually.
Please find my code below
public override void SendData(EthernetLayer Ethernet, PayloadLayer Payload)
{

try
{
this.builder = new PacketBuilder(Ethernet, Payload);

Packet packet = this.builder.Build(DateTime.Now);
this.communicator.SendPacket(packet);
this.reaceiveDataWaitHandler.Set();

Console.WriteLine(packet.Timestamp.ToString("yyyy-MM-dd hh:mm:ss.fff") + " length:" + packet.Length);

// Print the packet
const int LineLength = 64;
for (int i = 0; i != packet.Length; ++i)
{
Console.Write((packet[i]).ToString("X2"));
if ((i + 1) % LineLength == 0)
Console.WriteLine();
}

}

Boaz Brickner

unread,
Mar 25, 2016, 8:59:31 AM3/25/16
to Pcap.Net Q&A
The Ethernet Frame check sequence (FCS) is added by the Ethernet device.

mmcc...@gmail.com

unread,
Jun 3, 2016, 12:45:27 PM6/3/16
to Pcap.Net Q&A
Boaz,

I am having a similar issue - using NIC card the fcs bytes are not added automatically. Not sure if there is some way to enable hardware to do this, but trying to do in software is causing problems.

If I add those 4 bytes to end of packet and full with appropriate values Payload layer grows by 4 bytes and adjusts Length accordingly. Receiving application is discarding packets, I assume because fcs is not there after reading larger Payload?

Thanks for assistance
mark

Boaz Brickner

unread,
Jun 4, 2016, 2:46:18 AM6/4/16
to Pcap.Net Q&A
Hi Mark,

Can you elaborate what are you trying to achieve and what do you see exactly?
Maybe add sample .pcap so it's easier to understand what's wrong.

Boaz.
Reply all
Reply to author
Forward
0 new messages