当前位置:网站首页>Network foundation (1)

Network foundation (1)

2022-07-07 11:06:00 Exy-

Catalog

1. Switch :

2. Router

3. Division of network

4.IP Address

5. Port number

6. Network communication protocol

7. Network byte order

8. The transport layer TCP And UDP agreement


One . Network development background

1. Switch :

According to the record of the connected computer mac( Physical network card address ), Data exchange .

shortcoming : It is impossible to send to which host you want .

2. Router

A function is added to the technology of data exchange --- Network identification , For every piece of data in the network , Choose a suitable path , Send to the target host , It has realized the function of sending it to whoever you want , The router will recognize the network choice of the destination host sent to .( Path selection , Data forwarding )

3. Division of network

LAN ( The coverage is 1000m)

Metropolitan area network ( The coverage is 20km)

Wide area network ( Greater than 20km)

The Internet we usually use / The Internet belongs to a larger international wide area network , It is a complex star network , More disaster tolerant .

Ethernet / Token ring network is a networking method

4.IP Address

uint32_t --- Unsigned 4 Byte integer

As the unique identification of the host in the network --- Location between hosts in the network ( Which host communicates with which host )-- adopt IP Address identification

Every data in the network will contain Source side IP Address / To the end IP Address

ipv4: uint32_t( Less than 43 Billion , It's not enough )     ipv6:uint8_t addr[16]-- The promotion degree is very low

DHCP: Dynamic address assignment -> Who surf the Internet to whom IP Address    NAT: stay DHCP after , There are still many people , Let many people use the same IP Address to surf the Internet

5. Port number

uint16_t Unsigned 2 An integer of bytes

Uniquely identify a process on a host , When writing communication programs , You have to tell the computer , Which port should I handle the data sent to

A port can only be occupied by one process , However, a process can use multiple ports

Every piece of data in network communication contains --- Source port and peer port --- It means which process this data is sent from , Which process should be handed over to handle

6. Network communication protocol

Data format convention in network communication

Follow the unified communication protocol standard , To achieve substantial communication , Realize network interconnection .

There are many communication protocols in the whole network communication environment --- Each protocol deals with different communication scenarios

Protocol layer : According to different communication scenarios , The services are different , The protocols used are divided into different levels

Typical protocol layering :

OSI Seven layer reference model : application layer / The presentation layer / The session layer / Transport layer / The network layer / The link layer / The physical layer

TCP/IP Five layer model : application layer / Transport layer / The network layer / The link layer / The physical layer

application layer : Responsible for how to communicate between applications ;HTTP/FTP/DNS/DHCP......

Transport layer : Responsible for data transmission between processes ;TCP/UDP

The network layer : Responsible for address management and routing ;IP; Router

The link layer : Responsible for data transmission between adjacent devices ; Ethernet protocol ; Switch

The physical layer : Responsible for the transmission of physical photoelectric signals ; Ethernet protocol ; A hub  

7. Network byte order

Byte order :cpu The access order of data in bytes in memory

Host byte order : The size of a host byte order depends on cpu framework

Byte order is divided into big end byte order and small end byte order ; Big endian byte order : The low address stores the high address ; Small endian byte order : The low address stores the low address

The communication between hosts with different host byte order is easy to cause data ambiguity , Byte order standard in network communication ( Convert the byte order of your own data into standard byte order before transmission ) To avoid data ambiguity caused by different byte order

8. The transport layer TCP And UDP agreement

TCP--- Transmission control protocol --- Connection oriented , Reliable transmission , Byte stream oriented

UDP-- User datagram protocol --- There is no connection , unreliable , For datagram

difference :TCP Ensure reliable transmission , But the transmission speed is not UDP fast ;

        TCP Applied to high security scenarios ,UDP Applied to scenes with high real-time requirements

原网站

版权声明
本文为[Exy-]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130620441482.html