TCP/IP series network layering and data transfer from one host to another

Source: Internet
Author: User

I recently read the TCPIP explanation, a classic book on TCPIP analysis. The examples used in this book are Unix Commands and some tools written by the author using C. I am going to use Java to write some functions introduced in the book to deepen my understanding of the book.

As we all know, the network protocol is layered. Let's first introduce the layer of the TCP/IP protocol stack. t c p/I p is generally considered as a layer-4 protocol system:

1) link layer, also known as data link layer or network interface layer,
It usually includes the device drivers and computers in the operating system.
Network interface card. They work together with the physical interface details of the cable (or any other transmission medium.
2) the network layer, also known as the Internet layer, Processes Group Activities in the network, such as group routing. In
In the t c p/I p protocol family, network layer protocols include I p protocol (Internet Protocol), I c m p protocol (I n t e r n e t Internet Control
Protocol), and I g m p protocol (I n t e r n e t Group Management Protocol ).
3) the transport layer provides end-to-end communication for applications on two hosts. In the t c p/I p protocol family, there are two
Different transmission protocols: t c p (Transmission Control Protocol) and u d p (User Datagram Protocol ).
T c p provides high-reliability data communication for the two hosts. The work it does includes the data points that the application delivers to it.
Send a suitable small block to the following network layer, confirm the group received, and set the timeout clock for the last confirmation group.
. Because the transport layer provides high-reliability end-to-end communication, the application layer can ignore all these details.
On the other hand, u d p provides a very simple service for the application layer. It only refers to the group called a datagram.
A data packet is sent from one host to another, but it is not guaranteed that the data packet can reach the other end. Any required reliability
Must be provided by the application layer.

4) the application layer is responsible for handling specific application details.

The application layer can be considered as a variety of applications, but we often hear such applications as FTP, telnet, and HTTP,
They are called protocols, which define the format order of the exchanged data and act as protocols.
The link layer, network layer, and transmission layer are implemented by the operating system in the kernel. The operating system provides APIs to run in this operating system.
Application on the application layer to call.
For JDK provided by Java, we can only operate on the transport layer. Java can also use an open-source project.
Jpcap is used to access the IP layer and link layer. For C Programming in Unix/Linux
Call the operation to the IP layer and link layer.

Applications on one host need to communicate with applications on the other host. The general process is as follows:
On the sender end, applications at the application layer provide the data to be sent and call the operating system API,
The data is added with the header information shown in. Taking TCP as an example, a TCP header is added to the transport layer to form a TCP segment,
An IP header is added to the IP layer to form an IP datagram, and an Ethernet frame is added at the link layer to form an Ethernet frame.

The operating system calls the NIC Driver to send the Ethernet frame to the network.

At the receiving end, after the data arrives at the host, it is a reverse process. The operating system uses the NIC Driver to obtain the data,
Based on the Ethernet frame, you can know what protocol the previous layer is. After removing the Ethernet head and tail, it is sent to the previous layer. If it is an IP address, it is transmitted to the IP layer.
(ARP and RARP are usually directly processed by the operating system kernel.) The IP layer performs similar processing,
Remove the IP header and send it to the previous layer. The data sent from the sender at the application layer is finally reached.

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.