Uploaded June 2017 | Updated November 2026, 3 hours ago
IP Header: Networking & TCP/IP Tutorial. TCP/IP Explained
TRANSCRIPT:
Today we examine the IP Header in great detail. So 1st lets look at the location of IP in the TCP/IP Stack. We notice that its in the Network Layer, which is layer 3.
Now let’s examine the fields in detail.
Version (4 Bits)
Defines the version of the IP Protocol. Currently version you have mostly vers 4, ie IPv4 with Ipv6 coming in. Vers 6 could totally replace 4, probably around the same time porn is totally eliminated from the internet.
Header Length (4 bits)
This is the total length of the header in 4 byte words (that’s 32 bits for you n00bs). Meaning it points to the beginning of the data.With no options the header length is 20 bytes, so the value of the field is 5 (20 / 4). Add options and guess what: value increases.
Service Type (8 bits)
This was originally TOS, to indicate the QOS (Quality of Service) desired in networks that offer service precedence. So high precedence traffic got the royal treatment. Just for fun they changed it to Differentiated Services, still concerned precedence, but with a different interpretation. But it’s still compatiblewith the original TOS.
Total Length (16 bit)
This is the total length of the IP datagram, in bytes including header and the data. Do the math: 16 bits allows for a total length of up to 65,535. Try sending a 65,000 byte datagram over your production network just for fun
Identification (16 bits)
If the datagram is fragmented, all the fragments will have same unique identification value. This way the receiving end knows that all fragments with same identification value need to be assembled back into one datagram
Flags (3 bit)
Bit 0: Reserved (for what, nobody knows)
Bit 1: Do not Fragment. If set to 1, may not be fragmented. So if MTU is too small, datagram is dropped. Remember MTU = Maximum Transfer Unit
Bit 2: More fragments. If set to 1, then the datagram is not the last fragment
OK, we just came across 2 important terms, Fragmentation & MTU. Let’s discuss them now before proceeding
What’s Fragmentation?
LANs & WANs have a limit on the amount of data that can be carried in a frame (at layer 2), which is usually Ethernet. That limit is called the MTU = Maximum Transfer Unit. But the datagram prepared at the network layer, may be larger the MTU, due to the large amount of that needs to be sent. In this case, the datagram needs to be fragmented to smaller unit before being passed to the data link layer.
Fragmentation offset (13 bits)
Indicates the relative position of each particular frag when a datagram is fragmented. It’s the offset of the original datagram in 8 byte units. Note carefully - 8 byte units. Example - Datagram of 3200 bytes is split into3 frags1st Frag: Carries the 1st 1400 bytes. Being the 1st frag it’s offset is always 0.2nd Frag: Carries the next 1400 bytes. It’s offset is 175. Why? It’s the bytes in theprior frag, divided by 8.Last Frag: Carries the next 800 bytes. It’soffset is 350. Why? It’s the bytes in the prior 2 frags (2800) divided by 8
Time to live (8 Bits)
Prevents the datagram from hanging around endlessly, like unwanted guests, should routing tables get screwy. Each router it hits decrements the TTL by 1, & when TTL gets to 0, the datagram is unceremoniously discarded.
Use of TTL is what makes Traceroute work
Protocol (8 bits)
Defines the upper layer Protocol. A value of 6 indicates TCP sits on top of the IP datagram. Value of 17 indicates UDP. 1 indicates ICMP. There’s over a 100 more, some important, most obscure.
Header checksum (16 bits)
Purpose of checksum is to detect corruption in transit. For IP, the checksum covers the header but not the data. The sender uses analgorithm (one’s complement arithmetic, if you must know) on the header & the result is sent with the packet. Then the receiver uses same algorithm over the header, and comes up with it’s own result result. If the results don’t match the packet is rejected like a geek at senior prom.
Source IP Address (32 bits)
I thought long & hard about how to describe this one. In a stroke of genius I came upwith “the IP address of the source”
It looks like this: 192.168.1.1
Not this: 68-A3-C4-3F-52-53
Destination IP Address (32 bits)
This one should be pretty muchself explantory after reading my brilliant explanation on Source IP address
Options + Padding (32 bits)
Options don’t seem to be used too much solet’s blow it off for now. If your do use em,you add enough padding so that the field is exactly 32 bits.Seems like fertile ground for crafted packethacks
This has been Huckleberry. Please mash down that LIKE button right now before you forget.
IP Header: Networking & TCP/IP Tutorial. TCP/IP Explained
TRANSCRIPT:
Today we examine the IP Header in great detail. So 1st lets look at the location of IP in the TCP/IP Stack. We notice that its in the Network Layer, which is layer 3.
Now let’s examine the fields in detail.
Version (4 Bits)
Defines the version of the IP Protocol. Currently version you have mostly vers 4, ie IPv4 with Ipv6 coming in. Vers 6 could totally replace 4, probably around the same time porn is totally eliminated from the internet.
Header Length (4 bits)
This is the total length of the header in 4 byte words (that’s 32 bits for you n00bs). Meaning it points to the beginning of the data.With no options the header length is 20 bytes, so the value of the field is 5 (20 / 4). Add options and guess what: value increases.
Service Type (8 bits)
This was originally TOS, to indicate the QOS (Quality of Service) desired in networks that offer service precedence. So high precedence traffic got the royal treatment. Just for fun they changed it to Differentiated Services, still concerned precedence, but with a different interpretation. But it’s still compatiblewith the original TOS.
Total Length (16 bit)
This is the total length of the IP datagram, in bytes including header and the data. Do the math: 16 bits allows for a total length of up to 65,535. Try sending a 65,000 byte datagram over your production network just for fun
Identification (16 bits)
If the datagram is fragmented, all the fragments will have same unique identification value. This way the receiving end knows that all fragments with same identification value need to be assembled back into one datagram
Flags (3 bit)
Bit 0: Reserved (for what, nobody knows)
Bit 1: Do not Fragment. If set to 1, may not be fragmented. So if MTU is too small, datagram is dropped. Remember MTU = Maximum Transfer Unit
Bit 2: More fragments. If set to 1, then the datagram is not the last fragment
OK, we just came across 2 important terms, Fragmentation & MTU. Let’s discuss them now before proceeding
What’s Fragmentation?
LANs & WANs have a limit on the amount of data that can be carried in a frame (at layer 2), which is usually Ethernet. That limit is called the MTU = Maximum Transfer Unit. But the datagram prepared at the network layer, may be larger the MTU, due to the large amount of that needs to be sent. In this case, the datagram needs to be fragmented to smaller unit before being passed to the data link layer.
Fragmentation offset (13 bits)
Indicates the relative position of each particular frag when a datagram is fragmented. It’s the offset of the original datagram in 8 byte units. Note carefully - 8 byte units. Example - Datagram of 3200 bytes is split into3 frags1st Frag: Carries the 1st 1400 bytes. Being the 1st frag it’s offset is always 0.2nd Frag: Carries the next 1400 bytes. It’s offset is 175. Why? It’s the bytes in theprior frag, divided by 8.Last Frag: Carries the next 800 bytes. It’soffset is 350. Why? It’s the bytes in the prior 2 frags (2800) divided by 8
Time to live (8 Bits)
Prevents the datagram from hanging around endlessly, like unwanted guests, should routing tables get screwy. Each router it hits decrements the TTL by 1, & when TTL gets to 0, the datagram is unceremoniously discarded.
Use of TTL is what makes Traceroute work
Protocol (8 bits)
Defines the upper layer Protocol. A value of 6 indicates TCP sits on top of the IP datagram. Value of 17 indicates UDP. 1 indicates ICMP. There’s over a 100 more, some important, most obscure.
Header checksum (16 bits)
Purpose of checksum is to detect corruption in transit. For IP, the checksum covers the header but not the data. The sender uses analgorithm (one’s complement arithmetic, if you must know) on the header & the result is sent with the packet. Then the receiver uses same algorithm over the header, and comes up with it’s own result result. If the results don’t match the packet is rejected like a geek at senior prom.
Source IP Address (32 bits)
I thought long & hard about how to describe this one. In a stroke of genius I came upwith “the IP address of the source”
It looks like this: 192.168.1.1
Not this: 68-A3-C4-3F-52-53
Destination IP Address (32 bits)
This one should be pretty muchself explantory after reading my brilliant explanation on Source IP address
Options + Padding (32 bits)
Options don’t seem to be used too much solet’s blow it off for now. If your do use em,you add enough padding so that the field is exactly 32 bits.Seems like fertile ground for crafted packethacks
This has been Huckleberry. Please mash down that LIKE button right now before you forget.


![Three Way Handshake: Networking & TCP/IP Tutorial. TCP/IP Explained .
3 way handshake. Networking & TCP/IP Tutorial. TCP/IP Explained
TRANSCRIPT:
We dive into the TCP three-way handshake.
Most folks can tell you that the three-way handshake is Syn, Syn-Ack, Ack. What does that mean? In this video I’give you all the nitty-gritty details so that you will understand everything you need to know about three-way handshake. Why is it important to understand the three-way handshake? Because it’s really the basis of understanding TCP itself.
At the most basic level what is it the three-way handshake does? It establishes a connection between a client & a server. So when they say that TCP is connection oriented, it is the three-way handshake that creates the connection in the first place. Remember that UDP is not connection oriented so therefore it does not use the three-way handshake
Three-way handshake actually performs 4 specific functions for the TCP. These functions, in no particular order, are:
• is the destination port listening?
• Advertisement of ephemeral ports
• advertisement of ISN’s
• advertisement of window sizes
So in this video is go over in detail each of the 4 functions above and then I’ll do a live demonstration of the three-way handshake in Wireshark.
Let’s start with 1st function of the three-way handshake:
• Is the destination port listening?
In TCP, we have a client host that tries to connect to a server host.
The client always sends the first packet, which is a SYN. If the server is listening on the destination port of the SYN packet, then it will respond with the SYN ACK packet.
If the server is not listening, i.e. the server port is closed, then then it will not respond with SYN ACK and the connection process terminates here.
We go to the next function of the three-way handshake which is:
• Advertisement of ephemeral ports
While IP address tells TCP/IP what host to go to, the port number says where on the host to go to, specifically what application to go to.
There are 2 different types of ports: well-known ports and ephemeral ports.
Examples of well-known ports: port 80 for HTTP, port 443 for HTTPs, & port 23 for Telnet.
If the client wants to connect to a specific Web server, the first packet of the three-way handshake will show a destination port of port 80 & a source port of some random number greater than 1023, such as 12345.
12345 is chosen at random by the client and is called an ephemeral port. The server must be aware of this ephemeral port number to allow it to communicate back to the correct application process on the client
We go to the next function of the three-way handshake which is:
• Advertisement of ISN’s
ISN stands for Initial Sequence Number.
But before we can understand what an initial sequence number is, we need to understand concept of sequence numbers in general.
TCP numbers all data bytes that are transmitted during a connection, and TCP keeps track of the sequence number to maintains its reliability.
However the first sequence number is called an ISN and is randomly generated for security purposes. If security were not a concern, we could simply start counting sequence numbers at zero, in which case this function of the TCP handshake might not be necessary.
So TCP begins counting bytes from the ISN and not zero. To be clear, the sequence number refers to the byte number and not the segment or packet number.
Supposing the ISN were 1147, and the total data to be sent was 5000 bytes, then the bytes would be numbered from 1147 to 6147
Specifically the sequence number for each segment is the number of the first byte of data carried by that segment.
Now working hand-in-hand with the sequence number is an acknowledgment number.
This is used by TCP to acknowledge that it has received data.
Specifically the acknowledgment number defines the number of the next bite that TCP expects to receive.
Note that the acknowledgment is cumulative. This means that TCP takes the number of the last bite that it received, adds one to it then advertises this sum as the acknowledgment number.
With these concepts in mind, this is how the three-way handshake goes:
Segment [1]
the client sends a segment to the server with the SYN flag set. The client generates an ISN at random, and sends it to the server.
Segment[2]
the server responds with the SYN and ACK flags set.
This segment has 2 functions:
1st function is the SYN for communication the other direction. The server uses this segment to initialize the sequence number for numbering the bytes sent from the server to the client.
2nd function is to acknowledge the receipt of the segment from the client, by setting the ACK flag, and generating an acknowledgment number which is the next sequence number it expects to receive from the client.
Check out more of my great TCP/IP & Cyber Security Tutorials:
https://www.youtube.com/playlist?list=PLjXnMD3emuh1QYexMGYGvr_aM0KTnCXFU
… Three Way Handshake: Networking & TCP/IP Tutorial. TCP/IP Explained .](https://i.ytimg.com/vi/XU4X5gVIKFw/mqdefault.jpg)







