当前位置:网站首页>Network protocol: tcp/ip protocol
Network protocol: tcp/ip protocol
2022-07-26 19:16:00 【Lin Feifan 1998】
One . Network protocol
If you want to understand Socket, Be familiar with TCP/IP Transmission control protocol / Internet Protocol , Defines how the host connects to the Internet , A standard for how data is transferred between them .
TCP/IP Protocol reference model , Put all the TCP/IP The series of protocols are grouped into four abstraction layers : application layer , Transport layer , The network layer , Data link layer , Each abstraction layer is built on the services provided by the lower layer , And provide services for the higher level .
Why is the Internet layered ?
Set rules between layers ( Is the interface ), Each layer should do its own thing , Layers can evolve internally .
agreement : standard , Rules to follow
It is divided into several layers ?5 layer , Let's analyze this in detail 5 layer


Physical layer
The physical connection , Optical fiber / Cable, etc . The relay will be 0 and 1
Link layer
Make a rule 0 and 1 The way of reading .
Ethernet
- It's probably a group of signals as packets , Become a frame -Head-data
- Head: Description information ( sender --- The receiver )
- Data: Real data
- Data must be from network card to network card ( Each network card has Mac Address )
- Broadcast , Send it to all network cards of the LAN
The Internet is composed of multiple LANs . LAN is a sub network .
The network layer
- Solve different computers , In different LAN communication problems .
- IPV4 Determine which subnet it belongs to , independent IP More expensive . Every computer has one IP Address :192.168.1.1 altogether 32 Bit
- Put the frame inside data Divide into 2 block (Head Include IP Address + length ,data Real data )
- The frame length is limited , If exceeded , Will be broken into different bags , Every bag has it head And package serial number
Transport layer
- problem : Many programs in the computer use the network , Frame here , To which program ? There has to be something , Tell me to give that program .( The port change is shining ....)
- Guarantee : Information about a program on the computer , Send to a program on a computer .
- port :0~65535, among 0 To 1023 System use the . Ensure that procedures communicate with procedures
- host + port = Kit word (Socket),socket In fact, it is to ensure the interaction of programs distributed on different computers , Can do network application development
- UDP agreement , hold data Split into head+data(head Only put ports ). There is no guarantee that the data will be received . characteristic : Simple , reliable
- TCP agreement , Data accessibility , Make sure the data is not lost , Confirmation process . Complex version UDP. characteristic : Load inefficiency , Offset more resources , reliable .
application layer
http Examples of agreements , explain data The meaning of data . Appoint data What format is in it , What's the point .
Two . Network communication
Supersocket There are three main objects :Session,AppServer,Commands
- Session: Connection of each user , It's just one. Session
- AppServer:Socket Instance of the server
- Commands: The client sends back the command of data
The format of the message sent by the client :CommandName+ Space -+ Parameters 0+ Space + Parameters 1+ Space + Parameters N+\r\n
Server processing :CommandName Command class to handle
Heartbeat detection mechanism :
- Used to detect whether the client is disconnected , The client is online , The server sends a heartbeat packet within the interval , The server returned a reply .
- If the heartbeat cycle , received , The server thinks you are offline
边栏推荐
猜你喜欢

深度学习的数学基础

Brian behrendorf, general manager of openssf Foundation: it is estimated that there will be 420million open sources in 2026

(ICLR-2022)TADA! Time adaptive convolution for video understanding

Multi thread learning notes -1.cas

MySQL学习笔记-2.如何提高sql语句的查询性能

LeetCode简单题之验证回文字符串 Ⅱ

篇7:exited on DESKTOP-DFF5KIK with error code -1073741511.

一文详解MES系统给企业带来的5大好处,附应用场景

JS uses readLine to realize terminal input data
![[postgraduate entrance examination vocabulary training camp] day 14 - Panini, predict, access, apologize, sense, transport, aggregation](/img/fb/0338559494f31db8657f0e4767138b.png)
[postgraduate entrance examination vocabulary training camp] day 14 - Panini, predict, access, apologize, sense, transport, aggregation
随机推荐
深度学习的数学基础
2022 Shanghai safety officer C certificate operation certificate examination question bank simulated examination platform operation
Utility website recommendations
Brand new! Uncover the promotion route of Ali P5 Engineer ~p8 architect
篇7:exited on DESKTOP-DFF5KIK with error code -1073741511.
一些时序建模策略(一)
节省50%成本 京东云发布新一代混合CDN产品
2022年流动式起重机司机考试试题模拟考试平台操作
[postgraduate entrance examination vocabulary training camp] day 14 - Panini, predict, access, apologize, sense, transport, aggregation
Zbxtable 2.0 heavy release! 6 major optimization functions!
Arrangement of information security emergency plan
Tensorflow GPU 1.15 installation
.Net CLR GC 动态加载短暂堆阈值的计算及阈值超量的计算
Tensor Rt的int8量化原理
如何成为一名优秀的测试/开发程序员?专注谋定而后动......
2022 mobile crane driver test questions simulation test platform operation
图解用户登录验证流程,写得太好了!
当前占位,之后再写
Verification palindrome string II of leetcode simple question
2022t elevator repair examination questions and online simulation examination