In this lecture, we'll study about IPv4 Protocol.
First, a little bit on protocol terminology.
One octet is one byte which equals eight bits,
so an octet and a byte are the same thing.
A word is a group of multiple bits.
You will see 16 bit word or
a 32 bit word and things like that in the protocol descriptions.
In addition, a flag is a one bit control function.
And if the flag,
if this one bit is set to one,
we say that the flag is set.
And if the flag is set to zero,
then we say that the flag is clear.
A flag will be used as a control function within the protocol header.
These are used in IPv4 but they're also used in IPv6,
TCP and UDP and other IETF protocols.
IPv4 packet is called a datagram.
And the reason is because a datagram is defined as follows, in RFC 1594,
it is defined as a self-contained independent entity of data carrying
sufficient information to be routed without reliance on any other earlier sent packet.
In other words, we're talking about an independent unit
that has all the control features and functionalities within it,
and also it can be routed independently,
not depending on former packets if they were successfully routed or not.
And that's the definition of a datagram and the IP packet was designed to be that way,
both IPv4 and IPv6.
Looking into the packet structure of IPv4,
there is a header and a payload.
The payload part will include a TCP/UDP header and also the data part,
which is the payload segment part.
The essential functions of IPv4 are inter-Networking and routing.
The IPv4 packet header
contains all required functionalities to deliver an IPv4 packet to its destination,
and that's why it was called a datagram.
The version field tells you what version it is.
And right now, we're looking at an IPv4 packet,
so in the version field it'll have the binary number of four included inside.
And in an IPv6 packet,
it will have six in binary written inside.
Then, there's the IHL,
which is the Internet Header Length, and that's four bits.
It's the length of an IPv4 header in
words and one word here is four octets which is 32 bits.
The minimum value is five.
So the header minimum length is 20 octets.
Then we have the DS and ECN bits.
They are combined as one byte.
First, the DS which stands for Differentiated
Services field is the first six bits.
It distinguishes service priority assignments.
And then we have the ECN which is
Explicit Congestion Notification. These are the two bits.
Now these are used for explicit signaling of congestion in the network to slow down
the speed of packets being transmitted when there is delay or
congestion that is detected within the network.
Then, we have the total length field which is
16 bits and it tells you the total length of the IP packet in units of octets.
It includes the entire IP packet.
Now, because we have 16 bits,
the length that we can indicate with these are two to the power of 16 minus one,
which is 65,535 octets.
Now that's a very very large size.
But, one of the things that you'll see is that we won't
use that entire size, that full size.
The reason is because IPv4 packet size is limited by the layer 2 frame size.
For example, one of the things is the definition of MTU.
It is a maximum size of an IP packet that can be
transmitted without fragmentation over a medium.
Now, for example, if you're using an Ethernet,
well based on the IEEE 802.3 standards,
the size of the MTU is 1500 octets.
And from the positions where you can see that from 46 minimum
to 1500 octets in the payload area is where your IP packet can go into.
So, therefore, in this case the MTU for IPv4 will be 1500 octets.
In the case of Wi-Fi which follows the IEEE
802.11 wireless local area network, wireless LAN standard,
you can see that 2304 octet maximum size MSDU,
MAC Service Data Unit, is the MTU,
and the MPDU, which is the MAC Protocol Data Unit,
this would include the frame control,
duration ID, addresses, MSDU,
and the FCS which would have this type of a structure in an overall Wi-Fi frame.
Then you can see in the part where it's written as frame body,
it can be for a length of
0 to 2304 octets and that's where the IP packet will need to fit in.
So, therefore, in this case the IPv4 packet or
IPv6 packet that will go into a Wi-Fi packet, will have a maximum transfer unit,
MTU, size of 2304 octets.
Looking into the identification field,
which is 16 bits,
this is a sequence number used to uniquely identify the IPv4 packet.
It is used together with the source address,
destination address and the protocol field.
Now, looking down here you can see the flags and the fragment offset.
This is used in packet fragmentation.
It's used to divide a packet if the packet
is too large to pass through a certain network.
Looking into the flags,
there are three bits and only two of the three bits are actually used.
The bit 0 1 on the top is not used. It's reserved.
Bit one is the don't fragment,
and this flag is,
if it's set as one that means do not fragment this IP packet.
However, if it's set as zero,
then you are allowed to fragment the packet if you need to.
Then there's bit two,
which is more fragments.
Now, what this does is,
if you do fragment a packet,
then the preceding part will have this bit set to
one such that it will indicate that there is a following fragment part,
that is going to come after my packet,
after this packet, and that's what this is used to indicate.
Then there is the fragment offset.
Now, this indicates where in the original datagram does this fragment belong to,
and fragments other than the last fragment must contain a data field,
that is a multiple of 64 bits in length.
Looking down over there is the TTL,
the Time To Live.
Now, this specifies the time length
in seconds that a datagram is allowed to remain in the Internet.
Every router that the IP packet passes through
should decrease the TTL by at least one.
TTL is similar to hop count in that term,
and if the TTL field becomes zero
before it reaches the destination, then that packet will be discarded.
We then look at the protocol field.
This identifies the type of the next header in
the packet directly following the IPv4 header.
In other words, this is the header of IPv4.
Now down here, right here,
is where you're going to have your next header.
And then after, even below is going to be where you have your payload data part,
the payload segment part.
Now right over there,
the protocol field will indicate what is
the next header that's going to follow this header that ends right here.
Some of the protocol options are included in this table which
includes TCP and UDP which are the most popular ones.
In addition, you can see ICMP which is Internet Control Message Protocol and
also OSPF which is used to do the routing path set up.
The Header Checksum includes
the error detection code such that the IPv4 packet header is protected,
and it does not protect the payload part of the IP packet.
Errors are checked by the Header Checksum at each router.
And this is because checking is needed because
the fields within the packet do change
and when they change, the Header Checksum is recomputed.
Some of the fields that would change by hop by
hop going through the routers would be like the Time To Live,
which is consistently decreased,
the flags and also the fragmentation options.
Now, looking at the address fields,
the source and destination address of IPv4 are each 32 bits.
There is Classful address where class A,
B, C, D and E do exist.
However, the CIDR, which is
the Classless Inter-Domain Routing notation is used much more popular now these days.
Looking into the details of CIDR,
this is a method to efficiently allocate IP addresses and enable IP routing.
It was introduced by the IETF in 1993,
and it replaces the Classful IP addressing used in the Internet.
So, you will not see any more class A,
B and C type classes used rather
the CIDR notation is what dominates the IP addressing structure these days.
Why was this used?
Well, the typical class A,
B, C type, these classes,
they created subnets that were excessively large,
and they were larger than the number of IP addresses that were needed for that subnet.
Due to this reason,
a lot of them had unused,
reserved, wasted IP addresses.
And because of this problem,
a more efficient subnetting and routing notation was needed,
and this is why CIDR was created.
It makes the Internet more scalable because
networks can be assigned proper subnet sizes.
CIDR enables IPv4 and IPv6 address block allocations to
organizations based on their actual network size and short-term predicted needs.
This can be used to allocate IPv4 and IPv6
address spaces to Internet Service Providers,
as well as end users.
VLSM which stands for
Variable-Length Subnet Masking is a technique that the CIDR notation uses.
Looking into a VLSM example,
you can see this,
where A is 123.234.100.56/24.
This represents the IP address before the slash and then the subnet mask.
The subnet mask is represented by the slash 24 number that you see,
which means that there are 24 ones, right here,
followed by the zeros that you see right here,
and there are eight zeros.
If we were to map them to a decimal number from the binary representation,
it would be the 255.255.255.0.
The subnet size can be directly obtained from this subnet mask structure,
because we know that the IP address is 32 bits,
and we have 24 ones,
so that means two to the power of eight,
which are the number of how many zeros we have right here.
That means that 256 IPv4 addresses are in the subnet.
The routing prefix can also be obtained
directly from the subnet and the CIDR notation.
Because we know the IP address,
we know that the subnet mask is 255.255.255.0, therefore,
we can directly map the two,
look at where the zeros are located,
of the IPv4 address field,
and then we can directly know that the routing prefix is the part
which has the first three bytes which is the 123.234.100.
That would be the prefix part and therefore,
it ends with a .0 at the end.
For CIDR IPv4 and v6 address assignments, the IANA,
the Internet Assigned Numbers Authority,
assigns Regional Internet Registry,
which is RIR, CIDR blocks.
These are assigned to countries and huge territories.
These RIRs are subdivided into LIR,
which are the Local Internet Registry subnets,
which are further subdivided into subnets that fit the local network size.
The options field in the IPv4 header is now what we're going to look into.
This includes the options requested by the sending host computer.
At the end of the option field,
it also includes padding and this is because
we need to make this field right here,
a multiple of 32 bit word.
Therefore, the padding will help to do that.
These are the references that I used and I recommend them to you. Thank you.