Network programming
Network model:
- OSI (Open System Interconnection Open System interconnect) Reference Model
- TCP/IP Reference Model
Seven Floor Brief:
1. Layer Physical layer: The main definition of physical equipment standards, such as the interface type of network cable, the interface type of optical fiber, the transmission rate of various transmission media.
its main role is to transmit the bitstream (that is, 1, 0 is converted to the current strength to carry out the transmission, after reaching the destination in the conversion to 1, 0, that is, we often say the digital-to-analog conversion and A/D conversion). This layer of data is called a bit .
2. Layer Data Link layer: The main data received from the physical layer to the MAC address (network card address) encapsulation and unpacking.
This layer of data is often called a frame . The device that works on this layer is the switch, which transmits the data through the switch.
3. Layer Network layer: The main data received from the lower level of IP address (example 192.168.0.1) encapsulation and solution encapsulation.
The device that works on this layer is the router, which is often called the data packet .
4. Layer Transport Layer: defines some protocol and port number for transmitting data (WWW port 80, etc.),
such as: TCP (Transmission Control Protocol, low transmission efficiency, strong reliability, for transmission of high reliability requirements, large data volume data),
UDP (User Datagram Protocol, the opposite of TCP characteristics, for transmission reliability requirements are not high, data volume of small data, such as QQ chat data is transmitted in this way).
The main point is to segment and transmit the data received from the lower layer, and then reorganize after reaching the destination address. This layer of data is often called a segment .
5. Session Layer: The path of data transmission is established through the Transport Layer (port number: Transport port and receive port).
primarily initiates a session between your systems or accepts a session request (the device needs to know each other either IP or Mac or hostname)
6. Presentation layer: The main is to carry out the interpretation of the received data, encryption and decryption, compression and decompression, and so on (that is, the computer can recognize something that adults can recognize things (tablets, sounds, etc.).
7. Application layer: mainly some terminal applications, such as FTP (all kinds of file download), the WEB (ie browsing), QQ and so on (it can be understood as we can see on the computer screen things. is the terminal application).
Network communication elements:
- IP Address: inetaddress
- Marking of devices in the network
- Hard to remember, host name available
- Local loopback address: 127.0.0.1 host name: localhost
- Port number
- The logical address used to mark the process, and the marking of the different processes
- Valid ports: 0~65535, where 0~1024 systems use or retain ports
- Transport protocol
- Rules of Communication
- Common protocols: TCP, UDP
Udp
- Encapsulates data and sources and purposes into packets without establishing a connection
- Limit the size of each packet within 64K
- Because there is no connection, it is not a reliable protocol.
- No need to establish connection, fast speed
Tcp
- Establish a connection to form a channel for transmitting data.
- Make large data transfers in a connection
- Complete connection via three handshake, is a reliable protocol
- The connection must be established, efficiency or slightly lower.
OSI&TCP/IP Reference Model