The network layer and transport layer of the computer Network (Shehiren) study notes

Source: Internet
Author: User
Tags relative reserved socket port number
Note: This note is written from a programmatic point of view, which is what I think is helpful for programming, not from the perspective of a network expertise.
The following illustration shows the different partitioning of the architecture of the computer: the OSI seven-layer protocol architecture, the architecture of TCP/IP, and the architecture of the five-tier protocol:

The following figure illustrates the changes that the application process's data undergoes during the transfer of the various layers
The following figure shows the method distance for the TCP/IP protocol. Note that routers in the forwarding group when the maximum use of the network layer and wood has the use of transport and application layer is shown below the host C two server processes to A and B of the customer service process to provide services for data exchange in the network established rules, A standard or convention is called a network protocol. The network protocol consists of the following three elements: ①, syntax, data and control information structure or format
②, semantics is what control information needs to be emitted, what action to complete and what response to make
③, synchronization is a detailed description of the sequence of events implementation. PS: Here the synchronization is generalized, that is, under certain conditions what should happen, so synchronization contains the meaning of timing. The most common approach now is to use a network adapter to implement the Protocol's hardware and software for communication. The general adapter includes the data link layer and the physical layer of the two layers of functionality. The following figure shows that data is only considered to flow in the data link layer in the Internet, the Network Layer protocol data unit is an IP datagram or abbreviation for the number of reported, grouped or packets. Each link layer specifies the maximum length of the data portion of the frame, which is the main feature of the MTU packet switching of the maximal transmission unit: Packet switching using store-and-forward technology usually we call the whole piece of data to be sent as a message. Before sending the datagram, the datagram is divided into smaller, equal-length data segments. After each data segment is preceded by a number of necessary control information, a grouping, also known as a "package", is formed. Grouping is a unit of data that is transmitted over the Internet. The following illustration shows the concept of dividing a message into several groupings
The format of the IP datagram Ethernet provides services that are unreliable delivery, that is, making the best effort to deliver. It is up to the upper echelons to determine if the error frame is re-transmitted. There are four protocols that are used with IP protocols: Address Resolution Protocol ARP (addr Resolution Protocol), Inverse Address Resolution Protocol RARP (Reverse address Resolution Protocol), Internet Control Message Protocol ICMP (Internet Controls message Protocol), Internet Group Management Protocol IGMP (Internetwork Management Protocol)
The intermediate device used by the physical layer is called a repeater; the intermediary device used by the data link layer is called a bridge or bridge; the intermediary device used by the network layer is called the router; the intermediary device used above the network layer is called the gateway. PS: Connecting two incompatible systems with a gateway requires a protocol conversion at the top level. Sometimes we call the router using the network layer a gateway. Network bridge is used to extend Ethernet over the data link layer. The bridge works at the data link layer, which forwards and filters the received frames based on the destination address of the Mac frame. The following figure shows that the source and destination addresses of different levels in different tiers are connected by a forwarder or a bridge, and some LANs are still a network because they have the same host number. A LAN with different network numbers must be interconnected using routers. Routers are routed only based on the network number of the destination station's IP address. Routers always have two or more two IP addresses, that is, each interface of the router has a different IP address for the network number. After receiving the IP datagram, the router finds the destination subnet according to the destination network number and subnet number. The IP datagram is delivered to the destination host. The network layer corresponds to the IP; Transport layer corresponds to TCP. The following figure shows the network number field and the host number field in the IP address. IP address addressing has undergone three historical stages: the classification of IP addresses, the division of Subnets, and the formation of an ultra-network. The following figure shows the definition of level two IP address as shown in the figure below for level three IP address
The assigned range of IP addresses shown in the image below is the address used by the data link layer and the physical layer, and the IP address is the address used by the network layer and its upper layers, and is a logical address. The IP address is a logical address because it is implemented with software.
The difference between the IP address and the hardware address shown in the following figure is that only IP datagrams can be seen on the Internet at the IP layer abstraction. At the link layer of the LAN, only Mac frames are visible. Mac frames are routed across different networks. The following image shows the Mac frame format of the Ethernet V2
The slice offset indicates that the longer is the relative position of a piece in the original grouping after the Shard. That is, the slice starts from where it is relative to the starting point of the user data field. The slice offset is offset in eight bytes.
Although all packet forwarding on the Internet is based on the network where the destination host resides, in most cases it is permitted to specify a route for a particular destination host. This route is called a specific host route.
Address Resolution Protocol ARP stores a mapping list of IP addresses to hardware addresses in the host ARP cache, and this map list is updated dynamically. Each host has an ARP cache, There is a map of the IP address of each host and router of the local area network to the hardware address. When the router and neighboring routers exchange information, they must place their network's subnet mask high-speed neighboring routers. The following figure shows how the address Resolution Protocol ARP works
The default subnet mask for Class A addresses is the default subnet mask for 255.0.0.0 Class B addresses is the default subnet mask for 255.255.0.0 Class C addresses is 255.255.255.0. The following illustration shows the default subnet mask for Class A, Class B, and Class C IP addresses end-to-end communication is the communication between application processes. The network layer provides logical communication for the host, while the transport layer provides end-to-end logical communication between the application processes. The transport layer, shown in the following figure, provides logical communication for the application process that communicates with each other
The main differences between the Transport layer protocol and the Network layer protocol shown in the following figure
According to the OSI terminology, the data units transmitted by the two equivalent transport entities during communication are called Transport Protocol data Unit TPDU. However, in TCP/IP, the protocol used is TCP or UDP, which is referred to as TCP or UDP user datagrams, respectively. The header and pseudo header of the UDP User datagram as shown in the following illustration
The port number is concatenated to the IP address, which makes up the socket. The endpoint of a TCP connection is a socket. TCP connects the connection as the most basic abstraction. Each TCP connection is uniquely determined by the two endpoints on each end of the communication, which is a socket.
Some common port numbers are shown in the following figure
The header format of the TCP segment shown in the following illustration
The following figure shows a three-time handshake to establish a TCP connection

The process of releasing a TCP connection as shown in the following illustration
According to the Internet, a network is a collection of hosts with the same network number. Therefore, several LANs connected with forwarders or bridges are still a network, that is, there can only be one network number. We know that the IP address is used at the network layer, but when the data frame is transferred on the link of the actual network, The hardware address of the network must eventually be used.
Below we summarize four typical scenarios for using ARP:
①, the sender is the host, to send the IP datagram to another host on the network. This is the hardware address of the host that is found with ARP.
②, the sender is the host, to send the IP datagram to a host on another network. At this point, ARP finds the hardware address of a router on the network. The rest of the work is done by this router.
③, the sender is the router, to forward the IP datagram to a host on a local network. This is the hardware address of a host on the network that is found with ARP.
④, the sender is the router, to the IP datagram to another network on a host. The hardware address of a router on the network is then found with ARP. The rest of the work is done by this router.
When the router receives a datagram to be forwarded, after the IP address of the next hop router is drawn from the routing table, instead of filling in the IP datagram, the address is sent to the lower network interface software. The network interface software is responsible for converting the IP address of the next-hop router into a hardware address, This hardware address is placed at the header of the Mac frame of the link layer, and then the next hop router is found based on this hardware address.
Dividing the subnet only divides the host number of the IP address, not the original network number of the IP address. The same IP address and different subnet masks can be used to derive the same network location. However, different mask effects are not the same.
No classification addressing CIDR (constituting a network): using the variable eldest son netmask Vlsm can further improve the resource utilization of IP addresses. On the basis of VLSM, the non-classified address method is further researched, and its formal name is the main features of routing Cidr.cidr among non-categorical domains: CIDR eliminates the traditional Class A, class B, and C addresses, as well as the concept of subnetting, thus effectively allocating IPv4 address space and allowing the internet to continue to grow before new IPv6 can be used. Although CIDR does not use subnets, However, because there are still some networks that use subnetting and subnet masks, the address masks used by CIDR can also continue to be called subnet masks.
There are five kinds of ICMP error report messages: One, the end point is not up to two, the source point suppresses three, the time expires four, the parameter question five, changes the route. The format of the ICMP message as shown in the following figure
The following figure shows several commonly used ICMP message types the data field content of the ICMP error message shown in the following illustration from the transport layer perspective, the real endpoint of the communication is not the host but the process in the host. That is, the end-to-end communication is the communication network between the application process to provide logical communication layer host The transport layer provides end-to-end logical communication for the application process.
UDP supports a pair of one or one-to-many, many-to-one, many-to-many communications. The main features of UDP: No connection, near maximum effort delivery, message-oriented. The sender's UDP message to the application is given to the IP layer after the header is added. UDP does not merge or split the incoming messages, but retains the boundaries of the messages.
In the network layer, the inspection and fields in the IP datagram only check the header for a trip error without checking the data section. The transport layer also carries out error detection of incoming messages.
The main features of TCP: protocol for connection-oriented transport layer, point-to-point, reliable delivery service, full-duplex communication, byte-stream oriented. The Transport layer protocol in the TCP/IP system shown in the following illustration
A "stream" in TCP refers to a sequence of bytes that flows into or out of a process. " Byte stream oriented "means that although the application and TCP delivery are a data block of varying size at a time, TCP takes the application's data as a series of unstructured byte streams. TCP does not know the meaning of the stream of bytes being transmitted. The following image shows the concept of TCP-oriented byte-stream "stop waiting" is not sent after a packet is stopped, waiting for the other party to send confirmation. Send the next packet after the acknowledgement is received. Note Three: First, a after sending a packet, You must temporarily keep a copy of a group that has been sent. You can clear a temporarily reserved group copy only after you receive the corresponding confirmation.
Second, grouping and confirming the grouping must be numbered.
The retransmission time of the timeout timer setting should be longer than the average round trip time of the data in the packet transfer.
Through the verification and retransmission mechanism, we achieve reliable communication on unreliable transmission networks. The following figure shows two scenarios that may occur in a stop-wait protocol:
The following figure shows two cases of confirmation of loss and confirmation of lateness in the IP address range, some of the original non-routed addresses are reserved by the IANA, which is the IANA reserved address. These addresses are mainly used for special purposes. Reserved addresses are mainly in the following three categories:
Class A: 10.0.0.0-10.255.255.255 (length equivalent to 1 Class A IP address) Class B: 172.16.0.0-172.31.255.255 (length equivalent to 16 consecutive Class B IP addresses) Class C : 192.168.0.0-192.168.255.255 (length equivalent to 256 consecutive Class C IP addresses)
These addresses are not assigned by the Internet, so they are never routed through the Internet. Although they are not directly connected to the Internet, they can still be used to communicate with the Internet, and people can choose the appropriate address classes as needed.       Use these addresses as public IP addresses on the internal LAN. These addresses are also available on the Internet for devices that do not need to communicate with the Internet, such as printers, manageable hubs, and so on, to conserve IP address resources. Private address: 10.x.x.x, 172.16.x.x-172.31.x.x, 192.168.x.x These addresses are heavily used in the intranet. Some broadband routers also tend to use 192.168.1.1 as the default address. Private networks are not connected to the outside, It is possible to use an arbitrary IP address. This is reserved for use in order to avoid confusion in the future when accessing the public network. Private networks with private addresses when accessing the Internet, use address translation (NAT) to translate the private address into a common legal address. On the Internet, such addresses are not allowed to appear. All routers in the Internet are not forwarded to a datagram where the address is a private address.
The common 192.168.1.2-192.168.1.99 is to manually configure the IP segment, from 192.168.1.100~192.168.1.254 is the IP segment of the DHCP dynamic address when the DHCP server in the network fails or the address is allocated, Or when a DHCP client is not contacted by a DHCP server, the DHCP client automatically configures the network card with an address from the 169.254.0.1-169.254.255.254 address, which is called the Microsoft Automatic Private address. Because the address resource is exhausted, it is not possible to force the address type to be DHCP assigned. The following illustration shows the difference between an IP address switch and a router that is not typically used: the traditional switch is developed from the bridge and belongs to the OSI second layer, the Data link layer device. It is addressed according to the MAC address. The router belongs to the OSI third layer, the network layer device, which is addressed by IP address and generated by routing Table routing protocol. The following figure is a separate grouping of TCP protocols and UDP protocols that I grab using the grab kit

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.