TCP/IP: protocol overview

Source: Internet
Author: User
Tags ftp protocol

Introduction

How does the Internet we use every day be structured? How does the world's billions of devices achieve "interconnection"?
Computer network is an indispensable sub-discipline, to understand these seemingly biased "hard" knowledge seems to us to write code does not help, but in-depth exploration of the above two issues for understanding the entire network system has a great help.

First of all, give examples to explain some nouns.

    • Network: I just started to have their own computer, the understanding of the network is the Internet, can open the "Baidu." In fact, in computer science, two (or more computers) logically link together to form a network (logically linked together, the two computers can send some data to each other, two computers like one).
    • Internet: The Internet actually refers to the connection between multiple networks, forming a unified huge network, in the Internet host (computers, mobile phones, etc.) can communicate with each other.

    • Protocol: This is a term that is often encountered in learning computer networks. I've just seen this word in my head. Two people write some articles on paper to sign made his mark. In fact, the protocol is a set of specifications (including how the host connects between hosts, the format of the data sent between hosts, what each byte means, etc.). As to why the agreement is the thing, because the world's billions of devices, operating systems, each network has its own set of transmission rules, then the transmission between the information is not a mess? Therefore, there is an international organization has set up a number of standards to constrain information, information standardization is conducive to dissemination.
    • Rfc:request for comments, request a revised opinion book. This is a series of numbered documents that contain information about the Internet (including specific criteria for various protocols, etc.).

Now let's introduce these four very simple nouns.
When learning network knowledge, you will encounter a lot of nouns, these things are for the specific application of the implementation of the resulting, so in the face of practical problems to explain more easily understand.

Hierarchical model of the Internet

The introduction indicates that the Internet has a wide variety of protocols, which must be adhered to to develop network applications or build networks. To simplify the operation, the Internet is actually layered . Each layer of the Internet corresponds to a lot of protocols, layers and layers are not interfering with each other, hiding the details of various protocols. Can be analogous to write a program when each module has completed different functions, modules and modules do not interfere with each other, only need to provide some interface to communicate.

    • Each layer of the Internet is a module that has its own set of protocols that accomplish specific functions.
    • There is no interference between the layers of the internet and the layers, but there are services between the tiers (that is, the modules and modules reserve some interfaces for communication).

The typical layered model of the modern Internet is divided into five layers, as follows:

The orange-yellow downward arrow indicates that the layer will provide some services down the level. This does not mean that data can only be transferred from the upper layer to the lower layer.

Below we will briefly describe the role of each layer and its corresponding protocol.

Physical Layer

We say that the hosts in the same network are "logically" connected, which means that there is no connection between the two hosts and the data can still be accessed by each other, so there must be a transit station.

There are no lines connected between the hosts. However, either host is connected to the broker (or indirectly).

In fact, the simplest network is formed by connecting two hosts with a medium that can transmit data (twisted pair, cable, or even a wireless wave without solids).

The physical layer is something we can see and feel, and in addition, the physical layer also provides some electrical characteristics (such as high-level representation of 1 or low-level) and so on.

Data Link Layer

We know that the wire can transmit current, assuming that the high level represents 1 low for 0, then the receiver can get a stream of bits.

But how do we explain these bitstream? How many bits count as a group?
This requires some regulation (agreement).
The protocol of the data link layer is above the physical layer and determines the grouping and meaning of the 0,1.

The data link layer has a number of protocols, which are described later in detail.

In the early days, each company had its own way of grouping electrical signals, which was very detrimental to the data interactions between different networks, and later they were phased out and replaced by a rule called the Ethernet protocol . (There are actually some other common protocols that we'll go into in detail in the data link layer).

Ethernet Protocol

The Ethernet protocol specifies that a group of electrical signals be packaged, called frames. Each frame is divided into two sections, as shown in:

    • Head: Frame header, which records information such as sender, recipient, data type, protocol type, and so on.

    • Data: The specific content of the frame

MAC address

As mentioned above, the header of the Ethernet packet contains the information of the sender and the recipient. So, how are senders and recipients identified?
Ethernet specifies that all devices connected to the network must have a "Nic" interface. The packet must be routed from one network card to another. The address of the network card is the sending and receiving address of the packet, which is called the Mac (Media Access Control) address, which translates to the Media control address , and some books also call it an Ethernet address or a physical address.

The MAC address is a total of 48 bits (6 bytes) in hexadecimal notation. The first 24 bits are determined by the IEEE, and the last 24 bits are assigned by the manufacturer who actually produces the network device.

The picture is a network card.

So, theoretically, as long as there is a network card can be assigned to the MAC address (MAC address must be the world's only), can also be networked. (The technology base of the Internet of Things).

If you are a Windows system, you can view the local MAC address in the following ways.

cmd 模式下输入ipconfig/all

Assume that the result of the Physical Address. . . . . . . . . : 00-05-5D-E8-0F-A3 run
This is the MAC address of the machine.
After defining the MAC address, how does one NIC know the MAC address of the other NIC?
The data link layer also has an ARP protocol that can be used to solve this problem. This is left to the back, only to know that the Ethernet packet must know the receiver's MAC address before it can be sent.

Sending a packet

With the data, MAC address, how is the data sent?
Here's a brief talk.

    • MAC Address Table: You can assume that there is a table, LAN host MAC address and switch interface corresponding to the table, the switch is responsible for transferring the data frame to the specified host on the table. (For the moment, the switch is understood as a transit point for information, which is simply a forwarding packet).

    • Broadcast: If the MAC Address table does not have a mapping between the destination MAC address and the host MAC address, then the switch will send this frame to all machines on the same network, and the machine will accept the frame and compare it to its MAC address, or discard the frame if it is the same.

A general understanding of the definition of the packet, the MAC address of the network card, the way the packet is sent, can have a basic understanding of the interaction of the information on the data link layer.

Network layer

With the MAC address, in theory you can let any two network cards in the world to interact with information, but this has a great flaw.

If there is no target host in the MAC Address table of the switch, then Ethernet sends the packet in a broadcast manner, which is not only inefficient but also confined to the sub-network where the sender resides. In other words, if two computers are not on the same subnet, the broadcast is not passed.
(Think about it too, if sent to every host in the world so the information is all messed up)

Therefore, you must find a way to differentiate which MAC addresses belong to the same subnet and which are not. If it is the same sub-network, it is sent by broadcast, otherwise it will be used in other ways (as described later).
Unfortunately, the MAC address itself cannot do this. It is only relevant to the vendor, regardless of the network in which it is located.

This led to the birth of the "network layer". Its role is to introduce a new set of addresses that allow us to distinguish whether different computers belong to the same subnet . This set of addresses is called "Network Address", referred to as "url".

Therefore, after the "Network layer" appears, each computer has two kinds of addresses, one is the MAC address, the other is the network address . There is no connection between the two addresses, the MAC address is bound on the network card, the network address is assigned by the administrator, they are only randomly grouped together.

The network address helps us determine the subnet where the computer resides, and the MAC address sends the packet to the destination network card in that subnet.
Therefore, it is logically inferred that the network address must be processed before the MAC address is processed.

IP protocol

The protocol that specifies the network address is called the IP protocol. The address that it defines is called an IP address.
The current widely used IP address is the fourth version, also known as IPV4.

IPV4 specifies that the IP address is a 32bit binary number composition, we are accustomed to each 8bit sub-group, converted to 10 binary represents an IP address.

Cases:

IP 32bit IP Decimal (also known as dotted decimal notation)
10101100 00010000 11111110 00000001 172.16.254.1

Each computer on the Internet will be assigned an IP address. This address is divided into two parts, the previous part represents the network, and the latter part represents the host.
For example, the IP address 192.16.8.1, which is a 32-bit address, assuming that its network portion is the first 24 bits (192.16.8), then the host part is the last 8 bits (the final 1).
Computers in the same sub-network, their IP address must be the same network part, that is, 192.16.8.22 should be in the same subnet as 192.16.8.1.

As to exactly how many digits the network number represents, it will be introduced in subsequent articles.

In short, the IP protocol functions as:

    • Assign an IP address to each computer

    • Determine which IP addresses are part of the same network.

IP datagram

According to the data sent by the IP protocol, we often call it an IP datagram, which is formatted like an Ethernet frame and is divided into headers h e a d Span style= "Display:inline-block; width:0px; Height:2.563em; " > and data Data 。

Actually, the IP datagram is placed directly into the "Data" section of the Ethernet frame, so the Ethernet specifications are not modified at all.
This is the benefit of the hierarchical structure of the Internet: changes in the upper layers do not involve the underlying structure at all.

Therefore, the Ethernet frame that joins the IP datagram should resemble the following format:

Transport Layer

With the MAC address and IP address, we can already establish communication on any two hosts on the Internet.

The next problem is that there are many programs on the same host that need to use the network, for example, while you're browsing the web and chatting with your friends online. When a packet is sent from the Internet, how do you know whether it represents the content of a Web page or the content of an online chat?
In other words, we also need a parameter that indicates which program (process) The datagram is intended to use.
This parameter is called "Port", which is actually the number of each program that uses the NIC. Each packet is sent to a specific port on the host, so different programs can take the data they need.

The port is an integer between 0 and 65535, exactly 16 bits. 0 to 1023 of the ports are system-occupied, users can only choose a port greater than 1023. Whether you are browsing the Web or chatting online, the application randomly selects a port and then contacts the appropriate port on the server.

In contrast, the function of the network layer is to establish host-to-host communication , and the function of the transport layer is to establish the application-to-application communication .

UDP protocol

The addition of port information requires a new protocol. The simplest implementation is called the UDP Protocol (User Data Protocol), which is almost in the form of a port number in front of the original IP datagram.

TCP protocol

The advantages of the UDP protocol are relatively simple and easy to implement, but the disadvantage is that the reliability is poor, once the packet is sent, it is impossible to know whether the other party received.
In order to solve this problem and improve the network reliability, the TCP protocol was born.
This protocol is more complex, you can simply understand that on the basis of UDP added some to ensure that the data can be transferred to the mechanism, of course, if the recipient does not receive it will resend.

Application Layer

When the application layer receives data from the transport layer, it interprets the data, but the different programs transmit the information in a certain format, so we have to standardize the data emitted by different applications, which forms a variety of protocols for the application layer.

For example, FTP protocol, HTTP Hypertext Transfer Protocol (although it is called the transport protocol but belongs to the application layer) and so on.

In short, the Application layer protocol specifies how the received data messages should be parsed.

This article refers to Nanyi-the Internet, the introduction of a large part of the content, coupled with the understanding of changes, I hope you respect the work of the original author, to the original look can have a greater harvest.

TCP/IP: protocol overview

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.