The Internet and how data travels
The Internet
- The Internet is a huge network of computers that are joined together.
- No single computer is in charge. Many computers share the work.
- When you open a web page, your data travels across many of these computers.
อินเทอร์เน็ต
- อินเทอร์เน็ต คือเครือข่ายคอมพิวเตอร์ขนาดใหญ่ที่เชื่อมต่อกัน
- ไม่มีคอมพิวเตอร์เครื่องใดเป็นผู้ดูแล มีหลายเครื่องแบ่งเบาภาระงาน
- เมื่อเปิดหน้าเว็บ ข้อมูลของคุณเดินทางผ่านคอมพิวเตอร์เหล่านี้หลายเครื่อง
Data is split into packets
- Big data does not travel in one piece.
- It is cut into small pieces called packets.
- Each packet carries a bit of the data, plus an address (where it goes) and a number (its order).
ข้อมูลถูกแบ่งเป็นแพ็กเก็ต
- ข้อมูลขนาดใหญ่ไม่เดินทางเป็นก้อนเดียว
- มันถูกตัดเป็นชิ้นเล็กๆ ที่เรียกว่า แพ็กเก็ต
- แต่ละแพ็กเก็ตพกข้อมูลบางส่วน plus an address (where it goes) and a number (its order)
Your message: "HELLO FRIEND"
Split into packets:
[1] "HELL" to: 203.0.113.7
[2] "O FR" to: 203.0.113.7
[3] "IEND" to: 203.0.113.7
Routing: many paths
- Routing means choosing a path for each packet through the network.
- Packets pass through many computers called routers on the way.
- Different packets can take different paths to the same place.
การ-route: หลายเส้นทาง
- Routing (การกำหนดเส้นทาง) หมายถึงการเลือกเส้นทางสำหรับแต่ละแพ็กเก็ตผ่านเครือข่าย
- แพ็กเก็ตจะผ่านคอมพิวเตอร์หลายเครื่องที่เรียกว่า routers (เราเตอร์) ในระหว่างทาง
- แพ็กเก็ตที่แตกต่างกันสามารถใช้ เส้นทางที่แตกต่างกัน ไปยังจุดหมายเดียวกันได้
[You] --- router A --- router B --- [Website]
\ /
--- router C --- router D -
Packet 1 may go A -> B.
Packet 2 may go C -> D.
Both still arrive.
Redundancy and fault tolerance
- Redundancy means there is more than one path between two points.
- Because of this the Internet has fault tolerance: it keeps working even if one link fails.
- If router B breaks, packets just use another route, like C -> D.
ความซ้ำซ้อนและการทนต่อความผิดพลาด
- Redundancy (ความซ้ำซ้อน) หมายถึงการมีมากกว่าหนึ่งเส้นทางระหว่างจุดสองจุด
- เนื่องจากสิ่งนี้ อินเทอร์เน็ตจึงมี fault tolerance (ความสามารถในการทนต่อความผิดพลาด): ทำงานต่อไปได้แม้ว่าลิงก์ใดลิงก์หนึ่งจะล้มเหลว
- หากเราเตอร์ B ล้มเหลว แพ็กเก็ตก็จะใช้เส้นทางอื่น เช่น C -> D แทน
[You] --- router A --- (router B BROKEN)
\
--- router C --- router D --- [Website]
The path through B fails.
Packets still arrive through C -> D.
TCP/IP: the rules
- Computers must agree on rules so they can talk. We call a set of rules a protocol.
- IP (Internet Protocol) gives every computer an address and helps send each packet.
- TCP (Transmission Control Protocol) checks that all packets arrive and puts them back in order.
TCP/IP: กฎกติกา
- คอมพิวเตอร์ต้องตกลงกันเรื่อง rules (กฎกติกา) เพื่อสื่อสารกันได้ เราเรียกชุดกฎเหล่านี้ว่า protocol (โปรโตคอล)
- IP (Internet Protocol) ให้ address (ที่อยู่) แก่คอมพิวเตอร์ทุกเครื่องและช่วยส่งแพ็กเก็ตแต่ละตัว
- TCP (Transmission Control Protocol) ตรวจสอบว่าแพ็กเก็ตทั้งหมดมาถึงแล้วจัดเรียงใหม่ in order (ตามลำดับ)
Packets arrive (maybe out of order):
[3] "IEND" [1] "HELL" [2] "O FR"
TCP reorders them by number:
[1] "HELL" + [2] "O FR" + [3] "IEND"
= "HELLO FRIEND"
HTTP: the web
- The web (World Wide Web) is the pages and links you open in a browser.
- The web uses a protocol called HTTP (HyperText Transfer Protocol).
- Your browser sends an HTTP request ("please give me this page"); the server sends an HTTP response (the page).
HTTP: เวิลด์ไวยาฯ
- The web (เวิลด์ไวยาฯ) คือหน้าเว็บและลิงก์ที่คุณเปิดในบราウเซอร์
- เวิลด์ไวยาฯ ใช้โปรโตคอลที่เรียกว่า HTTP (HyperText Transfer Protocol)
- บราウเซอร์ของคุณส่ง request (คำขอ) แบบ HTTP (“กรุณาส่งหน้าเว็บนี้ให้ฉัน”); เซิร์ฟเวอร์ส่ง response (คำตอบ) แบบ HTTP (หน้าเว็บนั้น)
Why this design is strong
- No single point controls everything, so there is no single point to break the whole Internet.
- Many paths + packets = the network can route around problems.
- Shared rules (TCP/IP, HTTP) let very different computers work together.
ทำไมการออกแบบนี้ถึงแข็งแกร่ง
- ไม่มีจุดเดียวที่ควบคุมทุกอย่าง ดังนั้นจึงไม่มีจุดเดียวที่จะทำให้อินเทอร์เน็ตล่มทั้งระบบ
- หลายเส้นทาง + แพ็กเก็ต = เครือข่ายสามารถ route around (หลีกเลี่ยง) ปัญหาได้
- กฎร่วมกัน (TCP/IP, HTTP) ทำให้คอมพิวเตอร์ที่แตกต่างกันมากสามารถทำงานร่วมกันได้
Key words
- Packet: a small piece of data with an address and an order number.
- Routing: choosing a path for packets through routers.
- Redundancy / fault tolerance: many paths, so one failure does not stop the network.
- TCP/IP: rules to send packets and reassemble them in order.
- HTTP: the rules the web uses to request and send pages.
คำศัพท์สำคัญ
- Packet (แพ็กเก็ต): ชิ้นส่วนข้อมูลขนาดเล็กที่มีที่อยู่และหมายเลขลำดับ
- Routing (การกำหนดเส้นทาง): การเลือกเส้นทางสำหรับแพ็กเก็ตผ่านเราเตอร์
- Redundancy / fault tolerance (ความซ้ำซ้อน/ทนต่อความผิดพลาด): มีหลายเส้นทาง ดังนั้นความล้มเหลวหนึ่งครั้งจะไม่หยุดยั้งเครือข่าย
- TCP/IP: กฎสำหรับการส่งแพ็กเก็ตและประกอบกลับเป็นลำดับ
- HTTP: กฎที่เวิลด์ไวยาฯ ใช้สำหรับขอและส่งหน้าเว็บ
Common mistakes
- Data is split into packets that travel separately and are reassembled.
- The Internet and the World Wide Web are not the same thing.
ข้อผิดพลาดที่พบบ่อย
- ข้อมูลถูกแบ่งเป็นแพ็กเก็ตที่เดินทางแยกต่างหากและถูกประกอบกลับเข้าด้วยกัน
- อินเทอร์เน็ตและเวิลด์ไวยาฯ ไม่ใช่สิ่งเดียวกัน
Now you try
- These tasks model how data really travels: split it, reassemble it, and route around a failure.
- Press Check answer to test your code.
ลองดูเลย
- งานเหล่านี้จำลองวิธีการเดินทางของข้อมูลจริง: แบ่งข้อมูล, ประกอบกลับ, และหลีกเลี่ยงความล้มเหลว
- กด Check answer เพื่อทดสอบโค้ดของคุณ
Data travels in packets · ข้อมูลเดินทางในแพ็กเก็ต
The Internet splits data into packets that are routed and reassembled. · Internet แบ่งข้อมูลออกเป็น packets ที่ถูก routing และประกอบกลับ
TCP puts packets back in order by their number. packets is a list of [order, text] pairs that arrived shuffled. Write reassemble(packets) that sorts them by order and returns the joined text. Example: reassemble([[2, "O FR"], [1, "HELL"], [3, "IEND"]]) is "HELLO FRIEND". · TCP จัดแพ็กเก็ตใหม่ตาม หมายเลข packets เป็น list ของ [order, text] คู่ที่เข้ามาแบบสลับกัน เขียน reassemble(packets) ที่ sort ตาม order และ return ข้อความที่ join แล้ว ตัวอย่าง: reassemble([[2, "O FR"], [1, "HELL"], [3, "IEND"]]) คือ "HELLO FRIEND"
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่
Big data is cut into fixed-size packets. Write split(text, size) that returns a list of [order, chunk] pairs (order starts at 1), each chunk at most size characters. Example: split("HELLO FRIEND", 4) is [[1, "HELL"], [2, "O FR"], [3, "IEND"]]. · Big data ถูกแบ่งเป็น packets ขนาดคงที่ เขียน split(text, size) ที่ return list ของ [order, chunk] คู่ (order เริ่มที่ 1), แต่ละ chunk ไม่เกิน size ตัวอักษร ตัวอย่าง: split("HELLO FRIEND", 4) คือ [[1, "HELL"], [2, "O FR"], [3, "IEND"]]
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่
Redundancy gives more than one path, so the network can route around a failure. paths is a list of routes (each a list of router names). A route works only if it avoids the broken router. Write working_routes(paths, broken) returning the routes that do not contain broken. · Redundancy ให้หลายเส้นทาง ทำให้ network สามารถ bypass การล้มเหลว paths เป็น list ของ routes (แต่ละ route เป็น list ชื่อ router) Route ใช้งานได้ก็ต่อเมื่อหลีกเลี่ยง broken router เขียน working_routes(paths, broken) ที่ return routes ที่ไม่ มี broken
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่