IP Header Basics 01-03-2015, 05:47 PM
#1
After writing the TCP header basics thread, I realized that parts of it required the IP header you guys might not already know about, so here it is.
Following are the ability to have option fields, I won't go into them.
ver_len:
4 bit version (usually 0b0100)
4 bit header length:
DSCP_ECN
DSCP added in RFC.2474 that replaces ToS (type-of-service). I don't know very much about DSCP, but you can google it (or read the RFC)
ECN is (not something I really care to talk about, assume these two bits are 0b00, they likely always are anyways).
total_size
the entire size of the packet (not just the fragment)
ident
Ident is 3 bits. The first of which always being 0, and only 1 of the others set.
bit 1: Don't fragment
bit 2: More fragments
makes sense.
fragment_offset
This is where math is involved that I won't play out (just trying to be basic here), it is just the packet's location in relative to the original datagram (all of the shit put together)
TTL
time to live (you here this a lot) it is NOT pronounced time to lieve. Grr that pissed me off in college... Measured in seconds until the packet expires.
Protocol
the type of protocol we are using. There is a list here
Checksum:
A sum of the packet header. For calculation these bits are 0x0000.
Source address:
ip address of the sender.
Destination address:
dest addr (ip)
Any questions? Shouldn't be much, this was intended to be VERY surface level just to get a concept. If anybody wants to elaborate this in another thread that would be really cool.
Code:
struct IPHeader
{
uint8_t ver_len; //both the version and the length
uint8_t DSCP_ECN; //6-bit DSCP (ToS), 2 bit ECN (RFC.3168)
uint16_t ident;
uint16_t total_length;
uint16_t flag_offset; //3-bit flags, 13-bit fragment offset
uint8_t ttl;
uint8_t protocol;
uint16_t checksum;
uint32_t source_addr;
uint32_t dest_addr;
};
ver_len:
4 bit version (usually 0b0100)
4 bit header length:
Spoiler:
DSCP_ECN
DSCP added in RFC.2474 that replaces ToS (type-of-service). I don't know very much about DSCP, but you can google it (or read the RFC)
ECN is (not something I really care to talk about, assume these two bits are 0b00, they likely always are anyways).
total_size
the entire size of the packet (not just the fragment)
ident
Ident is 3 bits. The first of which always being 0, and only 1 of the others set.
bit 1: Don't fragment
bit 2: More fragments
makes sense.
fragment_offset
This is where math is involved that I won't play out (just trying to be basic here), it is just the packet's location in relative to the original datagram (all of the shit put together)
TTL
time to live (you here this a lot) it is NOT pronounced time to lieve. Grr that pissed me off in college... Measured in seconds until the packet expires.
Protocol
the type of protocol we are using. There is a list here
Checksum:
A sum of the packet header. For calculation these bits are 0x0000.
Source address:
ip address of the sender.
Destination address:
dest addr (ip)
Any questions? Shouldn't be much, this was intended to be VERY surface level just to get a concept. If anybody wants to elaborate this in another thread that would be really cool.