04 Network Layer Protocols and IP Addressing
04 Network Layer Protocols and IP Addressing
▫ IPv4 is the core protocol in the TCP/IP protocol suite. It works at the network
layer in the TCP/IP protocol stack and this layer corresponds to the network layer
in the Open System Interconnection Reference Model (OSI RM).
▫ For example, after a TCP header is added to the upper-layer data in a PDU at the
transport layer, the PDU is called a segment. The data segment is transmitted to
the network layer. After an IP header is added to the PDU at the network layer,
the PDU is called a packet. The data packet is transmitted to the data link layer.
After the data link layer header and tailer are encapsulated into the PDU, the
PDU becomes a frame. Ultimately, the frame is converted into bits and
transmitted through network media.
▫ The process in which data is delivered following the protocol suite from top to
bottom and is added with headers and tails is called encapsulation.
• This presentation describes how to encapsulate data at the network layer. If data is
encapsulated with IP, the packets are called IP packets.
• The IP packet header contains the following information:
▫ Header Length: 4 bits long, indicating the size of a header. If the Option field is
not carried, the length is 20 bytes. The maximum length is 60 bytes.
▫ Type of Service: 8 bits long, indicating a service type. This field takes effect only
when the QoS differentiated service (DiffServ) is required.
▫ Total Length: 16 bits long. It indicates the total length of an IP data packet.
▫ Fragment Offset: 12 bits long. This field is used for fragment reassembly.
▫ Don't Fragment: Value 1 indicates that fragmentation is not allowed, and value 0
indicates that fragmentation is allowed.
▫ More Fragment: Value 1 indicates that there are more segments following the
segment, and value 0 indicates that the segment is the last data segment.
• Fragment Offset: 12 bits long. This field is used for fragment reassembly. This field
indicates the relative position of a fragment in an original packet that is fragmented.
This field is used together with the More Fragment bit to help the receiver assemble
the fragments.
• Time to Live: 8 bits long. It specifies the maximum number of routers that a packet can
pass through on a network.
▫ When packets are forwarded between network segments, loops may occur if
routes are not properly planned on network devices. As a result, packets are
infinitely looped on the network and cannot reach the destination. If a loop
occurs, all packets destined for this destination are forwarded cyclically. As the
number of such packets increases, network congestion occurs.
• The field may identify a network layer protocol (for example, ICMP of value 0x01) or
an upper-layer protocol (for example, Transmission Control Protocol [TCP] of value
0x06 or the User Datagram Protocol [UDP] of value 0x11).
• On an IP network, if a user wants to connect a computer to the Internet, the user
needs to apply for an IP address for the computer. An IP address identifies a node on a
network and is used to find the destination for data. We use IP addresses to implement
global network communication.
• Note: The interface that needs to use an IP address is usually the interface of a router
or computer.
• IP address notation
▫ The IP address format helps us better use and configure a network. However, a
communication device uses the binary mode to operate an IP address. Therefore,
it is necessary to be familiar with the decimal and binary conversion.
▫ 00000000.00000000.00000000.00000000–
11111111.11111111.11111111.11111111, that is, 0.0.0.0–255.255.255.255
• An IPv4 address is divided into two parts:
▪ Network devices with the same network ID are located on the same
network, regardless of their physical locations.
▫ The network mask is not an IP address. The network mask consists of consecutive
1s followed by consecutive 0s in binary notation.
▫ Generally, the number of 1s indicates the length of a network mask. For example,
the length of mask 0.0.0.0 is 0, and the length of mask 252.0.0.0 is 6.
▫ The network mask is generally used together with the IP address. Bits of 1
correspond to network bits in the IP address. Bits of 0 corresponds to host bits in
the IP address. In other words, in an IP address, the number of 1s in a network
mask is the number of bits of the network ID, and the number of 0s is the
number of bits in the host ID.
• A network ID indicates the network where a host is located, which is similar to the
function of "Community A in district B of City X in province Y."
• A host ID identifies a specific host interface within a network segment defined by the
network ID. The function of host ID is like a host location "No. A Street B".
• Network addressing:
• Gateway:
• Broadcast address
• Available address
▫ Given that the host part of a network segment is n bits, the number of IP
addresses is 2n, and the number of available IP addresses is 2n – 2 (one network
address and one broadcast address).
• Network address: After the host part of this address is set to all 0s, the obtained result
is the network address of the network segment where the IP address is located.
• Broadcast address: After the host part of this address is set to all 1s, the obtained
result is the broadcast address used on the network where the IP address is located.
▫ Public IP address: A network device connected to the Internet must have a public
IP address allocated by the IANA.
• Therefore, subnetting can be used to reduce address waste through the variable length
subnet mask (VLSM) technology. A large classful network is divided into several small
subnets, which makes the use of IP addresses more scientific.
• Assume that a class C network segment is 192.168.10.0. By default, the network mask
is 24 bits, including 24 network bits and 8 host bits.
• Subnet bit: The value can be 0 or 1. Two new subnets are obtained.
▫ 192.168.1.0/28
▫ 192.168.1.16/28
▫ 192.168.1.32/28
▫ 192.168.1.48/28
▫ 192.168.1.64/28
▫ 192.168.1.80/28
▫ 192.168.1.96/28
▫ 192.168.1.112/28
▫ 192.168.1.128/28
▫ 192.168.1.144/28
▫ 192.168.1.160/28
▫ 192.168.1.176/28
▫ 192.168.1.192/28
▫ 192.168.1.208/28
▫ 192.168.1.224/28
▫ 192.168.1.240/28
• To improve the efficiency of IP data packet forwarding and success rate of packet
exchanges, ICMP is used at the network layer. ICMP allows hosts and devices to
report errors during packet transmission.
• ICMP message:
▫ ICMP messages are encapsulated in IP packets. Value 1 in the Protocol field of
the IP packet header indicates ICMP.
▫ Explanation of fields:
▪ The format of an ICMP message depends on the Type and Code fields.
The Type field indicates a message type, and the Code field contains a
parameter mapped to the message type.
▪ The Checksum field is used to check whether a message is complete.
▪ A message contains a 32-bit variable field. This field is not used and is
usually set to 0.
− In an ICMP Redirect message, this field indicates the IP address of
a gateway. A host redirects packets to the specified gateway that
is assigned this IP address.
− In an Echo Request message, this field contains an identifier and a
sequence number. The source associates the received Echo Reply
message with the Echo Request message sent by the local end
based on the identifiers and sequence numbers carried in the
messages. Especially, when the source sends multiple Echo
Request messages to the destination, each Echo Reply message
must carry the same identifier and sequence number as those
carried in the Echo Request message.
• ICMP redirection process:
1. Host A wants to send packets to server A. Host A sends packets to the default
gateway address that is assigned to the gateway RTB.
2. After receiving the packet, RTB checks packet information and finds that the
packet should be forwarded to RTA. RTA is the other gateway on the same
network segment as the source host. This forwarding path through RTA is better
than that through RTB. Therefore, RTB sends an ICMP Redirect message to the
host, instructing the host to send the packet to RTA.
3. After receiving the ICMP Redirect message, the host sends a packet to RTA. Then
RTA forwards the packet to server A.
• A typical ICMP application is ping. Ping is a common tool used to check network
connectivity and collect other related information. Different parameters can be
specified in a ping command, such as the size of ICMP messages, number of ICMP
messages sent at a time, and the timeout period for waiting for a reply. Devices
construct ICMP messages based on the parameters and perform ping tests.
• ICMP defines various error messages for diagnosing network connectivity problems.
The source can determine the cause for a data transmission failure based on the
received error messages.
▫ If a loop occurs on the network, packets are looped on the network, and the TTL
times out, the network device sends a TTL timeout message to the sender device.
• Tracert is a typical ICMP application. Tracert checks the reachability of each hop on a
forwarding path based on the TTL value carried in the packet header. In a tracert test
for a path to a specific destination address, the source first sets the TTL value in a
packet to 1 before sending the packet. After the packet reaches the first node, the TTL
times out. Therefore, the first node sends an ICMP TTL Timeout message carrying a
timestamp to the source. Then, the source sets the TTL value in a packet to 2 before
sending the packet. After the packet reaches the second node, the TTL times out. The
second node also returns an ICMP TTL Timeout message. The process repeats until the
packet reaches the destination. In this way, the source end can trace each node
through which the packet passes based on the information in the returned packet, and
calculate the round-trip time based on timestamps.
• Physical interface: is an existing port on a network device. A physical interface can be a
service interface transmitting services or a management interface managing the device.
For example, a GE service interface and an MEth management interface are physical
interfaces.
▪ Once a Loopback interface is created, its physical status and data link
protocol status always stay up, regardless of whether an IP address is
configured for the Loopback interface.
▪ The local device directly discards a packet whose destination address is not
the local IP address but the outbound interface is the local Loopback
interface.
• Planning rules: