Skip to content
Discussion options

You must be logged in to vote

Yes, you should reserve space for the Ethernet and IP headers.
But you don't fill all of their fields.
You only need to specify source and destination IP addresses.

The other fields are filled in

{
buf = 0;
buf += 4 << 4; // IPv4
buf += 5; // hlen = 5
packet.writeData(ip_start + 0, &buf, 1);
}
{
buf = 0; // DSCP, ECN
packet.writeData(ip_start + 1, &buf, 1);
}
{
buf = 0;
assert(packet.getSize() >= ip_start + 20);
uint16_t size = packet.getSize() - ip_start;
buf = size >> 8;
packet.writeData(ip_start + 2, &buf, 1);
buf = (uint8_t)(…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by overflow218
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants