I. TCP/IP background and introduction
In the 70 's, with the development of computer technology, computers users realized that it was necessary to connect computers from all over the world to play a more important role in computer. But the simple connection is not enough, because the computer can not communicate. Therefore, the design of a common "language" to communicate is necessary to be less, then the TCP/IP protocol was born. This address: http://blog.csdn.net/sunansheng/article/details/52054632
TCP/IP (transmission Control protocol/internet Protocol) is the short name for transmission protocol and network protocols, which defines how electronic devices connect to the Internet and how data is transmitted between them.
TCP/IP is not a protocol, but a general term for a protocol family that includes IP protocols, IMCP protocols, TCP protocols, and HTTP, FTP, POP3 protocols, and so on. Computers in the network are interconnected using this set of protocols.
Network protocol stack Architecture
Refers to the network protocol stack structure, the most famous is the OSI seven layer model, but the TCP/IP protocol family structure is slightly different, the hierarchy between them have a corresponding relationship:
TCP/IP is divided into 4 layers, each layer undertakes different tasks, each layer of the protocol works differently, each layer encapsulates the upper data in a different way:
- (1) Application layer: The application accesses the network through this layer, common FTP, HTTP, DNS and TELNET protocols,
(2) Transport layer: TCP protocol and UDP protocol,
(3) network layer: IP protocol, ARP, RARP protocol, ICMP protocol, etc.
- (4) network interface layer: is the base of TCP/IP protocol, responsible for sending and receiving data frames.
Third, the preparation of knowledge 1, IP address
Each node on the network must have a separate IP address, usually using an IP address that is a 32bit number. into 4 groups, for example, 255.255.255.255 is an IP address. With an IP address, the user's computer can discover and connect to another computer on the Internet.
In a Linux system, you can view your IP address with one of these commands:
ifconfig -a
2. Domain Name
12-digit IP address is difficult to remember, in the actual application, the user generally do not need to remember the IP address, the Internet to each IP address an alias, used to be called domain name.
The domain name corresponds to the IP address of the computer and stores the correspondence in the Domain Name service, which allows the user to communicate with the specified computer by remembering the domain name.
Common domain names include COM, net, and org three top-level domain suffixes, in addition to each country has its own country-specific domain name suffix (such as our country's domain name suffix cn). Currently used domain names such as Baidu (www.baidu.com), the Linux Organization (www.lwn.net) and so on.
We can use the command "nslookup" or "ping" to view the IP address corresponding to the domain name, we can use the view because of the experimental building network restrictions ping git.shiyanlou.com
.
For example:
The mapping of domain names to IP addresses, as well as the routing and Discovery mechanisms of IP addresses, are described in detail in subsequent chapters.
3. MAC Address
MAC (Media Access Control) address, or physical address, or hardware address, used to define the location of devices in the Internet.
In the TCP/IP hierarchy model, the network layer manages the IP address, and the link layer is responsible for the MAC address. So each network location will have an IP address dedicated to it, and each host will have a dedicated MAC address.
4. Port number
IP addresses are used to discover and find addresses in a network, but how different programs communicate with each other requires a port number to identify them. If the IP address is likened to a house, the port is the door to the house. The real house has only a few doors, but the port is identified by a 16-bit number, and an IP address can have a port of 65536 (that is: 2^16)!
The server's default programs are generally identified by the port numbers that are known to them. For example, for each TCP/IP implementation, the TCP port number of the SMTP (Simple Mail Transfer Protocol) server is either the TCP port number of the 25,FTP (File Transfer Protocol) server or the UDP port number of the 21,tftp (Simple File Transfer Protocol) server is 69. Any TCP/IP implementation provides a service that uses a well-known port number between 1-1023. These known port numbers are managed by the Internet Port number assignment Authority (internet Assigned Numbers Authority, IANA).
5. Encapsulation and Separation
encapsulation : When the application sends data, the data passes from top to bottom through each layer in the protocol hierarchy, Each layer will add some header or tail information to the data, as shown, the data unit passed to the network layer by the transport layer is called tcp message segment (TCP segment) or udp datagram (UDP datagram ) 。 The data unit passed to the link layer by the network layer is called ip datagram (IP datagram). The transmission unit on the link layer is called frame (frame).
divide : When the host receives a data frame, the data rises from the bottom of the protocol layer, passing each layer, checking and removing the corresponding level of the packet header or tail, and the package process is the opposite.
6. RFC
The RFC (Request for Comment) documentation is the official standard for all Ethernet protocols and is published on its official web site, developed by the IETF Standards Association. A large number of RFCs is not a formal standard, and the purpose of publication is simply to provide information. The length of the RFC varies from a few pages to hundreds of pages. Each protocol is identified by a number, such as RFC 3720 is the standard for the ISCSI protocol, and the larger the number, the more recent the content of the RfC is, or the corresponding protocol (standard) that appears later.
All RFC documents can be found on the web and are on the IETF's website. On the site, you can quickly find RFC documents for the target protocol by category and search. There are currently thousands of RFC documents on the IETF website, but we do not need to master all, in the work or study if the corresponding interpretation can be found, the theory and the actual combination will have a better effect, simply read the effect of the RFC generally.
Introduction to "Fine" TCP/IP protocol (i) Introduction to TCP/IP