Were you asked about the TCP/IP protocol during the interview? _TCP/IP

Source: Internet
Author: User
Tags file transfer protocol

https://blog.csdn.net/yulyu/article/details/69062288

Objective:

Proficient in TCP/IP, familiar with Socket for network programming.
See this sentence, there is no feeling very familiar ah. I believe many people have seen this request in the delivery of their resumes, many people will feel that we do not generally use this knowledge in the actual development, so we shrug off these things.

But I think want to make a better APP, then the basic knowledge must have a certain understanding, so that you can consider more comprehensive and perfect, let us take a look at what is TCP/IP.

1. What is TCP/IP?

TCP/IP is a kind of protocol system, which is a set of protocols for network communication.

Traditionally, TCP/IP is considered to be a four-tier protocol.

1) network interface layer:

Mainly refers to the physical level of some interfaces, such as cable.

2) Network layer:

Provides hardware-independent logical addressing, which enables the transformation of physical and logical addresses.

In the TCP/IP protocol family, the network layer protocol includes IP protocol (Internet Protocol), ICMP protocol Internet Control Message Protocol, and IGMP Protocol (Internet Group Management Protocol).

3) Transport Layer:

Provides traffic control, error control and validation services for the network.

There are two distinct transport protocols in the TCP/IP protocol family: TCP (Transmission Control Protocol) and UDP (User Datagram Protocol).

4) Application layer:

Provides specific applications for network scheduling, file transfer, remote control, and Internet operations

2. Data packet

In the TCP/IP protocol, the data is loaded from top to bottom, and then the top of the packet is torn down.

In the packaging, each layer will add some information for transmission, this part of the information is called the header, when the upper level of data to the layer, will be the data plus the header of this layer packaged together, continue to pass.

Loading package

At the time of unpacking, each layer reads the headers needed in this layer and uploads the remaining data.

This process is a little like the Russian set of dolls, so sometimes people will use the Russian set of Eva to describe the process.

Russia set Eva

3. Network interface Layer

This piece mainly involves some physical transmission, such as Ethernet, Wireless LAN. There's no detailed introduction here.

4. Network layer

As mentioned earlier, the network layer is primarily the conversion between physical and logical addresses.

Currently the most used in the market is the 32-bit binary IPv4, because the IPV4 address is not enough, so the 128-bit binary IPV6 application is more and more extensive (but the following is based on the introduction of IPV4)

1) IP:

Each network adapter on the TCP/IP protocol network has a unique IP address.

IP address is a 32-bit address, this address is usually divided into 4, each 8 binary for a paragraph, but for the convenience of reading, it is usually converted to decimal to display each paragraph, such as everyone very familiar with the 192.168.0.1

The IP address is divided into two parts:

Network ID
Host ID
However, the specific part of the network ID, which belongs to the host ID is not specified.

Because some networks require a host of hosts, this means more of the host ID, but some networks need fewer hosts, so the part of the host ID should be less.

Most IP addresses fall into the following categories

Class A Address: The first 8 digits of the IP address represent the network ID, and the last 24 digits represent the host ID.
Class B Address: The first 16 digits of the IP address represent the network ID, and the last 16 digits represent the host ID.
Class C Address: The first 24 digits of the IP address represent the network ID, and the last 8 digits represent the host ID.
It is obvious here that a class A address can provide fewer network IDs, but each network can have very many hosts

But how do we see what kind of address an IP address is?

If the 32-bit IP address starts with 0, then it is a class A address.
If the 32-bit IP address starts with 10, then it is a class B address.
If the 32-bit IP address starts with 110, then it is a C-class address.
Then convert to decimal (four paragraphs), we can be in the first paragraph of the decimal number to distinguish the IP address is what kind of address.

Attention:

Decimal first paragraph is greater than 223 of class D and E-class address, these two kinds of special and not common, here is not to do a detailed introduction.
Each class has some exclusion addresses that are not part of the class, and they are used in special cases (described later)
In addition to such a way to divide the network, we can also divide each network into smaller network blocks, called subnets (described later)
All 0 of the host ID represents the network itself, for example, the IP address is 130.100.0.0 refers to the network ID of the class B address 130.100.

All 1 of the host IDs represent broadcasts, which are used to all host method messages on the network. IP address for 130.100.255.255 is the network ID 130.100 Network broadcast address (binary IP address is all 1, converted to decimal is 255)

Addresses that begin with decimal 127 are loopback addresses. The destination address is a loopback address message that is actually sent and received locally. This is primarily used to test whether TCP/IP software is working correctly. When we use the ping function, the usual loopback address is 127.0.0.1

2) Address Resolution Protocol ARP

In simple terms, the role of ARP is to map the IP address to the physical address, and the opposite RARP (reverse ARP) is to map the physical address to the IP address.

3) Subnet

Previously mentioned the classification of IP addresses, but for class A and class B addresses, the number of hosts under each network is too large, then the transmission of the network will become very inefficient, and very inflexible. For example, the IP address is 100.0.0.0 's Class A address, the number of hosts under this network exceeds 16 million units.

So the subnet mask appears to solve this problem.

Let's review the previous distinction between host IP and network IP.

Take the class A address 99.10.10.10 As an example, the first 8 bits are network IP, and the latter 24 bits are host IP. (pictured below)

Subnet mask is also a binary number of 32, can also be divided into four decimal digits, each of his corresponding IP address corresponding location, the value of 1 o'clock represents a non-host bit, the value of 0 o'clock is the host bit.

The table can be clearly seen that the network IP is still from the previous classification to determine the number of bits, host IP is a subnet mask value of 0 of the number of digits to decide, the rest is the subnet IP

5 Transmission Layer

The transport layer provides two ways to reach the target network

Transmission Control Protocol (TCP): Provides sophisticated error control and flow controls to ensure that data is transmitted properly and is a connection-oriented protocol.
User Datagram Protocol (UDP): Provides only basic error detection and is a connectionless protocol.
Characteristics:

1) UDP:

Pack the data
Data size is limited (64k)
Do not establish a connection
Fast, but low reliability
2) TCP:

Establish a connection channel
Unlimited data size
Slow, but high reliability
Because the transport layer involves more things, such as ports, sockets and so on, are we do mobile development needs to understand, after the article in our specific introduction, here is not explained.

6 Application Layer

Application layer as the highest level of TCP/IP protocol, for our mobile development, is the most contact.

Protocols running on the TCP protocol:

HTTP (hypertext Transfer Protocol, Hypertext Transfer Protocol), mainly for general browsing.
HTTPS (hypertext Transfer Protocol over Secure Sockets Layer, or HTTP over SSL, Secure Hypertext Transfer Protocol), secure version of the HTTP protocol.
FTP (file Transfer Protocol, Files Transfer Protocol), known for file transfer.
POP3 (Post Office Protocol, version 3, Post Office Protocol), to receive mail.
SMTP (Simple Mail Transfer Protocol), which is used to send e-mail messages.
TELNET (teletype over the network, network Telex), through a terminal (terminal) landing to the network.
SSH (Secure Shell, used in lieu of security-poor telnet) for encrypted secure login.
Protocols running on the UDP protocol:

BOOTP (Boot Protocol, startup protocol), applied to diskless devices.
NTP (Network time Protocol, Network Timing Protocol) for network synchronization.
DHCP (Dynamic Host Configuration Protocol, dynamically hosted Configuration Protocol), dynamically configuring IP addresses.
Other:

DNS (domain Name Service), which is used to complete address lookup, mail forwarding, etc. (running on TCP and UDP protocols).
Echo (Echo Protocol, wrap protocol) for error checking and measurement of response time (running on TCP and UDP protocols).
SNMP (Simple network Management Protocol, Easy Network Management Protocol) for network information collection and network management.
ARP (Address resolution Protocol, addresses resolution Protocol) for dynamic resolution of Ethernet hardware addresses.
Similarly, because the application layer we need to involve too many things, specific introduction we will be in later articles, the article will not be extended, interested friends can continue to pay attention to my blog:

Http://blog.csdn.net/yulyu

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.