Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ระบบเครือข่าย >> ระบบเครือข่าย

HTTP Fundamentals: คู่มือครบวงจรสู่ Telecommunication ใน Computer Systems

โดย Cher Don

รู้จัก Open Systems Interconnection Model

HTTP Fundamentals: คู่มือครบวงจรสู่ Telecommunication ใน Computer Systems

Overview

ตลอด Series นี้ เราจะครอบคลุม Basics เช่น:
(Part 1) DNS ทำงานอย่างไร?
(Part 2) Network Stack, OSI Model [You are here!]
(Part 3) HTTP Methods และ Formats
(Part 4) Client Identification
(Part 5) Basic/Digest Authentication
(Part 6) HTTPS ทำงานกับ SSL/TLS

OSI Model

OSI Model เป็น Standardized Model สำหรับ Telecommunication ใน Computer Systems ไม่สนใจ Underlying Technology แต่สนใจ Layers ที่เกี่ยวข้องกับ Communication มาสำรวจ Layers ต่างๆ ใน OSI Model:

HTTP Fundamentals: คู่มือครบวงจรสู่ Telecommunication ใน Computer Systems Typical 5-Layered OSI Model

1. Application Layer

Layer นี้อนุญาตให้ Applications Communicate ผ่าน Network เมื่อ Connection Established แล้ว เช่นจาก Web Browser (Application) ไป Server Protocols ใน Layer นี้ เช่น HTTP และ TELNET

HyperText Transfer Protocol (HTTP)

ชุด Rules สำหรับ Transfer Files ผ่าน Internet เช่นเมื่อ Enter URL ใน Browser Browser ส่ง HTTP Request ขอ Webpage Host จะ Return Webpage พร้อม Elements ทั้งหมดภายใน: Images, Text, Videos, Styling Fonts ฯลฯ

2. Transport Layer

Layer นี้รับผิดชอบ Host-to-Host Communication ของ Messages Protocols ใน Layer นี้ เช่น TCP และ UDP

Transmission Control Protocol (TCP)

Connection-Oriented Protocol ที่พบบ่อยที่สุด กำหนดวิธี Establish และ Maintain Network Conversation รับผิดชอบ Establish Connection (เรียกว่า Socket) ระหว่าง Client และ Host ผ่าน 3-Way Handshake

HTTP Fundamentals: คู่มือครบวงจรสู่ Telecommunication ใน Computer Systems

User ขอ Data ส่ง SYN Data Packet ไป Server ขอ Synchronization Server Respond SYN-ACK กลับ User แสดงว่า Acknowledged Packet และอยาก Connect ด้วย Connection Established เมื่อ User ส่ง ACK สุดท้ายไป Server

TCP พบบ่อยที่สุดเพราะ Elegance สามารถเสนอ:

Connection-Oriented Communication
Establish Handshake Protocol ระหว่าง End-points ให้แน่ใจว่า Connected ก่อน Exchange Data และ Transmit เป็น Data Stream (Data Packets)

Reliability
ใช้ Checksums ให้แน่ใจว่า Data Packets Transmitted และ Received เหมือนกัน หาก Missing/Corrupted Packets จะ Request Re-transmission ส่ง NACK Message กลับ Sender

Order
Data Packets Numbered และ Transmitted TCP ให้แน่ใจว่า Received Packets Re-ordered ก่อน Deliver ให้ Application

Flow Control
อัตรา Data Transmission Regulated เพื่อ Efficiency และป้องกัน Buffer Overruns/Underruns (Data ส่งเร็วกว่าที่ Receiver Process ได้ และ Vice Versa) Mechanics อธิบายใน TCP Slow Start Section

Multiplexing
ส่ง Multiple Streams ของ Information พร้อมกันบน Socket เดียวกัน ผ่าน Different Ports บน Socket จะอภิปรายความต่าง Multiplexing และ Pipelining ต่อไป

User Datagram Protocol (UDP)

คล้าย TCP แต่เป็น Connection-less Protocol ตรงข้าม TCP ทั้งหมด ทำให้ Unreliable และ Unordered Dropped Packets ไม่ Re-transmit ทำให้ Data มี Gaps

HTTP Fundamentals: คู่มือครบวงจรสู่ Telecommunication ใน Computer Systems

แต่นั้นทำให้เหมาะสำหรับ Time-Sensitive Applications เช่น Voice Calls ผ่าน Internet (VoIP) เพราะไม่ต้อง 3-Way Handshake ก่อน Transmit ทำให้ Fast เพิ่มเติม Dropped Data Packets ไม่ใช่ปัญหาใน VoIP เพราะหูมนุษย์จัดการ Short Gaps จาก Dropped Packets ได้ดีมาก

3. Network Layer

Layer นี้รับผิดชอบ Data Routing Paths สำหรับ Network Connections 基本上 Move Data Packets ข้าม Network ด้วย Most Logical Path

Internet Protocol (IP)

กำหนด Structure ของ Data Packets และ Label ด้วย Source และ Destination Information

Source/Destination Information เป็น IP Addresses รูปแบบ 104.16.121.127 (IPv4) หรือ 2001:db8:0:1234:0:567:8:1 (IPv6)

4. Link/ Physical Layer

Layer นี้เป็น Root ของ OSI Model ข้อมูล Transmit ผ่าน LAN สำหรับ Link Layer และ Physical Signal เช่น Electrical, Mechanical Medium รูปแบบ Code Words หรือ Symbols ใน Physical Layer

Visualising Routes

ใช้ tracert google.com Trace Route จาก Client-side (คอมพิวเตอร์คุณ) ไป Host (google.com)

HTTP Fundamentals: คู่มือครบวงจรสู่ Telecommunication ใน Computer Systems

จากข้างบนเห็น Route เริ่มจาก Device 192.168.1.254 ไป Router 10.243.128.1 ผ่าน ISP ใน Portugal และต่อไป

Complementary Layers

TCP/IP Model

HTTP Fundamentals: คู่มือครบวงจรสู่ Telecommunication ใน Computer Systems TCP จะ Request Re-transmission Dropped Packets และ Re-order พวกเขา

IP รับผิดชอบ Structure ของ Data Packet เท่านั้น ไม่แก้ไขถ้า Packet Corrupt หรือ Dropped ที่นี่ TCP เข้ามา Number Data Packets ก่อนส่งไป Client ที่ Client Side TCP Request Re-transmission Lost/Corrupted Packets แล้ว Rearrange Data Packets

HTTP/TCP Model

เหมือนกล่าว HTTP ทำ Requests ผ่าน Connection ที่ TCP Handshake สร้าง แต่มัน Complement กันยังไง?

HTTP Persistent Connections
อนุญาต Multiple HTTP Request/Response บน Single TCP Connection แทนที่จะ Open New Connection ทุก Request/Response

HTTP Fundamentals: คู่มือครบวงจรสู่ Telecommunication ใน Computer Systems Sample Response สำหรับ Persistent Connection

ทำผ่าน HTTP Header ที่ Connection: Keep-Alive โดย Default Connection จะ Close เมื่อ Response อีกครั้งที่ Connection: Close ส่งหลัง Idle 30 Seconds

TCP Slow Start
เหมือนกล่าว TCP Support Flow Control ทำผ่าน TCP Slow Start ซึ่งเป็น Prevention สำหรับ Network Congestion

HTTP Fundamentals: คู่มือครบวงจรสู่ Telecommunication ใน Computer Systems

Sender มี Congestion Window (CWND) Receiver มี Receiver Window (RWND) หาก Data ใหญ่กว่า CWND/RWND จะมี Buffer Under/Overrun ตามลำดับ

ป้องกันนี้ Sender เริ่มส่ง Data Packet CWND เล็ก (CWND = 1) Probe Receiver หา RWND

Receiver Respond ACK Prompt Sender Double Data Packets ทุกครั้งจนไม่ได้รับ ACK จุดนี้ Optimum Number ของ Data Packets ค้นพบ ให้ Congestion Control Algorithms อื่นๆ รักษา Connection ที่ Speed นี้

Working Together
TCP Slow Start หา Optimum Data Packets ก่อน Connection Close ทำให้ Data จาก Host ไป Client Optimized โดยไม่ Risk Buffer Overrun (Data ส่งเร็วกว่ารับได้)

Other HTTP Features

HTTP Pipelining

HTTP Fundamentals: คู่มือครบวงจรสู่ Telecommunication ใน Computer Systems

Feature ใน HTTP/1.1 อนุญาต Multiple Requests ส่งพร้อมกันบน Socket เดียว โดยไม่ Wait Response แต่ถูก Replace โดย TCP Multiplexing ใน HTTP/2 ใหม่กว่า

Key Difference: ทั้งคู่ Allow Multiple Requests พร้อมกันบน Socket เดียว แต่ Pipelining ยังต้องการ Responses ส่งตามลำดับ หมายถึงถ้า Items Requested เรียง (A, B, C) Client ไม่ได้รับ Item C หาก Item B ไม่ Delivered Properly

ใน Multiplexing Order ไม่สำคัญ ทำให้ Delivery Time เร็วขึ้น

Methods เหล่านี้เหมาะกับ Idempotent Methods ซึ่ง Respond แยกจากจำนวนครั้งที่ Request — เช่น Request Webpage หลายครั้ง Respond Webpage เดียวกัน

Parallel Connections

เคยเปิด Webpage เห็น Multiple Components (Video Bar, Thumbnails, Buttons) Load Simultaneously?

HTTP Fundamentals: คู่มือครบวงจรสู่ Telecommunication ใน Computer Systems _Multiple Components Loading Simultaneously | Photo courtesy of Cloudflare Mobile SDK

ทำได้ด้วย Parallel Connections ที่มี Multiple TCP Connections Established พร้อมกัน ให้ Components Load Concurrently แทน Sequential

อย่างไรก็ตาม แม้ดู Load เร็ว อาจถูก Held Back โดย Bandwidth จำกัดของ Client หาก Parallel Connections ทั้งหมดแข่งขัน Bandwidth จำกัด แต่ละ Component จะ Load Proportionately Slower ทำให้ Zero Advantage ใน Total Loading Speed

Conclusion

ด้วย OSI Model เราเข้าใจ Big Picture ของ Networks ได้ง่าย และการ Interact กันจาก Hardware ถึง Software

โดยทั่วไปเป็น Teaching Tool ที่ยอดเยี่ยมและ Reference สำหรับ Troubleshooting Model นี้ยังมีประโยชน์สำหรับ Design เพราะ Investigate Functions ทุก Layer บังคับให้คิด Design Layer by Layer

สิ่งที่ผ่านมาคือ OSI 5-Layer Model แต่มี OSI 7-Layer Model ที่จัดการ Identification, Authentication และ Data Encryption ด้วย

นี่คือ Part 2 ของ HTTP Introductions Series อ่าน Part 1 เกี่ยวกับความสำคัญของ DNS Servers มาสำรวจ HTTP Requests Structure ใน Part 3!

Hi! ผมคือ Cher Don กำลังศึกษา Major Data Science ผมเป็น CTO ของ Paralegal Bot หาเว็บไซต์ได้ด้านล่าง Thanks for reading!

Piqued;
_Quality Content เราเสนอ Best Content สำหรับ Concepts ที่ยากต่อการเข้าใจ We've been there, and felt the same you do…_www.piqued.co

เรียนรู้เขียนโค้ดฟรี หลักสูตรโอเพนซอร์สของ freeCodeCamp ช่วยให้ผู้คนมากกว่า 40,000 คนได้งานเป็นนักพัฒนา เริ่มต้นได้เลย