ภาพรวม
Client-Server vs P2P
Process
Addressing processes
Socket
App ↔ Transport
TCP vs UDP
TLS
ภาพรวมบท Application Layer
network app principles
Web / HTTP
Email / SMTP / IMAP
DNS
video streaming / CDN
socket programming (UDP / TCP)
ตัวอย่างแอปในชีวิตประจำวัน: social media · web · messaging · email · เกมออนไลน์ · streaming (YouTube/Netflix) · P2P file sharing · VoIP · video conferencing · internet search · remote login
สถาปัตยกรรม: Client-Server vs P2P
Client-Server
เซิร์ฟเวอร์: เป็น always-on host มี permanent IP address มักอยู่ใน data center เพื่อรองรับการขยายตัว
ไคลเอนต์: เชื่อมต่อเป็นครั้งคราว อาจมี dynamic IP ไม่คุยกันเองโดยตรง
ตัวอย่าง: HTTP, IMAP, FTP
P2P (Peer-to-Peer)
ไม่มีเซิร์ฟเวอร์ส่วนกลางที่เปิดตลอดเวลา
อุปกรณ์ปลายทางคุยกันเองโดยตรง
self-scalability: peer ใหม่เพิ่มทั้งความสามารถให้บริการและความต้องการใช้บริการ
จัดการซับซ้อนกว่า เพราะ IP เปลี่ยนได้ตลอด
ตัวอย่าง: BitTorrent, blockchain
Process และการสื่อสารระหว่างโปรเซส
Process คือโปรแกรมที่รันอยู่บนโฮสต์
ในเครื่องเดียวกัน: คุยกันผ่าน Inter-Process Communication (IPC) ซึ่งควบคุมโดย OS
ต่างเครื่อง: คุยกันด้วยการแลกเปลี่ยนข้อความ (messages )
Client process
ฝ่ายเริ่มการสื่อสาร
Server process
ฝ่ายรอรับการติดต่อ
Addressing processes
IP address ระบุได้แค่ระดับเครื่อง/โฮสต์เท่านั้น (Network Layer) แต่หนึ่งเครื่องรันได้หลายโปรเซสพร้อมกัน จึงต้องใช้คู่ "IP address + Port Number" ในการระบุตัวตนที่แน่นอนของโปรเซสผ่านเครือข่าย
ตัวตนของ process บนเครือข่าย = IP address + Port number
เปรียบเทียบ:
IP = บ้านเลขที่ ·
Port = หมายเลขห้อง ·
ส่วนภายในเครื่องเองใช้ Process ID (PID)
Socket
Socket คือจุดที่ process ส่ง/รับข้อความ เปรียบเหมือนประตู
เหนือ socket แอปพลิเคชันควบคุม
ส่วนของแอปพลิเคชัน (process)
ใต้ socket OS ควบคุม
transport, network, link, physical
แอปพลิเคชันกับ Transport protocol
บริการของ TCP และ UDP
TCP service
reliable transport
flow control
congestion control
connection-oriented
ไม่รับประกัน: timing, throughput ขั้นต่ำ, security
UDP service
unreliable data transfer
ไม่มี: reliability, flow control, congestion control, timing, throughput guarantee, security หรือ connection setup ใดๆ
Securing TCP ด้วย TLS
TLS (Transport Layer Security) เข้ารหัสการเชื่อมต่อ TCP ให้ data integrity และ endpoint authentication
TLS ทำงานอยู่ที่ application layer — แอปเรียกใช้ TLS library ซึ่งใช้ TCP อีกที
cleartext ที่ส่งเข้า socket จะถูกเข้ารหัสก่อนวิ่งออกอินเทอร์เน็ต