1, the introduction





















Related articles:





  • “Network programming lazy introduction (A) : Fast understanding of network communication protocol (PART 1)” (* recommended)
  • “Network programming lazy introduction (2) : Fast understanding of network communication protocol (Part 2)” (* recommended)
  • “Network programming lazy introduction (six) : The history of the most popular hub, switch, Router function principle introduction”
  • Web Programming for lazy People (9) : Why use MAC Addresses when you have IP Addresses?


2. About the author



The deer





  • Wechat official account: Deer animation programming
  • Github address: github.com/luxiangqian…
  • Personal blog: Luxiangqiang.com/


3. Series of articles



This is the seventh article in a series that Outlines the following:





  • Learn TCP three handshakes and four waves with Animation
  • Introduction to Brain-dead Network Programming (II) : What are We Reading and writing when We read and write sockets?
  • Introduction to Brain-dead Network Programming (3) : Some must-know HTTP protocols
  • Introduction to Web Programming (4) : A Quick Understanding of HTTP/2 Server Push
  • Introduction to Brain-dead Network Programming (5) : The Ping command you Use every Day, What is it?
  • Introduction to Network Programming (6) : What is public IP and internal IP? What is NAT?
  • Introduction to Brain-dead Network Programming (7) : The Most Popular Computer Network layering in history


4. Why network hierarchy division?









































5. How is network stratification?





































6. What is the role of each layer?








6.1 the physical








6.2 Data Link Layer















6.2.1) MAC Address:


















6.2.2) Broadcast:











6.3 the network layer















6.3.1) IP protocol:
























6.3.2) Subnet mask:



































6.4 the transport layer





















6.4.1) UDP:












6.4.2) TCP protocol:











6.5 Application Layer Protocols

















7. What are the functional details of each layer?








7.1 the physical








7.2 Data Link Layer









7.2.1) Ethernet Protocol:



























Why is there a header in the data transmission? We want to know how the receiver can determine whether the data is sent to itself or not, so it only takes the header to determine. The header of a packet usually contains some identifying information about the packet, who the sender is and who the receiver is. The length of the header is fixed at 18 bytes, which means that some header identification information cannot be larger than 18 bytes.





Data, as the name implies, whatever data you want to send to the receiver is put into the packet, that is, the contents of the whole packet, such as files, strings and so on. The minimum length of the data part is 46 bytes and the maximum length is 1500 bytes. We might think that if less than 46 bytes is fine, what about more than 1500 bytes? Very simple, we divide into two packages (split), two packages can not store into three packages…



7.2.2) Broadcast:





























7.3 the network layer















7.3.1) IP protocol:



















IP packets are also divided into Head and Data:





  • 1) Header: The header of an IP packet is 20-60 bytes, including the version and IP address.
  • 2) Data: The maximum length of data is 65515 bytes. The maximum total length of the entire IP packet is 65535 bytes. It mainly stores the specific content of IP packets.









7.3.2) AND operation:
























7.3.3) ARP protocol:






Premise:











7.4 the transport layer















7.4.1) UDP:






The UDP protocol is also divided into Head and Data:





  • 1) Header: The length of the header is 8 bytes. The main storage of the sending and receiving port number;
  • 2) Data: the total length of the data part and the header part does not exceed 65535 bytes, which is just fit into an IP packet.
















7.4.2) TCP protocol:

















7.5 the application layer


















8. Write at the end









Continue with the following two articles, which should make your internal forces multiply:





  • Network Programming Lazy Introduction part 1: Quick Understanding of Network Communication Protocols part 1
  • “Network Programming Lazy Introduction ii: A Quick Understanding of Network Communication Protocols (Part II)”



In addition, regarding the layers and relationships of computer network protocols, we can take a look at the following two figures:














* For clear original images of the above two images, please see:
Computer Network Communication Protocol Diagram (Chinese Edition)


Appendix: More information on network programming basics



TCP/IP, rounding
Chapter 11 ·UDP: User datagram protocol



TCP/IP, rounding
Chapter 17: TCP: Transmission control Protocol



TCP/IP, rounding
Chapter 18: Establishment and termination of TCP connections



TCP/IP, rounding
Chapter 21. TCP Timeouts and retransmission



Once upon a time in technology: TCP/IP changed the world



Easy to Understand – In-depth understanding of TCP (part 1) : Theoretical basis



Easy to Understand – In-depth understanding of TCP (part 2) : RTT, sliding window, and congestion handling



Theory classic: TCP protocol three handshake and four wave process in detail



Connection between theory and practice: Wireshark captures packets to analyze TCP three-way handshake and four-way wave



Protocol Diagram of Computer Network Communication (Chinese Edition)



What is the maximum size of a packet in UDP?



P2P technology details (a) : NAT details – detailed principle, P2P introduction



(2) : P2P NAT traversal (hole) solution



P2P technology details (three) : P2P technology STUN, TURN, ICE details



Easy to Understand: Quickly understand the PRINCIPLE of NAT penetration in P2P technology



High performance network programming (a) : the number of concurrent TCP connections can be a single server



High performance Network programming (II) : The last 10 years, the famous C10K concurrent connection problem



High performance Network Programming (III) : In the next 10 years, it is time to consider C10M concurrency



High performance Network programming (IV) : Theoretical exploration of high performance network applications from C10K to C10M



High performance network programming (5) : read the I/O model of high performance network programming



High performance network programming (6) : understand the threading model of high performance network programming



Java BIO and NIO are hard to understand, right? Use code practice to show you, do not understand me to change!



Unknown Network Programming (I) : A Brief Analysis of the DIFFICULT Problems in TCP Protocol (Part I)



Unknown Network Programming (II) : A Brief Analysis of the DIFFICULT Problems in TCP Protocol (Part II)



Why TIME_WAIT and CLOSE_WAIT when closing TCP connections



Unknown network programming (iv) : In-depth analysis of TCP abnormal shutdown



Network programming unknown (5) : UDP connectivity and load balancing



Unknown network programming (6) : Understand UDP in depth and use it well



Unknown network programming (7) : How to make unreliable UDP reliable?



Hidden Network programming (8) : Deep decryption of HTTP from the data transport layer



Unknown network programming (9) : Theory and practice, comprehensive in-depth understanding of DNS



Quick Understanding of Network Communication Protocols (Part 1)



A Quick Understanding of Network Protocols (Part 2)



Network programming lazy introduction (three) : a quick understanding of the TCP protocol is enough



Network programming lazy starter (4) : Quickly understand the difference between TCP and UDP



Why UDP sometimes has an advantage over TCP



Network programming lazy entry (six) : the history of the most popular hub, switch, router function principle entry



Network programming lazy introduction (7) : simple, comprehensive understanding of HTTP protocol



Network programming lazy entry (eight) : teach you to write based on TCP Socket long connection



Network programming lazy introduction (nine) : popular explanation, IP address, why use MAC address?



Network programming lazy introduction (ten) : a bubble of urine time, quickly read the QUIC protocol



Technology Literacy: A new generation of UDP-based low latency Network Transport layer protocol – QUIC in detail



Making the Internet faster: A new generation of QUIC protocols shared in Tencent’s technology practices



Summary of optimization means of modern mobile terminal network short connection: request speed, weak network adaptation, security guarantee



Let’s talk about long connections in iOS network programming



Mobile IM Developers must read (1) : Easy to understand the “weak” and “slow” mobile web



Mobile IM Developers must read (ii) : Summary of the most comprehensive mobile weak Network optimization methods ever



IPv6 Technology details: Basic Concepts, Application Status, Technical Practice (Part I)



IPv6 Technology details: Basic Concepts, Application status, Technical Practice (Part 2)



From HTTP/0.9 to HTTP/2: Understand the history and design of the HTTP protocol



Take the network access layer design of online game server as an example to understand the technical challenges of real-time communication



To the next level: The network basics that a good Android programmer must know



Comprehensive understanding of mobile DNS domain name hijacking and other miscellaneous problems: technical principles, root causes, solutions, etc



Mobile DNS optimization practice of Meitu App: THE HTTPS request time is reduced by nearly half



Android programmers must know the network communication transport layer protocols – UDP and TCP



Introduction to Zero-Base Communication Technology for IM Developers (PART I) : 100 Years of Development of Communication Switching Technology (Part I)



Introduction to Zero-Base Communication Technology for IM Developers (II) : 100 Years of Development of Communication Switching Technology (II)



Introduction to Zero-base Communication Technology for IM Developers (III) : The Century-old changes of Chinese communication mode



Introduction to Zero-Base Communication technology for IM Developers (iv) : The evolution of mobile phones, the most comprehensive history of mobile terminals in history



Introduction to Zero-base Communication Technology for IM Developers (5) : 1G to 5G, 30 years of mobile communication technology evolution



Introduction to Zero-base Communication technology for IM developers (6) : Mobile terminal connector – “base station” technology



Introduction to Zero-Base Communication Technology for IM Developers (7) : The Swift Horse of Mobile Terminal — “Electromagnetic Wave”



Introduction to Zero-based Communication technology for IM Developers (eight) : Zero-based, the strongest “antenna” principle in history literacy



Introduction to Zero-Base Communication Technology for IM Developers (9) : “Core Network” — the Backbone of Wireless Communication Network



Introduction to Zero-Base Communication Technology for IM Developers (10) : Zero-base, the strongest 5G technology literacy in history



Why is WiFi signal bad? A text is understood!



Introduction to Basic Communication technology for IM Developers (12) : Networking? Network down? A text is understood!



Introduction to Zero-Base Communication Technology for IM Developers (13) : Why cell phone Reception is Poor? A text is understood!



How Hard is wireless On high-speed Trains? A text is understood!



Introduction to Zero-base Communication technology for IM Developers (15) : Understanding location technology, one article is enough



Baidu APP mobile terminal network in-depth optimization practice sharing (I) : DNS optimization chapter



Baidu APP mobile terminal network in-depth optimization practice sharing (II) : Network connection optimization



Baidu APP mobile terminal network in-depth optimization practice sharing (III) : mobile terminal weak network optimization chapter



Technology master Chen Shuo’s share: from shallow to deep, network programming learning experience dry summary



Can ruin your interview: Do you know how many HTTP requests can be made over a TCP connection?



Zhihu technology sharing: Zhihu high performance long connection gateway technology practice of ten million level concurrent



More of the same…