Introduction to Layer 3 IP protocol and Routing

Source: Internet
Author: User
Tags domain name registration

Over the past 20 years, network technology has continued to develop, from the initial X.25, frame relay, to Ethernet, FDDI, to the popular ATM, different technologies provide diverse network options. To achieve network interoperability among various types of LAN and WAN, you need to use the network protocol.

The network protocol stack used by the Internet not only has low-level protocol specifications, such as TCP and IP protocols, in addition, high-level applications such as object email, analog terminals, and file transmission have also formulated relevant specifications. Shows the relationship between the more important Internet protocol and the OSI reference model.

This article describes TCP, IP, and other related protocols and Protocol use environments. This article focuses on the introduction of the layer-3 IP protocol and routing function, while only a brief description of the layer-4 TCP protocol.

TCP protocol

TCP is a connection-oriented transport layer protocol. By using the serial number and validation information, the TCP protocol can provide the sender with the transfer information of the packets arriving at the receiver. When data packets are lost during transmission, the TCP protocol can resend the lost data packets until the data reaches the receiver or the network times out. TCP can also identify duplicate information and discard unnecessary information to optimize the network environment. If the sender transmits data much faster than the receiver receives the data, the TCP protocol can adopt a data stream control mechanism to slow down the data transmission speed and coordinate the sending and receiving data response. The TCP protocol can transmit data to a higher-level protocol or application.

IP protocol

The IP protocol is located on the third layer of the Internet protocol stack. It was first developed on the UNIX System Platform in 1970. Today, the IP protocol has developed into a standard mechanism for communication between network operating systems, and is the basis of high-level protocols such as HTTP and TCP. In addition to providing network routing, the IP Protocol also provides many functions such as error control and network segmentation, which is the core of the entire Internet protocol stack.

A complete IP address consists of 4 bytes, namely 32-bit numbers. For convenience, IP addresses are often written in a 10-digit format with the symbol ". separate different bytes. For example, a 32-bit IP address is as follows:


In decimal format:

IP addresses can be divided into different classes. The specific network type is determined based on the value of the four leftmost addresses. For example, the value of the leftmost side of all a-class network addresses is 0, while the other 31-bit values can be both 0 and 1. That is:

0 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

(X indicates 0 or 1)

According to the rules of Class A network address, we can calculate that the valid address range of this type of network is from to

The Class B network address must be 1 from left to right, and 0 from the second. The other 30 bits can be taken freely. For example:

10 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Therefore, the valid value range of B-type network addresses is from to 191.20.255. Similarly, except the first one, the second, third, and fourth bits of Class C, D, and E network addresses must be 1. We will summarize the division of IP addresses of different network types in the following table:

Domain Name

Domain names are more convenient and easier to remember. They can uniquely identify any computer on the network. The Internet uses the Domain Name System (DNS) to specify a name for the IP address, and can map and convert between the domain name and IP address based on different commands. The domain name system adopts a hierarchical structure similar to the directory tree. All Domain Name and address information are stored in distributed databases distributed across the Internet.

As a public network Internet, all domain names and addresses must be registered with the authorized domain name registrar before they can be used. Top-level domain names such as. com,. net, and. org can only be registered by registrars with the top-level domain name registration right.

IPv4 and IPv6

Currently, the commonly used IP protocol has become IPv4, that is, version 4. Later versions of IPv6 have already started trial use in a small network environment and will gradually replace IPv4 in the next few years. IPv6 improves the entire Address Allocation System and supports 128-bit (32-byte) Address length, enhancing performance and security.

We already know that IPv4 only supports 32-bit (8 bytes) Address length, so the number of addresses that can be allocated is limited, which is roughly equivalent to 4,294,967,296, that is, the power of 2. Of course, this number was quite impressive when the IP protocol was first used. However, with the explosive growth of computer networks around the world in recent years, the available IPv4 address space has become increasingly limited. Although the virtual address technology similar to the virtual memory of the operating system can be used temporarily, the increasing pressure cannot be mitigated. Therefore, in order to fundamentally solve the problem of insufficient IP address space and provide a broader space for network development, we have improved IPv4 and launched IPv6 with more comprehensive and reliable functions.

Network Address

Due to limitations in the electrical performance of the network cable, the computer network is generally composed of some separate network segments. Vrouters, bridges, and other network devices are used to connect different network segments. In addition to dividing networks physically using network cables, you can also use higher-level software protocols to divide subnets. Subnets can not only correspond to physical network segments, but also can be divided across network segments.

Even if no subnet is divided, the hosts on any IP network belong to a peer-to-peer network determined by the network address (because multiple NICs can belong to multiple peer networks at the same time ). Hosts With the same network address can be located in the same physical network segment or scattered in different places. By combining network addresses, you can easily communicate with each other.

The network address and IP address are very similar, but we cannot confuse them. The network address is determined by the host's IP address and network type. For example, for the host address, the leftmost eight digits represent the network address by default, and the others are 0, that is, the network address is

The following table describes how to divide the network addresses of A, B, and C networks. Because the D and E networks are only used for network management purposes, we will not describe them here.


In addition to the network addresses determined by the host address and network type, the IP protocol also allows you to create sub-networks based on your actual network needs. Combining subnets and network addresses can not only combine hosts in different physical locations, but also improve network security performance by separating key devices or optimizing data transmission, reduces network traffic.

Subnet Mask

One of the most notable features of a subnet is that it has a subnet mask. The subnet mask length is also 32 bits, which can also be in decimal format. For example, the following binary form Subnet Mask


In decimal format:

Mask rules

The subnet mask cannot be used as an IP address or exists independently. It must be used together with an IP address. The subnet mask is used to divide IP addresses to form two parts: the extended network address and the host address.

A valid subnet mask consists of two parts: the expanded network address bit on the left (represented by number 1) and the host address bit on the right (represented by number 0 ). The two subnet masks below are invalid.



The expanded network address consists of the basic network address and the extra subnet address. You can use a subnet address to divide a part of the address space in the host address space as the address of the sub-network. For example, a small enterprise plans to use the Network to establish an enterprise intranet and allocate different network segments to different departments. This requires the use of a subnet mask to divide the network. We already know that this is a class C network and the network address is 24 bits. To segment it, you must require that the number of bits of the network address be expanded to more than 24. For example, if we decide to use the 25-bit subnet mask, two new sub-networks will be created, and the addresses used for hosts will be reduced accordingly. See the following table:

If we take two places in the host address as the subnet mask, we can create four subnets. If we take three places as the subnet mask, we can create eight subnets. You can create a subnet mask based on the number of subnets and determine the number of hosts that can be connected to each subnet.


In some network structures such as Ethernet, two sub-protocols ARP (Address Resolution Protocol) and RARP (Reverse Address Resolution Protocol) in the Internet protocol stack can be used) dynamically obtain the IP address of the network host. ARP can determine the physical layer address (MAC address) corresponding to a network layer IP Address by sending network broadcast information ). RARP is a reverse ARP Protocol. It also determines the network layer IP address corresponding to a hardware address through network broadcast. RARP is especially important for diskless workstation because the network layer address of the local machine is unknown when the diskless workstation system is started, but the IP address corresponding to the hardware layer address of the local machine can be found through RARP.


The Internet is composed of numerous networks, large and small, all over the world. It can transmit data between different networks. As an interface device connecting different networks, vrouters have been widely used. Their main function is to connect multiple independent networks or subnets, achieve optimal path finding and data transmission between the Internet. Depending on the scope of the router, we can divide it into two types: internal router and external router. Internal routers are mainly used for information exchange within the Network (also called Autonomous Systems), while external routers are mainly used for information transmission between networks.

The IP routing protocol is a dynamic protocol that requires the routing device to calculate the route according to the network environment and automatically select the optimal path when the network changes. Unlike dynamic routing, Static Routing requires the network administrator to manually configure route information. When the network environment changes, the Static Routing remains unchanged unless the network administrator changes the route.

Generally, route information is stored in the routing table. Each route entry contains the address of the Target receiver and the address of the next router. Because the network environment is changing anytime, anywhere, it is difficult to predict the complete path of data during transmission, so it is impossible to list all the path information in the route table. Therefore, the route table generally only gives the path of the next vro that can reach the data receiver, so that it can form a continuous relationship between each vro on the network, provides the final complete path for data transmission.

When exceptions occur during the routing process, the IP protocol itself does not provide any error monitoring measures, but the ICMP (Internet Control Information Protocol) is mainly responsible for reporting and handling error situations. The ICMP protocol has multiple functions. In addition to sending route error messages to data senders, it can also detect the accessibility of network nodes (using icmpecho and reply information ), improve routing efficiency (icmpredirect information is used), and remind the sender that the packet exceeds the survival time (icmptimeexceeded information is used. In short, the ICMP protocol is an essential part of the entire IP network, especially for those running vro network environment.

Finally, we will briefly introduce various routing protocols.

Internal Routing Protocol

The internal routing protocol (IGP) is mainly used inside the autonomous system. Currently, IGP commonly used in TCP/IP networks mainly includes the following types:


If you want to talk about the IP network routing protocol, you must not mention rip ). The RIP Protocol was first launched by Xerox in 1980s and was mainly used in a network system developed by Xerox itself. Nowadays, the RIP Protocol has been adopted by many computer networks and has become a basic routing protocol.

Rip is mainly applicable to small-scale network environments. If a large network is used, there are many restrictions. For example, the RIP Protocol specifies that the number of Route hops between any two network hosts (each time a router is used as a hop) cannot exceed 16. In addition, the convergence speed of RIP is very slow, which means that when the network changes, it takes a long time for the changed information to be transmitted to all routers. Finally, rip determines the optimal route by looking at the number of Route hops between the two nodes, without considering other factors such as line speed and usage. As a result, the result is often not the optimal path. Based on the above reasons, many large networks that used the RIP Protocol have gradually switched to other well-developed routing protocols.


IGRP (Internal Gateway Routing Protocol) is an internal routing protocol developed by Cisco in 1980s. It improves some problems in the RIP Protocol. IGRP can determine the optimal path by checking the network bandwidth and latency between routers. The convergence speed of IGRP is significantly faster than that of RIP, so it can effectively avoid routing loops caused by inconsistent routing information. In addition, there is no rip restriction on the route length of IGRP, which is more suitable for those large and complex network topologies.

To better meet the needs of large networks running key tasks, Cisco has enhanced the functions of the IGRP protocol, combining the easy-to-use features of the traditional distance vector routing protocol with the high speed of The Link State routing protocol, the routing information transmission is optimized and the network bandwidth usage is reduced. In addition to IP routing, the enhanced IGRP Protocol also supports appletalk and novellipx routing information.


OSPF (short path Priority Protocol) is introduced by the Internet Engineering Task Group (IETF) to replace rip. OSPF is an Inter-Domain Routing Protocol Based on Link Status and hierarchical structure. It supports hierarchical routing within the autonomous system. The autonomous system can be divided into multiple routing regions. Each routing region is composed of one or more subnets connected to each other and is connected to the main region. In addition, the OSPF protocol supports a variable length subnet latency (vlsm) that provides network address space conversion and bandwidth-based computing.

External Routing Protocol

The external routing protocol provides routes between autonomous systems. The most common types of TCP/IP networks are as follows:


The first generation of the widely used external routing protocol is EGP (external gateway protocol ). EGP can provide dynamic connectivity, but requires that all connected autonomous systems adopt a tree structure, which can still be used in the early stages of Internet development.

Although EGP is a dynamic routing protocol, its design principle is very simple. It does not use any form of measurement standards, so it cannot really make intelligent routing decisions. As the EGP Protocol cannot meet the needs of today's complex networks, it is gradually being replaced by another protocol & #0; BGP.


The BGP protocol has improved many key issues in EGP. Like EGP, BGP is also an Inter-Domain Routing Protocol, mainly used for core vrouters of the network. However, unlike EGP, BGP is designed to work in any network topology to provide more flexible support for the network structure.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.