IPv4 Header
Synchronized Transcript
146 cues indexed • Click dialogue or words to jumpWelcome to Jeremy's IT Lab. This is a free complete course for the CCNA. If you like these videos, please subscribe to follow along with the series.
series. Also, please like and leave a comment, and share the video to help spread this free series of videos. Thanks for your help. help. Also, remember to download and use the Anki flashcards with the link in the description, description, which will help you very much in remembering what you have learned.
Let's get started. get started. In this video, we're going to take a look at the Internet Protocol version 4, known as IPv4 header. This is used at layer 3 to help send data between devices on separate networks, even on other sides of the world over the Internet.
This is known as routing. Originally, I planned this video to be a general introduction to routing, but in the end, I decided to split it up into separate parts.
Let's take a look at what we'll cover in this video. We'll cover the IPv4 packet structure, or more accurately, the IPv4 header, which is used to encapsulate a TCP or UDP segment.
UDP segment. Specifically, we will cover the fields of the IPv4 header. We already looked in detail at two fields of the header, the source and destination IP address fields, but there are quite a few more fields to look at.
look at. And that's all for this video. As I said, I originally planned to make this a long introduction to routing video. video. However, I don't want to make these videos too long.
Already, the shortest videos are at least 30 minutes, which is quite long, I think. So, I decided to split up routing into more videos. This prevents the videos from getting too long, but also lets me go more in depth on each topic.
So, this video will focus exclusively on the fields in the IPv4 header, and then future videos will get more practical with hands-on configuration in the CLI.
the CLI. Since we're going to look at the IPv4 header, let's review its position in a complete frame. complete frame. So, the upper layers of the OSI model prepare some data to be sent to another device.
device. It is encapsulated in a layer 4 header, typically using the TCP or UDP protocols, which we'll talk about in a future lesson.
future lesson. This combination of data plus layer 4 header is called a segment. The segment is encapsulated with a layer 3 header, usually using the Internet Protocol, IP.
This combination of data, layer 4 header, and layer 3 header is called a packet. packet. Then, the layer 2 header and trailer are added, and this is called a frame.
These units are called protocol data units or PDUs. For example, the layer 3 PDU is a packet, and the layer 2 PDU is a frame.
For this lesson, we'll focus on this layer 3 header, as it contains the information that is needed to route this packet to its destination. destination.
Note that since we'll be focusing on layer 3 here, I'll usually be using the term packet, talking about routing packets, rather than frames. than frames.
So, thanks to Wikipedia for this chart of the IPv4 header structure. As you can see, it's a bit more complicated than the Ethernet header. To be honest, I doubt that it will be necessary for you to memorize the exact structure of the header, the size of each field, et cetera, for the CCNA test, but I can't
make any guarantees. I didn't make the test. What I recommend is just getting to know the purpose of each field of the header, which we'll cover now. By the way, if you're wondering how to read this chart, it's left to right, top to bottom.
to bottom. So, this is the first bit of the header, and this is the last bit of the header. So, let's quickly go through each field of the header, so you're familiar with its purpose.
its purpose. First up is the version field of the header. header. Its length is four bits, half of one octet. octet. Its purpose is straightforward.
It identifies the version of IP used. Now, there are only two versions of IP in use. in use. IPv4, IPv4, which is simply identified with a value of four in this field, or 0100 in binary.
binary. The other version is IPv6, which is identified with a value of six, or 0110 in binary. in binary.
Now, you may wonder what happened to IPv5. IPv5. Well, there was an experimental protocol called Internet Stream Protocol, which uses an Internet Protocol value of five, but it was never publicly used.
So, you could say that's the lost IPv5. Now, we're focusing on the IPv4 header, so this field of the header will always have a value of four.
The IPv6 header has a different structure than the IPv4 header. So, if the value of this field is six, the rest of the header will also have a different structure.
different structure. Next up is the Internet Header Length, or IHL field. It's also four bits in length, half of one octet. one octet.
The final field of the IPv4 header, options, is variable in length. So, this field is necessary to indicate the total length of the header.
Here's an important part to remember. This field specifies the length of the header in four-byte increments. For example, if the value in this field is five, 5 * 4 bytes is 20, so that means that the length of the header is 20 bytes.
The minimum value in this field is five, which as I just said is equal to 20 bytes. bytes. That's the length of the IP packet without any IP options at the end.
So, an empty options field. The maximum value is 15, which is the maximum value of 4 bits. As you can see here, the value of the 4 bits are 1 2 4 and 8.
Adding them up results in 15. So, 15 * 4 bytes is equal to 60 bytes. That means the maximum length of the IP options field is 40 bytes.
So, an IPv4 header with no options field is 20 bytes in length. And that's the minimum length of an IPv4 header. header. And an IPv4 header with a maximum length options field, 40 bytes, has a length of 60 bytes.
60 bytes. And that's the maximum length of an IPv4 header. header. Okay, that's the IHL field of the IPv4 header. header. Next is the DSCP field.
DSCP stands for Differentiated Services Code Point. Code Point. And the field's length is 6 bits.
This field is used for QoS, Quality of Service. Service. Basic QoS is a topic on the CCNA. So, I will make a dedicated video about it later.
later. Essentially, it is used to prioritize delay-sensitive data, such as streaming voice and video. If you're loading a webpage and the internet is a little slow, it's not a big deal.
However, if you're having a Skype call and there's terrible delay, or the audio and video keep freezing, it can totally ruin the experience. This field is used to identify which traffic should receive priority treatment.
treatment. Next up is the ECN field, which stands for Explicit Congestion Notification, and has a length of 2 bits. It provides end-to-end notification of network congestion without dropping packets.
packets. Normally in a network, if the network is super busy, if there is congestion, this is signaled by dropping packets. The ECN field provides a way to signal a congested network without dropping packets.
packets. However, this is an optional field that requires both end points, as well as the underlying network infrastructure, to support it.
support it. Next up is the total length field, and its length is 16 bits or two octets, two bytes. two bytes. It indicates the total length of the packet, including the IPv4 header and the encapsulated layer 4 segment, which includes both the layer 4 header
and the data. This is different than the IHL field, which indicates only the length of the IPv4 header itself. This field indicates the length in bytes, not in 4-byte increments like the IHL field.
IHL field. So, a value of 20 in this field simply means 20 bytes. The minimum value in this field is 20, meaning 20 bytes, which is equal to a minimum-sized IPv4 header with no encapsulated data.
encapsulated data. The maximum value is 65,535, which is the maximum value of 16 binary bits all set to one.
Let me just show you that calculation. Here are 16 bits, two octets, all set to one. one. The first bit is equal to one, then two, then four, eight, 16,
32, 64, 128. This is as far as we went when looking at a single octet in an IPv4 address. If you extend beyond eight bits, the value keeps doubling.
Next is 256, 512, 512, 1,024, 1,024, 2,048, 2,048, 4,096, 4,096, 8,192, 8,192, 16,384, 16,384, and then the 16th bit is
32,768. Add those all up and you get 65,535, the maximum length of an IPv4 packet.
Next up is the identification field, which is also 16 bits in length. If a packet is fragmented due to being too large, this field is used to identify which packet the fragment belongs to, so it can be reassembled again to make the original packet.
All fragments of the same packet will have their own IPv4 header with the same value in this field, so they can be reassembled later. reassembled later.
Packets are fragmented if larger than the MTU, which stands for a maximum transmission unit. transmission unit. The MTU is usually 1,500 bytes.
Remember the maximum size of an Ethernet frame? frame? I mentioned that the maximum payload size of an Ethernet frame is 1,500 bytes.
So, these are related. And one last point, fragments are reassembled by the receiving host. Next is the flags field, which is three bits in length.
It is used to control and identify fragments. fragments. There are three bits and they function like this. The first bit, bit zero, is reserved and always set to zero.
Bit one is the don't fragment or DF bit. If it is set to one, it means that the packet should not be fragmented.
Bit two is the more fragments or MF bit. It is set to one if there are more fragments in the packet, and then set to zero for the last fragment.
Also, if the packet is a whole unfragmented packet, the MF bit is set to zero since there are no fragments.
Next we have one more field related to packet fragmentation. That is the fragment offset field, which is 13 bits in length.
in length. This field is used to indicate the position of the fragment within the original unfragmented IP packet. This allows fragmented packets to be reassembled even if the fragments arrive out of order since this field lets the receiver know the original order of the fragments.
fragments. Next up is the time to live field, which is eight bits in length. A router will drop a packet with a TTL of zero.
of zero. So, this field is used to prevent infinite loops. If a poor routing configuration causes a packet to be continually sent around in a loop, never reaching its intended destination, destination, if enough traffic like that accumulates, it could cause network congestion and eventually failure.
This feature prevents that from happening, happening, causing looped traffic to be dropped when the TTL reaches zero. This feature was originally designed to indicate the packet's maximum lifetime in seconds.
In practice, however, this actually indicates a hop count. Each time the packet arrives at a router on the way to its destination, the router decreases the TTL by one until the packet reaches its destination or the TTL reaches zero and the packet is dropped.
is dropped. The current recommended default TTL is 64. 64. Next up is the protocol field, which is also eight bits in length.
It indicates the protocol of the encapsulated layer 4 PDU. Typically, this will be one of the following: following: TCP, which is indicated by a value of 6, or UDP, which is indicated by a value of 17.
17. I haven't talked about TCP and UDP yet, but I will make a dedicated video about them later. them later. For now, try to remember the protocol numbers of 6 for TCP and 17 for UDP.
You might also see a value of 1, which is used for ICMP, the protocol ping uses. uses. Another one to remember is 89, which is OSPF, which stands for Open Shortest Path First.
Path First. OSPF is a dynamic routing protocol, which allows routers to learn routes to destinations from their neighbors without us having to manually configure the routes.
the routes. We will cover OSPF in depth in this course. course. So, for now, just try to remember the protocol number of 89. If you're curious, you can check a list of protocol numbers at this page on Wikipedia.
Wikipedia. Don't worry about memorizing any others, but try to remember these four. The included flash cards are extremely useful for remembering little facts like these.
these. Next is the header checksum field, which is 16 bits in length. It is a calculated checksum used to check for errors in the IPv4 header.
When a router receives a packet, it calculates the checksum of the header and compares it to the one in this field of the header. If the newly calculated checksum and the checksum in the IPv4 header do not match, it means that an error has occurred in transmission, so the router
drops the packet. Note that this is only used to check for errors in the IPv4 header, not in the encapsulated data. encapsulated data.
IP relies on the encapsulated protocol to do that. Both UDP and TCP, the two layer four protocols most likely to be encapsulated, have checksum fields to check for errors in the encapsulated data.
data. Okay, next up are the source and destination IP address fields, which I covered in detail already. As you already know, they are 32-bits in length each, as that is the length of an IPv4 address.
IPv4 address. The source IP address field indicates the IPv4 address of the sender of the packet. packet. The destination IP address field indicates the IPv4 address of the intended receiver of the packet.
Finally, the options field, which is optional and can be zero bits in length if not used, or up to 320 bits, 40 bytes in length.
This field is rarely used. However, if the IHL, Internet Header Length field is greater than five, it means that options are present.
are present. Here is a chart from Wikipedia showing the structure of the options field. You can check it out or read more online if you're interested. you're interested.
But for the purposes of CCNA studies, I don't think you need to worry about it. Okay, now we've covered all of the fields of the IPv4 header.
It's a bit more complicated than the simple Ethernet header and trailer we already learned about, but hopefully you understand the purpose of each field now. For the purpose of the CCNA, I think the information presented in this video is sufficient.
But of course, feel free to read more. A simple Google search will give you many good resources. resources. Also, don't forget to use the Anki flash cards to help you remember everything.
Now let's go in depth and analyze a packet capture from Wireshark. I showed you Wireshark before and it's an extremely useful tool both for learning and also in the real world to troubleshoot problems.
This isn't a Wireshark course, but I will show you Wireshark at various points in this course. And if you have a lab with real Cisco equipment or a virtual lab using GNS3, I highly recommend you use Wireshark to examine network traffic like this.
It will really help you in your studies. But in either case, I will show you Wireshark packet captures in this course. course. So, don't worry if you aren't able to use it yourself.
So, I sent a ping between two routers. Notice under the info column it says echo ping request. I have selected the frame here, meaning the entire frame, and you can see down here that the entire frame is highlighted.
These digits are a hexadecimal representation of the frame. Now I highlighted the Ethernet header and down at the bottom you can see only the Ethernet header section of the frame is highlighted.
is highlighted. Then I highlight the IP header and at the bottom only the IP header section of the frame is highlighted. Then I highlight the packet's payload, which is Internet Control Message Protocol, or ICMP, the protocol used by ping, ping, and you can see the payload highlighted
at the bottom. In this video we're focusing on the IPv4 header, header, so let's expand the Internet Protocol version 4 information.
Okay. So, I've expanded the IPv4 header section and zoomed up a bit. And here you can see all of the fields we looked at in this video, except options.
options. As I said, options are rarely used and they aren't in this packet. First up, the version field. And you can see the binary bits 0100 on the left and it shows you that means version 4.
version 4. Next is the header length, which is the IHL field. It has a binary value of 0101, which equals 5.
Remember, this field indicates the length in units of 4 bytes. So, this value of 5 means a header length of 20 bytes.
That is the minimum header length. And it is the length of an IPv4 header with no options field. Next up is the differentiated services field.
field. And as you can see, Wireshark categorizes both the DSCP, differentiated services code point, and ECN, explicit congestion notification fields under this section.
Both are set to zero as they are not being used. being used. Next up is the total length. This represents the total length of the IP packet in bytes, including both the header and the ICMP data it encapsulates.
So, this 100 means that the total length is 100 bytes. Next is the identification field. This packet has an identification field of 5.
of 5. It's not fragmented, but if it were fragmented, the other fragments belonging to this packet would also have a value of 5 here.
Next up is the flags field. Notice that Wireshark also includes the fragment offset field under this section. section.
The reserved bit is always zero. That's what not set means, by the way. I sometimes say set to zero or set to one, one, but another way of saying it is not set, which means zero, or set, which means one.
one. The don't fragment bit isn't set, so this packet can be fragmented if necessary. necessary. The more fragments bit also isn't set, which is expected as the packet isn't fragmented.
fragmented. The fragment offset field is also zero, which is also expected in a packet that isn't fragmented. isn't fragmented. Next is the time to live field, which is set to 255, the maximum.
Remember, the time to live field is eight bits in length, and 255 is the maximum eight-bit value. The protocol is ICMP because I used ping.
ping. Notice the protocol value of one, which indicates this. indicates this. You can see the header checksum here.
Remember, it's a 16-bit value. 0x indicates hexadecimal, and then each hexadecimal digit is equal to four bits. So, 4 * 4 is 16, 16 bits.
Here is the source IP address, and finally, the destination IP address. The standard ping command on a Cisco router will send 100-byte pings, which is why the ping I showed you wasn't fragmented.
wasn't fragmented. But, I pinged once more using this command. command. Ping 192.168.1.2 size 10,000, which will send 10,000-byte pings, much larger than the 1,500 bytes MTU.
MTU. So, this will cause fragmentation. As you can see here, there are a bunch of IP fragments. They all say reassembled in number 13.
What is number 13? Well, it's this ICMP echo request right here. here. Now, let's take a look at some of the IPv4 header fields in these fragments.
Okay, so these are the details of just the first two fragments. First off, notice the total length of 1,500 bytes. 1,500 bytes.
So, this 10,000 byte ping was divided up into 1,500 byte fragments, which is equal to the MTU size. Then, notice the identification field of one.
one. This is different than the last packet I showed you, but notice that the value is the same for these two fragments. Then, take a look at the flags.
Each of them has the more fragments bit set because neither of these is the last fragment in the packet. Also, notice that each of them has a different fragment offset value, and that the first fragment has an offset of zero.
Just one more thing. This time I sent a ping and set the don't fragment bit by adding the DF bit option to the ping command. command.
As you can see here, now the don't fragment bit is set. Because I didn't set the size, the default ping size of 100 bytes was used. So, it was no problem that these packets weren't allowed to be fragmented.
However, if I send pings that are larger than the MTU and set the DF bit, you can see the pings fail. They were too large to be sent unfragmented, but also not allowed to be fragmented.
fragmented. Before moving on to today's quiz, let's review what we studied. We looked at the structure of an IPv4 packet, packet, more specifically, the fields of the IPv4 header.
IPv4 header. That's it. It doesn't look like a lot when you list it like this, but I'm sure you agree that was a lot of information. In the next video, we'll get more practical and hands-on, getting into the CLI to see how to configure routes.
Okay, let's move on to today's quiz. In addition to the quiz, make sure to download and use the Anki flash cards to help you remember all of the details you learned in this video.
Let's get started with question one. What is the fixed binary value of the first field of an IPv4 header? A. 0010 B.
0110 C. 0001 D. 0100 Pause the video to think about your answer.
The answer is D. 0100 The first field of the IPv4 header is the version field. Because the question is about an IPv4 or Internet Protocol version 4 header, the version field is always set to four or
0100 in binary. Let's go to question two. Which field will cause the packet to be dropped if it has a value of zero?
A. TTL B. DSCP C. C. IHL IHL D. ECN Pause the video to think about your answer.
The answer is A. TTL TTL stands for time to live. It is reduced by one at each router the packet passes through.
If it reaches zero, the packet is dropped. dropped. Let's go to question three. How are errors in an IPv4 packet's encapsulated data detected?
A. The IPv4 header checksum field checks for errors. B. The encapsulated protocol, for example TCP or UDP, checks for errors.
C. C. Errors in the encapsulated data cannot be detected. be detected. Pause the to think about your answer.
The answer is B, the encapsulated protocol checks for errors. The IPv4 header checksum field only checks for errors in the IPv4 header itself.
itself. However, layer 4 protocols like TCP or UDP can use their checksum to check for errors in the encapsulated data. Let's go to question four.
Which field of an IPv4 header is variable in length? A, options. B, header checksum.
C, total length. D, D, IHL. IHL. Pause the video to think about your answer.
The answer is A, options. The options field can vary in length from zero bits to 320 bits. The other fields are fixed length.
Although the total length and IHL fields are used to represent the variable length of the IPv4 header and packet, the fields themselves are fixed in length.
length. Let's go to question five. Which bit will be set to one on all IPv4 packet fragments except the last fragment?
fragment? A, A, fragment offset bit. B, more fragments bit. C, don't fragment bit.
D, packet fragment bit. Pause the video to think about your answer.
The answer is B, more fragments bit. The more fragments bit, part of the flags field of the IPv4 header, is used to indicate that the current fragment is not the last fragment of a fragmented packet.
packet. It is set to one on all fragments except the last, which will set it to zero. A, fragment offset, is a 13-bit field in the header, not a single bit.
C, don't fragment bit, is used to prevent a packet from being fragmented. And D, packet fragment bit, is not a real bit in the IPv4 header.
Okay, that's all for the quiz. Remember to use the supplementary materials to help you remember what you studied. studied. There will be Anki flash cards to help you review what you studied.
For a video like this, I think the flash cards are particularly important. So, remember to download and use them. There will be a Packet Tracer lab for routing, but not after this video.
Wait until after day 11's video to get some hands-on practice configuring routing on a Cisco router. Good luck with your studies. Thank you for watching.
Please subscribe to the channel, like the video, leave a comment, and share the video with anyone else studying for the CCNA. the CCNA.
If you want to leave a tip, check the links in the description. I'm also a Brave verified publisher and accept BAT, or Basic Attention Token, tips via the Brave browser.
That's all for now.