TCP/IP explanation (3) IP: Internet protocol, Chapter 3 notes

Source: Internet
Author: User

I. Introduction:

IP is the most core protocol in the TCP/IP protocol family. All TCP, UDP, ICMP, and IGMP data are transmitted in IP datagram format. Note that the IP address is not a reliable protocol, the IP protocol does not provide a processing mechanism after the data is not transmitted-this is considered an upper-layer protocol-TCP or UDP to do. Therefore, TCP is a reliable protocol, and UDP is not that reliable.

 

Ii. IP header:

The IP datagram format is as follows. The normal IP header is 20 bytes, unless it contains an option field

The 32bit of the four bytes. The first is 0-7bit, 8-15, 16--31.

Service type TOS, where three are priority fields (ignored), and 4-bit TOS respectively represent the minimum latency, maximum throughput, maximum reliability, and minimum cost.

Te l n e t and r l o g I n interaction applications require the minimum transmission latency because they are mainly used to transmit a small amount of interactive data. On the other hand, f t p file transmission requires the maximum throughput. The maximum reliability is specified for network management (S n m p) and routing selection protocols. Usenet News (NNTP) is the only application that requires the minimum cost.

ICMP, IGMP, UDP, and TCP contain both header and data verification code in the header of their lattice.

I c m p, I g m p, U D P and T C P both adopt the same test algorithm, although T C P and U D P besides their header and data, the I p header also contains different fields. The RFC provides the Implementation Technology for how to calculate the I n t e r n e t-test and. Because the router often only modifies the t l field (minus 1), when the router forwards a packet, it can add its test, instead of re-computing the entire I p header. R f c provides a very effective method.

 

Three IP route selection:

When an IP packet is ready, how does the IP packet (or router) Send the packet to the destination? How does it select a proper path for "Shipping?

The most special case is direct connection between the target host and the host, so the host does not need to look for a route, so it is enough to directly pass the data. As for how to directly transfer it, it depends on the ARP protocol, which will be discussed later.

Generally, the host is connected to the target host through several routers. Then, the router needs to find a suitable destination for the IP packet through the IP packet information, such as a suitable host or a suitable route. The router or host will process an IP packet in the following way:

  1. If the TTL (lifecycle) of an IP packet reaches, the IP packet is discarded.
  2. Search the route table and search for matched hosts first. If the target host is exactly the same as the IP address, send the packet to the target host.
  3. Search the route table. If a host fails to match, the router in the same subnet is matched. This requires assistance from the "subnet mask (1.3. If a vro is found, the package is sent to the vro.
  4. Search for the route table. If a vro fails to match the same subnet, The vro matches the same network number (described in Chapter 1). If a vro is found, the package is sent to the vro.
  5. Search for the Land game table. If none of the preceding operations fail, search for the default route. If the default route exists, send the packet
  6. If all of them fail, discard the package.

This once again proves that the IP package is unreliable. Because it does not guarantee delivery.

Each item in the route table contains the following information.

1. Destination IP address

2 next stop Router

3 indicates the network address or host address, and indicates whether the next-Stop router is the real next-Stop router.

4. Specify a network interface for data transmission.

4. subnet addressing:

The IP address is defined as the network number + host number. However, all hosts require subnet addressing. That is to say, the host number is subdivided into subnet number + host number. In the end, an IP address becomes the network number, subnet number, and host number.

 

V. subnet mask:

The subnet mask of the class C address is 255.255.255.0.

The subnet mask of the B-type address is 255.255.0.0.

... And so on

The subnet mask is converted to binary. One represents the network bit and zero represents the host bit.

IP and subnet mask = network number

The IP address and subnet mask are not equal to the host number.

Host number of 2 (Part 0) = number of hosts

The following are two examples:

A. Divide Class B IP address 168.195.0.0 into 27 subnets

Solution 1) 27 convert to binary = 11011

2) the binary is 5 digits, so n = 5

3) set the subnet mask of the Class B address to the first 5 locations 1 of the host address of 255.255.0.0 to obtain 255.255.248.0. This is the subnet mask of the Class B IP address 168.195.0.0 that is divided into 27 subnets.

B. Divide the IP address 168.195.0.0 into several subnets. Each subnet has 700 hosts.

Solution 1) convert 700 to binary = 1010111100

2) the binary number is 10, that is, n = 10.

3) change the last 10 digits of the subnet mask 255.255.0.0 of the B-type IP address to 0 and the subnet mask of 255.255.252.0, that is, 168.195.0.0 of the B-type IP address divided into 700 hosts.

 

Vi. Two names

1 ipconfig/All (Windows), ifconfig (Linux)

2 netstat

 

Summary:

If the target host is directly connected to the network, the datagram is directly sent to the target host; otherwise, the data is sent to the default router. Both the host and vro use the route table for route selection. There are three types of routes in the Table: specific host type, specific network type, and default route type. A table in a route table has a certain priority. When selecting a route, the host route takes precedence over the network route, and the default route is selected only when no other routes are available.
I p route selection is implemented by Hop-by-hop. The destination I P address remains unchanged during the transmission of data packets on different sites, but the encapsulation and destination link layer addresses can be changed on each site. Most hosts and many routers use the default next-Stop router for non-local network datagram.

 

Two questions:

202.105.192.0/24 is not divided into subnets, Class c ip address, subnet mask is 255.255.255.0,/24 is the number of mask digits

Q: The address block allocated to a campus network is 202.105.192.0/18. How many class C Networks does the campus network contain?

Because the second IP address is a class c ip address and the number of mask bits is not 24, the subnet is divided.

1. IP address = network number + subnet number + host number

2. The network number and subnet number are all 1, and the host number is all 0

3. Because the subnet mask bits represent 1

4. Therefore, the subnet COUNT = the subnet mask count (24)-The subnet mask count (18) = 6

5. Therefore, it contains 2 to the power of 6-2 networks, except for the case where all 0 and 1 are involved.

 

Supplement:

Two hosts in the same CIDR Block do not need to communicate through routers. In addition, VLAN and virtual LAN are used.

Take a class c ip address as an example: the subnet mask of the class c ip address is 255.255.255.0

IP address = network number + host number ------ "IP address = network number + network ID + host ID this is when the subnet is divided and VLAN is used. At this time, when two hosts communicate, it is through a vro.

When the mask is 24, no subnet is divided.

When the mask is 26, it is divided into 2 to the power of 2 and 4 subnets. At this time, the number of hosts is 6 to 2.

When the mask is 22, the class C network is divided into the 2nd power, that is, four class C networks (this is not virtual ).

 

 

Related Article

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: info-contact@alibabacloud.com 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.