Computer network: the network layer IP protocol and (2)

First, subnetting

1. subnetting proposed

The traditional two IP address (network number and host number) design is not reasonable, mainly as follows:
utilization ● IP address space is low, a large number of addresses can not be used is wasted;
● each physical network is assigned a network number will result in the routing table becomes too large, causing performance degradation;
● two address structure is not flexible enough, new equipment before the application can not connect to the Internet IP address access to the Internet governing body.

To solve the above problem, in 1985, RFC-950 standard adds a traditional IP address in the subnet number field , the two IP address is changed to three IP addresses .
This approach is called subnetting ( subnet address / subnet route selection ).

2. The basic idea of ​​subnetting

  1. There are multiple physical network physical network into the unit, you can belong to several subnets ; subnetting is a unit of internal things, the network other than this unit can not see the subnet of the network, the unit is still outside the performance of a network .
  2. Subnetting method borrowed from a number of bits as the number of host IP address subnet numbers (Subnet-ID) , the address becomes two three addresses . Notation as:
    the IP addresses = {<network number> <subnet number> <host number>}.
  3. From all other networks to send data packets to the host of the unit, still looking for the purpose of router based on network number; the router this unit receives the datagram, then add subnet number to find the destination subnet , the packets delivered to the destination host.

3. Subnet Mask

Conventional fixed IP address of the network types, the former eight router to determine the type of IP address, network number obtained. However, subnetting mode, the IP address alone can not determine the host's network number and subnet number. To this end, we need a subnet mask to help determine the subnet mask is an important attribute of a network / subnet.
The subnet mask is a 32-bit length of the binary code. Mask corresponding to the IP address of a portion of a network number and a subnet number , part 0 corresponds to the IP address of the host number . The following is a divided IP address and corresponding subnet Subnet Mask:
Here Insert Picture Description
after obtaining the subnet mask, an IP address into a binary code, and then with the subnet mask for the bit-wise AND operation , can give the corresponding network number and subnet number.

Although there is no mandatory requirement subnet mask 1 must be continuous (ie, subnet numbers must be close to the network number), but generally the use of continuous 1, to avoid errors.

In the routing table, column also corresponds to a new subnet mask stored. Today's standards: All network must use the subnet mask. For the router, the units of each subnet, the router stores its normal network number and a subnet mask of the subnet number +; ordinary network (in other units may be a subnet, but only identify the common router network number), use the default subnet mask , digital network number length of a length equivalent to the network. For example, a class A network default subnet mask is 255.0.0.0.

Because subnetting need to take up space host number, compared to the traditional IP address of a network, increase network flexibility , but reduces the total number of hosts that can be connected .

4. subnet packet forwarding

In the case of the division of subnets, subnet mask, by the introduction of the router packet forwarding algorithm changes are as follows:

  1. From the received header data packet to extract the destination address D
  2. Judging whether or not delivered directly : The router connected directly to the respective subnet mask, and D for the calculation , comparison result matches with the network addresses match the delivery is complete
  3. Determining whether there is a routing table, the destination address D of a particular delivery route , if it is sent to the designated next hop address
  4. Each row in the routing table subnet mask and D AND operation, and determines whether or not the line number corresponding to the matching network; if the matching line is sent to the next hop address
  5. Determining whether the routing table is given a default route , if it is sent to the designated default routing address
  6. Report an error packet forwarding

Second, the structure of super-network

1. No addressing the proposed classification

Subnetting still faces three problems must be solved:
● insufficient balance of various types of addresses, will soon be have been distributed
● sharp increase in Internet backbone routing table entries
● IPv4 address space will eventually be depleted of all

Which, compared to the third question may be suspended, while the first two questions is imminent. To solve the first two problems, the IETF decided to use classless addressing method.
In 1987, RFC-1009 standard proposes using a subnetting the network variable length subnet mask VLSM can further improve the IP address of resource utilization.
On the basis of VLSM, developed a non-classified preparation method, formally known as the Select CIDR Classless Inter-Domain Routing .

2.CIDR address

There are two main features of CIDR:

  1. Eliminate the traditional concept of classes ABC network and subnetting, the IP address is divided into network prefix and host number two parts, become classless two-level address .
    In addition, the use of CIDR slash notation , also known as CIDR notation , written on the back of the IP address " / ", and write digit prefix network share.
    IP addresses = {<network prefix> <host number>} / network prefix digits
    such as (the underlined portion is the draw of the network prefix):
    Here Insert Picture Description
  2. The same network prefix constitute a continuous IP address CIDR address block , only need to know a CIDR address can know the minimum and maximum addresses of the address block.
    The minimum and maximum address above address CIDR address is:
    Here Insert Picture Description

In order to facilitate the routing, CIDR using a 32-bit address mask , the diet may also be referred to as a subnet mask . Back slash notation number is the number of 1s in the address mask.
Although not given subnetting within CIDR 32-bit address, each unit may be used alone but some sub-divided as desired.

3. route aggregation

Since a CIDR address block has an address number, the routing table CIDR address block can be used to find the destination network, this address is called a polymerization route aggregation .
Route aggregation make a routing table showing a plurality of the original route, it is also known configuration over the network . Route aggregation reduces the exchange of information between routers, improving network performance.
Route aggregation Another advantage is that the resources can be more efficiently allocate the IPv4 address may be assigned appropriate size CIDR address block as required. The next classification can only be assigned 8,16,24 addressing long network number. Here is an example CIDR address block allocation: a university needs 800 IP addresses, but also between different address the needs of each department.
Here Insert Picture Description

* CIDR notation is another notation. * The front part of the network prefix, * the part of the host number.

4. The longest prefix match

CIDR makes use, the use of network prefix notation, each item in the routing table network prefix and a next hop address composition. But when the routing table, you may get more than one match result . A plurality of matching results, it should select the longest prefix of the network routing, referred to as longest prefix match , because the longer the network prefix, the smaller its address block, the more specific the corresponding routing. For example:
There is a destination address D IP datagram = 206.0.71.128/25; routing table contains two 206.0.68.0/22 and 206.0.71.128/25; using a corresponding address mask and D after the AND operation, the results obtained with the two network addresses are matched. The longest prefix match principle , should be sent to the IP datagram to the next hop address 206.0.71.128/25.

5. Find a binary clues

As a result of the longest prefix match , the search process becomes more complicated. When the routing table entries a lot, in order to reduce search time, we need good data structures and advanced algorithms. The easiest way is to look for all possible prefixes do the order, but too many times to find this way too slow.
In order to more effectively find, usually the routing table stored In a hierarchical data structure , the top-down to find the most common way is binary look for clues .
IP addresses left to right determines the bit values from the path extending downwardly root node , each path represents the address stored in the routing table . In order to simplify the structure of the binary cues, you can find out the IP address corresponding to each unique prefix : using a unique binary prefix configured clues, and when looking for a unique prefix match.
Here Insert Picture Description
Binary clues maximum depth is 32 , because the IP address of at most 32, in a layer of the corresponding IP address. Unique prefix generally less than 32, often less than the depth of layer 32.
● The IP address is stored in a binary clues rules: the first from the left; if the current position is 0, the next layer of the root node in the lower left or lower right of the root node; the current one, until the last bit unique prefix under construction junction position after the inspection.
● Find the IP address of a rule: check from the far left, and stored in a manner similar to the node binary find clues. If you find a leaf node, we found a unique prefix match with the IP address of the entry ; if less than half-way to find matching nodes, indicating that the address is not binary trail.

Find clues binary steps, only to find unique prefix match rather than match the network prefix . Find unique prefix match the entry , the need to address mask to do once the operation.

Third, the Internet Control Message Protocol

IP protocol for efficient use of network resources, provides unreliable , connectionless of datagram delivery service . IP protocol lacks error control and directory assistance mechanisms .
In order to more effectively forward IP datagrams, RFC-792 standard proposes the use of Internet Control Message Protocol ICMP report, it allows hosts and routers to report errors and provide relevant abnormal situation, and provides a query mechanism is conducive to environmental analysis network and network fault location .
ICMP is a network layer protocol rather than the higher-level protocols.

1.ICMP message format

ICMP packet format is as follows:
Here Insert Picture Description
Type indicates the type of packet; codes providing further information on the type of message; checksum provided throughout ICMP packet checksum.
Data portion including a header and a data error 64Bit reported before, host help determine erroneous datagram.
Four parts to form a complete ICMP packet , and the IP datagram is inserted into the data portion is transmitted.

2.ICMP messages species

There are two ICMP messages: ICMP error reporting packets and ICMP packets inquiry .
Here Insert Picture Description

● ICMP error report message
  1. End unreachable : When a router or host can not deliver the datagram , it sends to the source host endpoint unreachable packets .
  2. Over time : When the router receives survival time (TTL) of 0 to datagram, the datagram is discarded, and the transmission source host more than packets ;
    Further, when the end point does not receive at all within a predetermined period of time a datagram data slice , the slice must discard the received and transmitted more than packets .
  3. Parameter problem : When a router or the destination host has received datagram header field value is incorrect, discards the data packets and sends the parameter problem message .
  4. Change the routing (redirect) : Router to redirect message to the host, the host to know the next time to send data packets to another router, to get a better route .

ICMP error reporting message format:
the first 8 bytes including 4 bytes of uniform field, 1 byte type field, a code field byte and 2-byte checksum field.
Data field is the need for an IP datagram header and error reporting of the first eight bytes.
Here Insert Picture Description
Following situations instead of sending the ICMP error reporting message:
● for ICMP error report message is no longer sent;
● for all fragments of the datagram after the first fragment of the sheet, is not transmitted;
● having a plurality multicast datagrams, do not send;
● datagram with a special address, do not send;

● ICMP packets inquiry
  1. Echo request and answer : ICMP echo request packet is sent to ask the host or router to a particular destination host, the host must receive packets sent ICMP echo reply message ; the message used to test whether the destination is reachable, and understand about its status.
  2. Timestamp request and reply : ICMP timestamp request and reply message is a request for a host or router to answer the current date and time, reply messages, there is a 32-bit field that indicates the January 1, 1900 to the present time a number of seconds; the message for synchronizing and clock time measurement.

Application examples 3.ICMP

PING command : Test connectivity between two hosts.
PING command uses ICMP echo request and reply messages , is an example of the direct use of application layer network layer protocol, not over TCP and UDP transport layer protocol.
The command line may be used PING command, the host will send four ICMP echo request packets , and by a reply message to get timestamp round trip time and statistics :
Here Insert Picture Description
the tracert command : tracing a route packets from source to destination.
tracert command to send a series of IP datagram to the destination host, inside the package is unable to deliver the UDP user datagram (using an illegal port number). It works as follows:

  1. Survival time of the first data packet of TTL set to 1, after the first R & lt router 1 the router decrements the TTL, then the datagram is discarded, the transmission time over the packet ;
  2. Then transmits a second data packet, TTL is set to 2, via the second router R & lt 2 , the datagram is discarded, the transmission time over the packet ;
  3. And so on
  4. Finally, a datagram arrives at the destination host , but the IP datagram carries is unable to deliver the UDP user datagram , the destination host to send endpoint unreachable packets .
  5. The source host sends back an ICMP error reporting message , obtained from the source host to the destination host reaches the routing information , and each router round trip time .

The command line may be used tracert command, the host sends three data packets for the same IP TTL value each are:
Here Insert Picture Description

Published 39 original articles · won praise 4 · Views 2034

Guess you like

Origin blog.csdn.net/weixin_44712386/article/details/105362408