Computer network Packet parsing

Source: Internet
Author: User
Tags comparison table

Turn http://www.cnblogs.com/jianxinzhou/p/4594027.html1 Introduction

The so-called internetworking is to connect a lot of networks, so how do we deliver packets under such a connected network?

2 IP and Routers1 IP Datagram Header Format

IPAddress: The current IP addresses are 32 bits, called IPV4. ipv6,128 bit will be used in the future.

identification: Router itself will be sealed, after looking up the table, will be packets from a network or port forwarding out, but router around the network is different (for example, from the Ethernet to the WiFi, or from WiFi to Ethernet), note that each network has an important feature called the MTU (maximal transmission Unit), and the MTU specifies the maximum size of packets transmitted over this network. If the packet received by router is too large and is going into a small MTU network, it is inevitable that the packet will be cut and a packet may be cut into several packets. After the packets have been cut, they will eventually be combined, so how do you know which pieces are cut by the same package when the cut pieces are finally assembled? This is the role of identification, the same ID will represent these small fragments originally belong to the same datagram.

Fragment Offset: Datagram is transmitted via IP (Internet protocal) and is only best effort, so datagram may be missing and may be out of order. Therefore, when the datagram is cut into a small fragment into the network, the final destination host receives, the order is not necessarily consistent. All we know is that the fragments received belong to the same IP address and their location (which is the first one?). Which one is in the second? Fragment offset is required to determine that offset is the meaning of the shift, recording the offset of each small fragment relative to the start position in data.

protocal: In the 7-tier architecture of the network, IP is on the third tier, and the Protocal field marks the protocal of the previous layer, which is TCP? Is it UDP?

Time to Live: How long a packet can survive on the Internet, set that time, and avoid having to go around the internet for long-lost packets. Router itself in helping us to transfer the packet, according to the state of the network at any time to adjust the route, there may be a packet through a router to go out, and then back around the situation, the packet may be lost, is constantly wandering, but always around. What should I do if I encounter this situation? It is not possible for us to keep such packets permanently, in case such packets become more and more, eventually exploding our internet plug. Assuming that the value of time to live is set to 128, the value will be reduced by 1,128 for each router pass, which means that after 128 router the value will be reduced to 0, minus 0, and router will discard the packet.

Flags

DF: Can be set datagram is not allowed to be cut during transmission. What if datagram is going to send it out from a port, but the datagram is too big and is told not to be cut? There are only two roads, one is to go the other way, two, if you can not find a datagram to pass through the network, then can only throw away the datagram.

MF: When the destination host receives a small fragment, it is marked as more Fragment, indicating that there is a small fragment behind it.

Total length: The size of the packet.

Header Checksum: The range of headers, such as the part of the red Line circled up.

Make a check of the contents of the header to avoid errors, because do routing. Router received the packet, will be based on the destination IP address to check, to avoid errors, go the wrong way. Therefore, the header has an error and the packet still needs to be discarded.

Version: The revision of the tagged IP. Now the world's most popular IP version is the 4th edition.

Typeof service: indicate what kind of services the package itself should receive. View

The Type of Service itself is a 8-bit field.

Precedence: The meaning of importance. is the generic data packet? Or is it a control packet for the network? The importance of the package itself is set.

Delay: The quality of the service. Whether this packet transfer is a normal delay or a low latency. After the IP packet enters the router, because the router at the same time the amount of packets to be processed is very large (possibly a second millions of or even tens of millions of), even after checking the table, determine from a port, the port processing of the packet volume is still very large, also need to queue up, Once the queue is up, it will cause delay, so if it is a packet of low delay, then the queue may be placed in the front position (it can be said that the meaning of high priority).

Throughput:high throughput often corresponds to low delay.

Reliability:router can throw away the reliability of the normal package first.

2 IP Addresses

The IP address has a total of 32 bits, so there are 2^32 IP addresses, about 4 billion. Because the IP address is allocated, the network is very small, so it is divided into 3 categories:

Class A type: Only 7 bit to represent network, so a total of only 2^7 = 128 Type A network, then a Class A network how big? 2^24 A (large network).

Class B Type: Use 14 bit to represent network, there are 2^14 type B networks worldwide, each Class B network can have 2^16 host (Medium network).

Class C type: With 21 bit to represent the network, a global total of 2^21 Class C networks, each Class C network has 2^8 host (Small Network).

3 How datagrams is delivered in an Internet?

Router when processing a packet, exactly which path the packet is going to take will change according to the status of the network in real time. The Router forwarding table will be updated at any time, with regular or irregular switching networks between router and router. The same source is sent to the same destination, because forwarding table will change, so the path of the packet will be different.

Packets may be cut during the transfer process, and the work of the package assembly will be done by destination.

If the packet is lost during transmission (possibly due to network congestion), then router sends a message telling the source that the packet was discarded, but the source does not retransmit.

Router itself in the processing of the packet, the interior has two important table, one is routing table (also called forwarding table, above the middle left table), and the second is Ip-mac table, Is the comparison table for the IP address and MAC address (above the middle right table).

In, the middle of the router connects 3 networks, the left is LAN 1, the right side is LAN 2, and below is LAN N. LAN 1 has 2 station, one is a, one is host X,lan 2 also has 2 station, one is B, one is host Y. The router on the lower left is connected to LAN 1 and LAN M. The middle of the router LAN 1 IP address is 140.114.77.65, the IP address of LAN 2 is 140.114.78.66.

If B is going to throw a packet to Y (note that both B and Y are connected to LAN 2 at the same time), how will the packet be prepared? First, in the IP datagram, the Source IP address is the IP address of B, the IP address of the Destination IP address y, because B and Y are on the same network, so the packet is not passed through router, directly to the Mac of Y. Such as:

If B is going to throw a packet to a, how is the packet prepared? Since B and a are in different networks, the delivery packets must be router. The Source IP address is the IP address of B, and the IP address of the Destination IP address is a. Which NIC is this packet sent to? It's obviously Mac (B). Since B and a are no longer the same network, the delivery packet must go through router, so the Destina MAC address fills the router Nic location mac (R). Such as:

When B throws the packet into the network, router will receive the packet because it fills in the router MAC address. After router the package, the next thing to do is to look up the table. Because the destination IP is the IP address of a--140.114.77.60, found in routing table 77 This network segment is directly connected with router, so you can send directly to a, but to a, must have a MAC address, which can be by looking for Ip-mac Table. Router sends a packet to a, such as:

Two examples are summarized as follows:

If two hosts in the same network, then do not have to pass the router, you can send the packet directly to the destination, or to router, and then by router forwarding, from the last router dropped to destination.

4 Example

Take a look at the following example:

There are 4 networks: 10.0.0.0, 20.0.0.0, 30.0.0.0, and 40.0.0.0, connected by F, G, h three router. Routing table for G.

If G is to send a packet to 20.0.0.0, the query for direct connection, indicating that 20.0.0.0 and router g directly connected, then router g can be sent directly to the packet (20.0.0.0 this network segment host). Similarly, 30.0.0.0 is directly connected to Router G.

If we receive a packet, the destination is 10.0.0.0 this segment, the list is 20.0.0.5, is not directly connected, that needs to be dropped to the next router,router the corresponding port IP address is 20.0.0.5. Note that not a router an IP address, which is an IP address for each port of router. IP address is not a bound computer, it is bound to port. Each port will have an IP address. Example, Router F connects two networks, the IP address on the left port is 10.0.0.5, and the IP address on the right port is 20.0.0.5.

If we receive a packet, the destination is 40.0.0.0 this segment, the list is 30.0.0.7, is not directly connected, that needs to be dropped to the next router,router the corresponding port IP address is 30.0.0.7.

So how do you produce such a routing table? Router is usually exchanged between the routing protocol through the exchange of information. After such an exchange, Router G knew that there was an F on the left and an h on the right. when there is a routing table, the package comes in to check the table, if directly connected to the destination, if not directly connected to the router. But either to the destination host, or to router, need to know the other side of the MAC address, so router itself also need to look up a table, is the IP address and MAC address table.

5 Summary

Forwarding table maps network number into next hop:forwarding table is routing table, which tells us where the next segment or router is.

Each host has a default router: A default router must be set for each host, so we must enter the computer to set the default router when we operate the pen. If the object of communication is in a different network segment than ours, then we must drop the packet to the default router and throw it to the next router.

Computer network Packet parsing

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.