You are on page 1of 32

Section 7

IPv4 Header Fields 

Before you can send an IP packet, there needs to be a format that all IP devices agree on to
route a packet from the source to the destination. All that information is contained in the IP
header. The IPv4 header is a container for values that are required to achieve host-to-host
communications. Some fields (such as the IP version) are static, and others, such as Time to
Live (TTL), are modified continually in transit.

The IPv4 header has several fields. First, you will learn about these four fields:

 Service type: Provides information on the desired quality of service


 TTL: Limits the lifetime of a packet
Note
The TTL value does not use time measurement units. It is a value between 1 and 255. The
packet source sets the value, and each router that receives the packet decrements the value by
1. If the value remains above 0, the router forwards the packet. If the value reaches 0, the
packet is dropped. This mechanism keeps undeliverable packets from traveling between
networks for an indefinite amount of time.
 Source address: Specifies the 32-bit binary value that represents the IPv4 address of
the sending endpoint
 Destination address: Specifies the 32-bit binary value that represents the IPv4
address of the receiving endpoint

Other fields in the header include:

 Version: Describes the version of IP.


 IHL: Internet Header Length (IHL) describes the length of the header.
 Total Length: Describes the length of a packet, including header and data.
 Identification: Used for unique fragment identification.
 Flag: Sets various control flags regarding fragmentation.
 Fragment Offset: Indicates where a specific fragment belongs.
 Protocol: Indicates the upper-layer protocol that is used in the data portion of an IPv4
packet. For example, a protocol value of 6 indicates this packet carries a TCP
segment.
 Header Checksum: Used for header error detection.
 Options: Includes optional parameters
 Padding: Used to ensure that the header ends on a 32-bit boundary

A subnet mask is a 32-bit number that describes which portion of an IPv4 address
refers to the network ID and which part refers to the host ID.

The subnet mask is configured on a device along with the IPv4 address.

If a subnet mask has a binary 1 in a bit position, the corresponding bit in the address
is part of the network ID. If a subnet mask has a binary 0 in a bit position, the
corresponding bit in the address is part of the host ID.

The figure represents an IPv4 address separated into a network and a host part. In
the example the network part ends on the octet boundary, which coincides with what
you learned about IPv4 address class boundaries. The address in the figure belongs
to class B, where the first two octets (16 bits) indicate the network part, and the
remaining two octets represent the host part. Therefore, you create the subnet mask
by setting the first 16 bits of the subnet mask to binary 1 and the last 16 bits of the
subnet mask to zero.
Notice the prefix /16; it is another way of expressing the subnet mask and it matches
the number of network bits that are set to binary 1 in the subnet mask.

Networks are not always assigned the same prefix. Depending on the number of
hosts on the network, the prefix that is assigned may be different. Having a different
prefix number changes the host range and broadcast address for each network.

Calculating the Network Address


An IPv4 address that has binary zeros in all the host bit positions is reserved for the
network address. The main purpose of the subnet mask is to identify the network
address of a host, which is crucial for routing purposes. Based on the network
address, the host can identify whether a packet's destination address is within the
same network or not.

Given an IPv4 address and a subnet mask, you can calculate the network address
by using the AND function between the binary representation of the IPv4 address
and the binary representation of the subnet mask.

The calculation is performed bit-by-bit following these rules:

 0 AND 0 = 0
 1 AND 0 = 0
 0 AND 1 = 0
 1 AND 1 = 1

The result of the AND operation is the network address of the network on which the
device resides; this is also called the network prefix. You can see that in the network
address, the network part is the same as it is in the original IPv4 address, while the
host bits are all set to zero.

Usually you will use the decimal form of the network address, so you need to
remember the binary to decimal conversion. Look at the figure to remember the
conversion process.
Take a look at the following figure. The top table shows a standard Class C network address
that is not subnetted. The bottom table shows the same address after it is subnetted by
borrowing one host bit. Notice that the prefix length has changed from 24 to 25. The network
IPv4 address itself is unchanged, although it is now considered a subnetwork (subnet) and is
one of two subnets that have been created. The subnet mask has changed from
255.255.255.0 in decimal to 255.255.255.128, because the 128 bit is now turned on in the
last octet.

Each time that a bit is borrowed, the number of subnet addresses increases, and the
number of host addresses that are available per subnet decreases. The algorithm
that is used to compute the number of subnets and hosts uses powers of two.
Therefore, borrowing one host bit enables you to create 2 1 = 2 subnets, borrowing 2
bits gives you 22 = 4 subnets, and so on.

Note
You can use the following formula to calculate the number of subnets that are
created by borrowing a given number of host bits: Number of subnets =
2s (where s is the number of bits that are borrowed)
As the following figure shows, you can also determine how many host addresses are
available per subnet when you borrow a given number of bits. Just like on a network,
two addresses are not available to be used as host addresses on a subnet; they are
used for the address of the subnet itself (with all of the host bits set to 0) and the
directed broadcast address on the subnet (with all of the host bits set to 1). The
figure shows that borrowing 1 bit for subnetting the address in the example leaves 7
bits for hosts.

Note
You can use a formula to calculate the number of host addresses that are available
when a given number of host bits are borrowed: Number of hosts = 2 h – 2 (where h is
the number of host bits that are remaining after bits are borrowed)
The formula to determine the number of hosts for this example is 2 7– 2, which
calculates to 126 host addresses per subnet.

The following figure shows the subnetting of a Class B network address. The top table
shows a network address with the default Class B subnet mask, 255.255.0.0. The second
table shows the same address after it is subnetted by borrowing six host bits. Notice that the
prefix length has changed from 16 to 22. The network IPv4 address itself is unchanged, but
the subnet mask has changed from 255.255.0.0 in decimal to 255.255.252.0.
If a network address is subnetted, the first subnet that is obtained after subnetting
the network address is called subnet zero, because all of the subnet bits are binary
zero. To determine each subsequent subnet address, increase the subnet address
by the bit value for the last bit that you borrowed.

In the following example, 8 bits are borrowed for subnetting the network address,
172.16.0.0/16. The first subnet address is 172.16.0.0/24; this is subnet zero. The last
bit borrowed is the bit with the value of 1 in the third octet, so the next subnet
address is 172.16.1.0/24.
Here is one more example of subnetting the same /16 network address, this time
borrowing 11 host bits for subnetting. The first subnet address is 172.16.0.0/27. The
second subnet address is 172.16.0.32/27 because the last borrowed bit has a value
of 32. Notice that this time, the last borrowed bit is in the fourth octet. Therefore, the
increment of 32 (the value of the last borrowed bit) is first applied in the fourth octet.

Once all the possible subnet addresses in the fourth octet have been calculated in
this manner, you move back into the third octet since you have borrowed bits from
the third octet as well. You can use all the third octet values from 1 to 255 for your
subnet addresses as well.
8.6- TCP/IP port numbers
The DHCP client and the DHCP server exchange the following packets:

1. DHCP Discover: The DHCP client boots up and sends this message on its
local physical subnet to the subnet's broadcast (destination IPv4 address of
255.255.255.255 and MAC address of ff:ff:ff:ff:ff:ff), with a source IPv4
address of 0.0.0.0 and its MAC address.
2. DHCP Offer:The DHCP server responds and fills the yiaddr (your IPv4
address) field with the requested IPv4 address. The DHCP server sends the
DHCP Offer to the broadcast address but includes the client hardware
address in the chaddr (client hardware address) field of the offer, so the client
knows that it is the intended destination.
3. DHCP Request: DHCP Request: The DHCP client may receive multiple
DHCP Offer messages, but chooses one and accepts only the DHCP server's
offer, implicitly declining all other DHCP Offer messages. The client identifies
the server by populating the Server Identifier option field with the DHCP
server's IPv4 address. The DHCP Request is also a broadcast, so all DHCP
servers that sent a DHCP Offer will receive it, and each will know whether it
was accepted or declined. Even though the client has been offered an IPv4
address, it will send the DHCP request message with a source IPv4 address
of 0.0.0.0.
4. DHCP ACK: The DHCP server acknowledges the request and completes the
initialization process. DHCP ACK message has a source IPv4 address of the
DHCP server, and the destination address is once again a broadcast and
contains all the parameters that the client requested in the DHCP request
message. When the client receives the DHCP ACK, it enters the bound state
and is now free to use the IPv4 address to communicate on the network.
R1#sh control-plane host open-ports

To disable http server

R1# no ip dhcp server

R1# sh tcp brief all


ARP
OSPF

 It is a Link-state routing protocol


 Link-state protocols are more scalable
 Each router has a full map of the topology
 Updates are sent when a topology change occures and are reflooded periodically.
 Link-state protocols respond quickly to topoloty changes
 An LSA describes a router and the networks that are connected to the router
 LSA – Link State Advertisement are stored in Link State Database (LSDB)

Show ip ospf neighbour

Show ip ospf database

The benefits of multiple areas in OSPF is, when introduce area borader router (e.g C, D, E) we can do
summarization

ASBR – Autonomous System Boarder Router – a router that is participating in OSPF and some other
exrternal routing procole like BGP
Sh ip ospf int brief

Sh ip protocols

Passive-interface default

No passive-interface e0/0, e0/1

You might also like