"My Linux, I am the boss!" "Technology Daniel tells you that the Linux network principle should learn this way!"

Source: Internet
Author: User
Tags ack network function

Linux belongs to the network operating system, so the network function is the important core function of Linux. We know that the network model includes the total Linetype network, the Star network, the Token Ring network and so on. Data transmission on the network is an electromagnetic signal transmission, for example, in the total Linetype network, at the same time only one signal in the transmission medium, if there are multiple hosts at the same time to send information, it will generate contention for the transmission media, at this time in order to solve this problem, we have produced a mac:media The solution for access control, which is media access controls. We give each access network device a unique identification code, so that the MAC algorithm generated by the arbitration results can be implemented, each host will have a MAC address, and MAC address using the CSMA/CD technology to complete network line arbitration, the technology was originally from the Ethernet network, The transmission signal usually follows: The carrier listens to multiplex accesses, the conflict detects the way carries on the data detection and transmits (for example). In addition, for example, ring networks are implemented by Token ring and so on.

Star network is mainly through a hub hub to connect all the host, hub hub itself does not isolate the signal mechanism, but simply to connect the host together, so the data in the process of transmission will still conflict. Star network in general still belongs to the total Linetype network, when the CSMA/CD mechanism to transmit data and the network hosts too many, data transmission will be blocked, conflict, etc., at this time can be a whole network to split, such as the formation of two network segments, in the middle using bridge devices to connect (such as), In the bridge, there will be a data table to record which host in which port correspondence, so when a host sends the destination in a host-side network, then the signal will not occupy the B-terminal network port channel, thereby reducing the signal collision probability.

first, the switch principle:
According to this idea, when we divide multiple network segments on the bridge device, and each network segment has only one host, at this time the scope of the conflict is limited to the host and Access bridge device node this line range (such as), at this time we can do when a host and B host communication, The C host is still free to communicate with the D host without the communication channel conflict blocking due to the CSMA/CD mechanism, which is known as the "switch", so the switch can isolate the conflict domain.

second, the router principle:
When the two switching network connected (such as), such as host a need and M host communication, at that time 1th network of a host does not know the M host specific MAC address and other location information, if it is simply to connect the network 1th and 2nd network with communication cable, then broadcast signal will flood the entire network, If the number of hosts in the network is very large, will form a broadcast storm, thus affecting the communication performance of the entire network, at this time we need to use a special device to connect 1th network and 2nd network, so that the intermediate equipment in the reception of broadcast signal is ignored directly discarded, but can be completed in different network segments of the host communication needs. The MAC address is the computer communication address, the transmission data must use the MAC address, but the MAC address can only identify the different host, cannot divide the different network, therefore belongs to the flat address, on the second basis we introduced the logical address (IP address) concept, may divide the different network. For example, the logical address of a host is 1.1, it declares that it needs to transmit data destination is 2.1, at this time the intermediary device is found to be different communication between the network, the gateway on the router is the switch network communication level they also have their own MAC address auxiliary communication, the broadcast of the 1th network through the intermediary device only in the broadcast of the 2nd network, Host m returns its logical address and MAC address to the sender to complete the communication. The special devices in the middle are known as "routers," so routers can isolate broadcast domains.

Third, OSI layer seven protocol:
The origin of OSI layer Seven protocol: because the network connection process is very complex, including hardware data encapsulation and application of the mutual link, if you want to write a network link all the functions of the program together, then any one link error, the whole program to rewrite, very troublesome, So we have the entire network connection process divided into layers to process, and each layer of data delivery is sequential delivery, this is the OSI seven layer protocol. The seven-layer protocol has the following characteristics:
each level has a specific, independent function
each level of code can be written independently
the function between layers and levels does not interfere with each other
Each level only knows each other's data on the same level.

Physical Layer: Because the network transfer media transmits bits (01), the physical layer must define the voltage and signal of the transmission device used, and must also understand the encoding of the data frame into the bitstream, and finally link the actual transmission media and send/receive the bit signal.
Data Link Layer: Hardware part, the main processing Mac data frame, transfer to the physical layer to convert to bit stream; The software part mainly deals with the conversion of data tables from the upper layer to the MAC format. Related protocols: PPP
Network Layer: Define IP Address, define link establishment between computers, terminate maintenance, etc., and transmit path of packet. Related protocols: IP, ICMP, ARP, RARP
Transport Layer: The link technology (TCP,UDP) that defines the sending and receiving end includes the packet format of the technology, the sending of the packet, the control of the process, etc., to ensure that the data can reach the destination correctly and accurately. Related protocols: TCP, UDP
Session Layer: Determine the confirmation of the Network Service establishment link.
Presentation Layer: Defines the conversion of data formats between network services (or programs), standardizes data formats, and also includes encryption and decryption of data on this layer.
Application Layer: Sends the data to the application and is eventually presented to the user. Related protocols: HTTP, FTP, SMTP, and so on.
Although the architecture of the OSI Seven layer protocol is very rigorous, it is quite difficult to write the program because it is too rigorous, resulting in the TCP/IP protocol. such as

four, TCP/IP network layer-related data packets and data
(1) Encapsulation of IP packets:
Understand the encapsulation of IP packets in order to know how IP is generated, IP packets can reach 65535bytes

The relevant terms are explained as follows:
IP VERSION:IP version number, including IPV4 or IPV6
Header Length: Header
Type of service: Services Type
Total length: The entire message
Identifiction: Marker
Fragment Offset: Slice offset
DF: No more slices
MF: More Films
Time-to-live: Time To Live
Protocol: Protocol, common TCP and UDP protocols
Header Checksum: Header checksum
Source IP Address: Origin IP
Destination IP Address: Destination IP
Options: Optional
Data:
(2) Reliable connection-oriented TCP protocol:
TCP (transmission Control Protocol) means the transmission protocol, which differs from the UDP (user Datagram Protocol) User Datagram Protocol. TCP is a reliable Transmission Control protocol that, above the network IP layer, is the TCP Transport layer, where the transport layer data is packaged into TCP packets.

The relevant terms are explained as follows:
Source port number: Port of origin
Destination Port number: Destination port
Sequence Number: Serial numbers
Acknowledgement Number: Confirmation
Header Length: Header
Reserved: Reserved Bits
URG: Emergency bit
ACK: Confirm bit
PSH: Push bit
RST: Reset Bit
SYN: Sync bit
FIN: End Bit
Window Size: Windows sizes
Checksum of TCP Checksum:tcp
Urgent Pointer: Emergency Hands
Options: Selectable Selections
Data:
(3) The type of IP address is divided into:
There are two kinds of IP categories in IPV4
Public IP: Common IP, through InterNIC unified planning IP, only this IP can be linked to the Internet.
Private IP: IP or reserved IP, not directly connected to the Internet IP, mainly used for host link planning within the local area network.
Public IP Common IP is as follows:(Note: 128+64+32+16+8+4+2+1)
Class A: 255.0.0.0~8-Subnet Mask
0-000 0001 ~ 0-111 1111 "1~127"
127 Class A addresses, 127 for loopback, with a total of 2^7-1 network addresses
How many hosts are accommodated: 2^24-2
Host bit all 0: network address
Host bit full 1: Broadcast address
Class B: 255.255.0.0~16-Subnet Mask
10-00 0000 ~ 10-11 1111 "128~191"
64 Class B addresses with a total of 2^14 network addresses (because the first 8 bits have the remaining 6-bit network addresses and the second 8 bits are all network addresses)
How many hosts are accommodated: 2^16-2
Class C: 255.255.255.0~24-Subnet Mask
110-0 0000 ~ 110-1 1111 "192-223"
32 Class C addresses with a total of 2^21 network addresses
How many hosts are accommodated: 2^8-2
Class D
1110-0000 ~ 1110-1111 "224-239"
Class E
"240-255"
private IP addresses are as follows:
Private addresses can be used in Ethernet, but not in the public Internet
Class A: 10.0.0.0/8 ~ 10.255.255.255/8
Class B: 172.16.0.0/16 ~ 172.31.0.0/16
Class C: 192.168.0.0/24 ~ 192.168.255.0/24
(4) dividing subnets:
A large network is divided into subnets, and the network ID is implemented to the host ID borrow. For example, to divide the 201.1.2.0/24 network into 2 subnets, one subnet needs to accommodate 4 hosts, and the other subnet needs to accommodate 6 hosts. You can divide 2 bits from the fourth 8-bit to use as a network bit. The following four combinations can be obtained:
00 (all 0 cases not considered)
01-00 0001 ~ 01-11 1110 "65~126" 201.1.2.64 network address, 201.1.2.127 broadcast address
10-00 0001 ~ 10-11 1110 "129-190" 201.1.2.128 network address, 201.1.2.191 broadcast address
11 (all 1 cases not considered)
(5) TCP three handshake and four waves of explanation:

three-time handshake:
First handshake: The client sends a TCP SYN flag where 1 of the package indicates the port of the server to which the client intends to connect.
Second handshake: The server sends back the acknowledgement packet ack reply, that is, the SYN flag bit and the ACK flag bit are all 1.
Third handshake: The client sends the confirmation packet again Ack,syn the flag bit to the 0,ACK flag bit of 1.
four times wave:
First wave: The client sends a fin to shut down the client-to-server data transfer and the client enters the fin_wait_1 state.
Second wave: The server receives fin, sends an ACK to the client, confirms that the serial number is received sequence number +1, the server enters the close_wait state.
Third wave: The server sends a fin to shut down the server-to-client data transfer, and the server enters the Last_ack state.
Fourth wave: After the client receives fin, the client enters the TIME_WAIT state, then sends an ACK to the server to confirm that the sequence number is received sequence number +1, the server enters the close state and completes four waves.
Five, Linux network configuration example:
The "Alias" Alias is used to set the device name on the early Red Hat 5 system through the/etc/modprobe.conf configuration file, and the device name is currently set in the/ETC/UDEV/RULES.D directory in Red Hat 6 system.
#ifconfig-A eth1
Explanation: Displays configuration information for all interfaces.
#ifconfig eth1 192.168.10.123/24
Explanation: The configured address takes effect immediately, but restarting the network service or host fails.
Network services:
rhel5:/etc/init.d/network {Start|stop|restart|status}
Rhel6:/etc/init.d/networkmanager {Start|stop|restart|status}


Iproute2: More powerful network management software packages

"My Linux, I am the boss!" "Technology Daniel tells you that the Linux network principle should learn this way!"

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.