Home >Common Problem >What protocol does ip belong to in computer network architecture?

What protocol does ip belong to in computer network architecture?

青灯夜游
青灯夜游Original
2022-08-29 16:12:185550browse

ip belongs to the "network layer" protocol of the computer network architecture. IP refers to the Internet Interconnection Protocol, which is a network layer protocol in the TCP/IP system. It can provide information of various protocols to the transport layer, such as TCP, UDP, etc.; IP information packets can be placed in the link layer through Various technologies such as Ethernet and Token Ring network are used for transmission.

What protocol does ip belong to in computer network architecture?

The operating environment of this tutorial: Windows 7 system, Dell G3 computer.

ip belongs to the "network layer" protocol of the computer network architecture.

IP protocol brief description

IP refers to the Internet Protocol, the abbreviation of Internet Protocol, IP is the entire TCP/IP protocol The core of the family and the foundation of the Internet. IP is located in the network layer of the TCP/IP model (equivalent to the network layer of the OSI model). It can provide various protocol information to the transport layer, such as TCP, UDP, etc.; IP information packets can be placed in the link layer. Transmitted through various technologies such as Ethernet and Token Ring networks.

What protocol does ip belong to in computer network architecture?

The purpose of designing IP is to improve the scalability of the network: first, to solve Internet problems and achieve interconnection of large-scale, heterogeneous networks; second, to segment top-level network applications and the underlying network technology to facilitate the independent development of both. According to the end-to-end design principle, IP only provides a connectionless, unreliable, best-effort packet transmission service to the host.

Although IPV4 will eventually be replaced by IPV6, IPV4 is still the mainstream version of the IP protocol, so we will focus on the IPV4 version. When learning TCP protocol and socket programming, we know that if we want to accurately locate a host in the shared network of the Internet, we must need the IP address of the host. The host has an IP address, but cannot perform routing control (Routing, which means forwarding and grouping data packets). A device such as a router has an IP address and can also perform routing control; we can connect the host to the Internet and routers are called nodes.

For example, we ordinary people only have our own address. If we want to send express delivery to a friend or receive express delivery from someone else, we can only provide the postman with the other party’s address or our own address, that is, we only have the address. logo, but we cannot send express delivery; and the courier is like a router, he also has his own address, and can also receive his private express, but he can also choose different express delivery according to the destination. lines for transportation. The following figure can clearly express the role of the IP protocol in the network environment.

IP protocol header format (IPV4)

Same as learning TCP and UDP protocols before, let’s first introduce the IP protocol header format

We can find that the IP protocol header is very similar to the TCP protocol header. Unless there are special circumstances, both are 20 bytes, so we often put the two together and call them TCP. /IP protocol. Below is a detailed introduction to each field in the IP protocol header:

  • 4-digit version number (Version): used to specify the version of the IP protocol. The version number of IPV4 is 4. If the IP message is the IPV4 version, then the value of this field is 4. Use 4 digits to The logo is 0100. The version number of IPv6 is 6.
  • 4-digit header length (Internet Header Length): Indicates the size of the IP header, The unit is 4 bytes, length * 4 bytes, because this field has a total of 4 bits, so the maximum value of this field is 2^4 - 1, which is 15, so the maximum length of the IP header is 15 * 4, which is 60 bytes; by default, this field is set to 5, so the default IP header is 20 words Festival.
  • 8-digit Type of Service: The first three digits represent priority (deprecated), the 4th digit represents minimum latency, the 5th digit represents maximum throughput, and the 6th digit represents maximum reliability. The 7th digit represents the minimum cost. These four digits conflict with each other and only one can be chosen. It needs to be selected according to different situations. If it is a remote login such as SSH/TELNET, then the minimum delay should be selected. If it is an FTP type program, the maximum throughput should be selected; the 8th bit is a reserved bit and is not currently used. , must be filled in with 0.
  • 16-bit total length (Total Length): Indicates the total number of bytes in the IP header and the data part carried behind it. This field has 16 bits, so the overall maximum length of the IP datagram is 65535 bytes.
  • 16-bit identification (ID): uniquely identifies the message sent by the host. If an IP message is fragmented at the data link layer, then this field in each fragment should have the same value. Help the peer host perform fragmentation and reassembly after reception.
  • 3-bit flag (Flag): The first bit is reserved (reserved means not used now, but will be used in the future if necessary), and must be filled with 0; the second bit is used to indicate whether sharding can be performed, if If it is 0, it can be fragmented. If it is 1, it cannot be fragmented. If an IP packet is prohibited from fragmentation and its length is greater than the MTU (Maximum Transmission Unit, described in detail later), the packet can only be discarded; If the packet is fragmented, if the third bit is 1, it means that it is a packet in the middle of the fragmentation, that is, there will be fragmented packets in the future. If the third bit is 0, it means that this is the last fragment.
  • 13-bit fragment offset (Fragment Offset): This field indicates the offset of the fragment relative to the beginning of the original IP message , which actually means that the current fragment is in the original message At the location, the corresponding value of the first fragment is 0. Since this field has a total of 13 bits, it can represent up to 2^13 or 8192 relative positions. The unit is 8 bytes, so the maximum position can be represented by 8192 * 8 = 65536 bytes.
  • 8-bit Time To Live: The maximum number of message hops for a datagram to reach its destination (Hop, refers to an interval in the network, and IP data packets are forwarded between hops in the network) , usually 64, each time it passes through a route, TTL–, if it has not reached the destination when TTL == 0, then the packet will be discarded. This field is mainly used to prevent routing loops. Data packets are forwarded in a loop, which wastes network resources.
  • 8-bit protocol (Protocol): Indicates what protocol is the upper layer of IP. The well-known TCP, UDP, ICMP, etc. are all in the upper layer of IP.
  • 16-bit header checksum (Header Checksum): Use CRC for verification to identify whether the IP header is damaged. If it is damaged, it will be discarded directly. It only verifies the IP header and does not verify the following content. , because the verification of the content part needs to be considered by the upper transport layer (TCP), and the IP protocol will directly discard the message as long as it finds a problem with the header.
  • 32-bit source IP address (Source Address): Indicates the IP of the sender.
  • 32-bit destination IP address (Destination Address): Indicates the IP of the receiving end.
  • Options field (Options): variable length, up to 40 bytes.
Supplement: Fragmentation and Assembly

MTU (Maximum Transmission Unit) is a concept in the MAC protocol below the IP layer. We can understand the MAC protocol as a physical Some protocols of the layer, which are located in the lower layer of the IP protocol, then when sending data, it is equivalent to User data application layer protocol header (such as HTTP request header) is handed over to the transport layer (such as TCP protocol) as the payload. The TCP protocol then delivers the data transmitted from the application layer of the TCP header to the IP layer, and the IP layer then delivers the TCP message transmitted from the TCP layer in the IP protocol header to the MAC frame. Therefore, each MAC frame is actually the payload of the IP layer in the IP protocol header. The MAC frame has a length limit, so the IP datagram is not required to be sent as long as you want when it is delivered downwards. If the MAC frame requires an MTU of 1500 bytes, and the total length of the IP datagram is 2000 words section, then it is necessary to fragment the original IP data packet into two pieces and send them in sequence. After the peer host receives it, the peer IP layer completes the assembly. We can use the ifconfig command to view the MTU in the Linux environment.

What protocol does ip belong to in computer network architecture?

Fragmentation and assembly are transparent to the upper layer TCP/UDP and the lower layer MAC, that is, neither the upper layer nor the lower layer knows that the IP layer has fragmented the data packet, so the fragmentation and assembly operations will be performed by the sender IP layer and receiver IP layer are completed automatically. However, fragmentation means that one piece of data needs to be converted into multiple groups of data for transmission, and assembly needs to be performed at the opposite end. This will greatly reduce the network transmission efficiency and increase the risk of errors. Therefore, fragmentation should be avoided during the transmission process, that is, Try not to send IP datagrams that exceed the MTU length.

IP address

Definition of IP address:

In IPV4, we use a 32-bit positive integer to represent the IP address. The computer will store the IP address directly in binary, but People are not good at memorizing binary integers, so we use dotted decimal system to record IP addresses: that is, the 32-bit IP address is divided into 4 groups of 8 digits, separated by '.' between groups, and then each group is converted to decimal .

So we can directly calculate that there are up to 2 ^ 32 = 4292967296 IP addresses under the IPV4 standard, but the number that can be used by people is far less than this number. (For example, some IP addresses are reserved for special purposes, and some devices such as routers will occupy multiple IP addresses)

The composition of the IP address:

The IP address consists of The network identifier (network address) and the host identifier (host address) are composed of two parts .

The process of finding an IP address is like traveling to a certain place. For example, if we want to go to Tiananmen Square, it is impossible to take the high-speed train directly to Tiananmen Square. We must first arrive in Beijing (destination network ), and then arrive at Tiananmen (destination host) through transportation in Beijing. Therefore, when we select routing, we should first find the LAN where the target host is located, and then find the target host in the LAN. This method can quickly help us locate the target LAN. Searching for the target host in the LAN is much faster than finding a host in the vast network.

Network ID: Ensure that the two network segments connected to each other have different identities.

Host ID: Ensure that two hosts in the same network segment have different identities.

Division of IP addresses:

IP addresses are divided into five levels, namely Class A, Class B, Class C, Class D and Class E (which have never been used), so currently The only IP addresses we can see are A, B, C, and D. The basis for division is the bits from the 1st to the 4th bit of the IP address.

    Class A address: 0.0.0.0 ~ 127.255.255.255
  • Class B address: 128.0.0.0 ~ 191.255.255.255
  • Class C address: 192.0.0.0 ~ 223.255.255.255
  • Class D address: 224.0.0.0 ~ 239.255.255.255
  • Class E address: 240.0.0.0 ~ 247.255.255.255
When not considering Class E IP addresses, we can find that the bits occupied by the network numbers of Class A, B, C, and D addresses gradually increase, while the bits occupied by the host number is gradually decreasing. This means that among the above four types of addresses, the number of subnets in one type of address is increasing, but the number of hosts that can be connected in the subnet is becoming smaller and smaller. Take an ordinary university in China as an example. There are about 30,000 teachers and students in the school. If everyone has a laptop that needs to be connected to the campus LAN, and some students also have some tablet computers and other terminal devices that need to be connected to the network, then When applying for a network, you should apply for 50,000 to 60,000 IP addresses. If you use Class A addresses, then the 24-digit host number will generate 2^24 = 16777216 IP addresses, which is far more than what is actually needed. If you use Class C Class B address, there are only 2^8 = 256 IP addresses, which is far less than the required IP address, so the most suitable one is Class B address, which has 2^16 = 65536 IP addresses. This example also tells us that there should not be too many IP addresses, which will cause a lot of waste; nor too few, otherwise many devices will be unable to connect to the network.

Introducing subnet masks:
With the development of the Internet, the disadvantages of using the first four digits to classify are beginning to appear: that is, many applicants from subnets will apply. Class B network addresses, because class A cannot be used up at all, and class C is not enough. As a result, the network addresses of Class B were quickly allocated. Applying for a Class A network will waste a lot of IP addresses. In this case,

people have proposed a new division scheme: CIDR (Classless Interdomain Routing)

    Introducing the subnet mask to distinguish the network number and the host number
  • The subnet mask is also a 32-bit positive integer, but it usually ends with a string of 0
  • The IP address and subnet mask are
  • & operated, and the result is the network number
  • The division of the network number and the host number has nothing to do with whether the IP address is Class A, Class B or Class C
Give two examples to help understand the division of network numbers and host numbers through subnet masks

Example 1:
IP addressBinary expression##140.252.20.68
1000 1100 1111 1100 0001 0100 0100 0100
Subnet mask# #255.255.255.01111 1111 1111 1111 1111 1111 0000 0000

After performing a bitwise AND operation on the IP address and subnet mask, we get 1000 1100 1111 1100 0001 0100 0000 0000, and then convert it into a dotted decimal system that is convenient for people to use as 140.252.20.0 , this is the network number of the subnet. And the last 8 bits of its subnet mask are 0. This subnet can represent 2 ^ 8 = 256 hosts, so the address range of this subnet is 140.252.20.0 ~ 140.252.20.255

Example 2:
Binary expression
##IP addressBinary expression140. 252. 20. 681000 1100 1111 1100 0001 0100 0100 0100
## Subnet mask Code##255.255.255.2401111 1111 1111 1111 1111 1111 1111 0000After performing a bitwise AND operation on the IP address and subnet mask, we get 1000 1100 1111 1100 0001 0110 0100 0000
Binary expression
, which is the network number of the subnet, which is also converted into The commonly used dotted decimal is

140.252.20.64, and the last 4 bits of its subnet mask are 0. This subnet can represent 2 ^ 4 = 16 hosts, so the address of this subnet The range is 140.252.20.64 ~ 140.252.20.79Some special IP addresses

Set all the host addresses in the IP address to 0, that is, the LAN The network number, this IP address represents this LAN.

    Set all host addresses in the IP address to 1 to turn it into a broadcast address. This broadcast address can send data packets to all hosts connected to each other on the same link
  • 127. *The IP address is used for local loopback testing, usually 127.0.0.1
  • Private IP address and public IP address
If a university wants to set up a LAN within the campus , only realizes network communication within the campus and does not communicate with any external machine, then theoretically 2^32 IP addresses can be used, because only in this LAN, the same IP address will not appear. However, RFC1918 stipulates the specifications for private IP addresses in establishing a LAN:

10.* The first 8 digits are the network number, and there are 16,777,216 addresses in total

    172.16.*~172.31.* Previous The 12 digits are the network number, with a total of 1,048,576 addresses
  • 192.168.* The first 16 digits are the network number, with a total of 65,536 addresses
  • The IP addresses in the above range are all private IPs. IPs not within the above range are global IP addresses (public IP addresses).
For more related knowledge, please visit the

FAQ

column!

The above is the detailed content of What protocol does ip belong to in computer network architecture?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What format is rmvb?Next article:What format is rmvb?