Article Title: production of broadcast programs in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Principles of TCP/IP Networks In an Internet Protocol network, each computer has a 32-bit IP address. The IP address of each computer is unique. WWW is an extremely large and growing IP network. Therefore, each computer on the network must have a unique IP address. An IP address is a four-digit number separated by., for example, 16.42.0.9. In fact, IP addresses can be divided into two parts: one is the network address and the other is the host address. For example, in 16.42.0.9, 16.42 is the network address and 0.9 is the host address. Host addresses can be divided into subnet addresses and host addresses. The IP address of a computer is hard to remember. It is much easier to use a name. If you use a name, you must have a mechanism to convert the name to an IP address. These names can be statically stored in the/etc/hosts file, or the Linux system requests the Domain Name Server (DNS server) to convert the names. If you use a DNS server, the local host must know the IP addresses of one or more DNS servers. The information is stored in the/etc/resolv. conf file.
When you are connected to other computers, the system uses IP addresses to exchange data with other computers. Data is stored in IP data packets. Each IP packet has an IP data header, including the source address and destination address, a data checksum and other related information. The size of IP data packets varies with the transmission media. For example, Ethernet data packets must be larger than PPP data packets. After receiving data packets, the host at the destination address must assemble the data and send it to the received application.
IP data packets can be directly transmitted between hosts connected to the same IP subnet, while gateways are required for hosts connected to different subnets. The gateway is used to transmit data packets between different subnets.
The IP protocol is a Transport Layer Protocol. Other protocols can use the IP protocol to transmit data. TCP (Transmission Control Protocol) is a reliable Protocol between point-to-point. It uses the IP Protocol to transmit and receive its own data packets. TCP is a connection-based protocol. A virtual connection line will be established between the two applications that need to communicate, even if it goes through many subnets, gateways, and routers. TCP ensures that data is reliably transmitted and received between two applications, and that no data packets are lost or duplicated. When TCP uses the IP protocol to send its own data packets, the data in the IP data packet is the TCP data packet itself. The IP protocol layer in the host that communicates with each other is responsible for transmitting and receiving IP data packets. Each IP data header contains a protocol identifier of a byte. When TCP requests an IP packet from the IP protocol layer, the Protocol identifier in the IP data header indicates that the packet is a TCP packet. The IP layer of the acceptor can use this Protocol identifier to determine the layer to which the received packets are transmitted. Here, it is the TCP layer.
When applications use TCP/IP for communication, they must specify not only the IP address of the target computer, but also the port address used by the application. A port address can uniquely represent an application. A standard network application uses a standard port address. For example, a web server uses port 80. You can view the registered port addresses in/etc/services.
The IP protocol layer can also use different physical media to transmit IP packets to other IP address hosts. You can add protocol headers to these media sets. For example, the Ethernet protocol layer, PPP protocol layer, or SLIP protocol layer. Ethernet can be connected to multiple hosts at the same time, and each host has an ethernet address. This address is unique and saved in an Ethernet Card. Therefore, when an IP packet is transmitted over Ethernet, the IP address in the IP packet must be converted to the physical address in the ethernet card of the host. In Linux, Address Resolution Protocol (ARP) is used to translate IP addresses into physical addresses in the ethernet card of the host. Hosts that want to translate IP addresses into hardware addresses use broadcast addresses to send an ARP request packet containing IP addresses to all nodes in the network. After receiving the request, the target computer that owns this IP address returns an ARP response containing its physical address. ARP is not only limited to Ethernet, but can also be used in other physical media, such as FDDI. Network devices that cannot use ARP can be marked out, so that the Linux system will not try to use ARP. The system also has a reverse translation protocol called RARP, which translates the host's physical address into an IP address. The gateway can use this Protocol to respond to ARP requests on behalf of IP addresses in the remote network.
BSD Interface The BSD interface is the earliest implementation of network communication. It is supported by a management software that only processes BSD interfaces. The following is the INET interface layer, which manages the communication ends of TCP and UDP. UDP (User Data Protocol) is a connectionless Protocol, while TCP is a reliable end-to-end Protocol. When a UDP packet is transmitted over the network, the Linux system does not know whether or not these UDP packets are securely sent to the destination node. TCP data packets are numbered, and both ends of TCP transmission must confirm the correctness of the data packets. The IP protocol layer is used to implement the inter-network protocol. The code must prepare an IP data header for the previous layer of data, it is also necessary to decide how to transmit the received IP packet to the TCP or UDP protocol layer. Below the IP protocol layer is a network device that supports the entire Linux network system, such as PPP and Ethernet. Network devices are not exactly the same as physical devices, because some network devices, such as feedback devices, are completely implemented by software. Unlike standard devices that use the mknod command to create Linux systems, network devices only appear in the system when the software detects and initializes these devices. When you build the system kernel, you can only see/dev/eth0 even if the system has the corresponding Ethernet device driver. The ARP protocol is between the IP protocol layer and the protocol that supports ARP translation addresses.
======================================
Network Application
User Layer
--------------------------------
BSD core layer
Set Interface Layer
|
LNET
Set Interface Layer
|
/? \
TCP UDP
|
IP
|
PPP | SLIP | Ethernet ---> ARP
======================================
BSD is a common network interface in UNIX systems. It not only supports different network types, but also supports communication between internal processes. Both communication processes use a set of interfaces to describe the two ends of the communication link. The Set interface can be considered as a special pipe, but unlike the pipe, the set interface has no limit on the size of data that can be accommodated. Linux supports multiple types of interfaces, also known as the set interface addressing family, because each type of interfaces has its own addressing method.
Linux BSD interfaces support the following interface types:
1. stream)
These interfaces provide reliable bidirectional sequential data stream connections. They can ensure the integrity, correctness, and singularity of data transmission. The TCP protocol in the INET addressing family supports this type of set interface.
The data stream set interface is a reliable two-way connection communication data stream. If you put two pieces of data in the order of "1, 2" in the Set interface, they will also arrive in the order of "1, 2" at the other end. They can also be considered as error-free transmission.
The commonly used telnet application is an example of using the data stream set interface. The http www browser also uses the data stream interface to read webpages. In fact, if you use telnet to log on to port 8 0 of a WWW site and type "GET webpage name", you will GET this HTML page. Data Stream sets use TCP for high-quality data transmission. The datagram set interface uses UDP, so the order of the datagram is not guaranteed. Data is transmitted in a response mode.
2. Data Packets)
This type of set interface can also provide two-way data transmission like a stream set interface, but they cannot guarantee that the transmitted data will certainly reach the target node. Even if the data can arrive, it cannot be ensured that the data arrives in the correct order and that the data is single and correct. The u d p protocol supports this type of interface.
3. Raw)
This type of interface allows the process to directly access the underlying protocol.
4. Reliable message delivery)
This interface is the same as the datagram interface, and can only ensure the arrival of data.
5. Sequenced Packets)
This type of set interface is the same as the stream set interface, except that the packet size is fixed.
6. Packet)
This is not a standard BSD interface type, but an extension in Linux. It allows processes to directly access data packets at the device layer.
Basic set Interface Options
SO_KEEPALIVE
Checks whether the host of the other party crashes to prevent (the server) from blocking the input of the TCP connection forever. After this option is set, if no data is exchanged in any direction of this interface within two hours, TCP automatically sends a keepalive probe to the other side ). This is a TCP shard that the other party must respond to. It may cause the following three situations:
The other party receives the desired ACK response. 2 hours later, TCP sends out another detection shard.
The other party has crashed and restarted: respond with RST. The interface to be processed is set to ECONNRESET, and the interface itself is closed. The other party has no response: TCP sent from the berkeley sends an additional eight detection segments, one in 75 seconds, and tries to get a response. If no response is returned after the first probe is sent for 11 minutes and 15 seconds, give up. The processing error of the Set interface is set to ETIMEOUT by mistake, and the Set interface itself is disabled. For example, if the ICMP error is "host unreachable (host inaccessible)", it indicates that the host of the other party has not crashed but is not reachable. In this case, the error to be handled is set to EHOSTUNREACH.
SO_RCVBUF and SO_SNDBUF
Each set of interfaces has a sending buffer and a receiving buffer. The receiving buffer is used by TCP and UDP to keep the received data for read by the application process. TCP: The window size of TCP advertised to the other end. The receiving buffer of the TCP interface cannot overflow, because the other party cannot send data that exceeds the size of the advertised window. This is the traffic control of TCP. If the recipient ignores the window size and sends out data that exceeds the Zhoukou size, the receiver TCP will discard it. UDP: When the received data report is not included in the interface to receive the buffer, the datagram is discarded. There is no traffic control for UDP. A fast sender can easily drown out slow recipients, causing the receiver to discard the UDP datagram.
SO_LINGER
Specify how the function closes the interface connection protocol-processing the LINGER structure when data remains in the buffer zone sent by the interface
Struct linger {int l_onoff; // 0 = off, nonzero = on int l_linger; // linger time in seconds };
SO_RCVLOWAT and SO_SNDLOWAT
Each set of interfaces has a receiving low tide limit and a sending low tide limit. They are used by the function select, and the threshold for receiving low tide is to make the select return "readable" and the total amount of data required in the buffer zone received by the interface. -- For a TCP or UDP interface, the default value is 1. Sending low tide limit is to allow the select statement to return "writable", and the available space is required in the interface sending buffer. This value is often missing for TCP interfaces.
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