hệ điều hành,david mazieres,www scs stanford edu Administrivia • Project 3 due Friday noon For longer extensions, please email cs140 staff • Stop by “working office hours” this week Today (Monday) 4 6[.]
Administrivia • Project due Friday noon - For longer extensions, please email cs140-staff • Stop by “working office hours” this week - Today (Monday) 4-6pm in Gates 498 - Wednesday 3:30-5:30pm in Gates 167 • Project goes out at end of week • This Friday will have section on project CuuDuongThanCong.com https://fb.com/tailieudientucntt 1/35 Networks • What is a network? - A system of lines/channels that interconnect - E.g., railroad, highway, plumbing, communication, telephone, computer • What is a computer network? - A form of communication network—moves information - Nodes are general-purpose computers • Computer networks are particularly interesting - You can program the nodes - Very easy to innovate and develop new uses of network - Contrast: Telephone network—can’t program most phones, need FCC approval for new devices, etc CuuDuongThanCong.com https://fb.com/tailieudientucntt 2/35 Physical connectivity • Computers send bits over physical links - E.g., Coax, twisted pair, fiber, radio, - Bits may be encoded as multiple lower-level “chips” • Two categories of physical links - Point-to-point networks (e.g., fiber, twisted pair): - Shared transmission medium networks (e.g., coax, radio): ⊲ Any message can be seen by all nodes ⊲ Allows broadcast/multicast, but introduces contention • One implication: speed of light matters! - ∼ 300, 000 km/sec in a vacum, slower in fiber ≥ ∼ 15 msec SF −−−−−−−−−−−−−→ NYC Moore’s law does not apply! CuuDuongThanCong.com https://fb.com/tailieudientucntt 3/35 Bandwidth-delay • Network delay over WAN will never improve much • But throughput (bits/sec) is constantly improving • Can view network as a pipe Delay Bandwidth - For full utilization want # bytes in flight ≥ bandwidth×delay (But don’t want to overload the network, either) • What if protocol doesn’t involve bulk transfer? - E.g., ping-pong protocol will have poor throughput • Another implication: Concurrency & response time critical for good network utilization CuuDuongThanCong.com https://fb.com/tailieudientucntt 4/35 Indirect connectivity • Rarely have direct physical connection to destination • Instead, communications usually “hop” through multiple devices source −−−→ switch −−−−→ destination - Allows links and devices to be shared for multiple purposes - Must determine which bits are part of which messages intended for which destinations • Circuit switched networks provide virtual links - E.g., old telephone network when numbers dialed • Packet switched networks - Pack a bunch of bytes together intended for same destination - Slap a header on packet describing where it should go - Most networks today are packet switched CuuDuongThanCong.com https://fb.com/tailieudientucntt 5/35 Example: Ethernet • Originally designed for shared medium (coax) - Medium Access Control (MAC) protocol governs access to coax - E.g., don’t transmit when someone else is - If you collide, used randomized backoff and try again • Vendors give each device a unique 48-bit MAC address - Specifies which node should receive a packet • Packet format: 64 48 48 16 Preamble Dest addr Src addr Type 32 Body CRC - Preamble helps device recognize start of packet - CRC allows card to ignore corrupted packets - Body up to 1,500 bytes for same destination - All other fields must be set by sender’s OS (NIC cards tell the OS what the card’s MAC address is, Special addresses used for broadcast/multicast) CuuDuongThanCong.com https://fb.com/tailieudientucntt 6/35 Why Ethernet is insufficient • Ethernet Limits A B C - 2,500m diameter - 100 nodes • Can bridge multiple Ethernets Port Bridge Port - First time you see destination address, send packet to all segments - Then learn where devices are, and avoid forwarding useless packets X Y Z • A switch is like a bridge with n > ports - Widely used within organizations - But could never scale to the size of the Internet • Moreover, need to communicate across networks - E.g., laptop w DSL or wireless contacting server w Ethernet CuuDuongThanCong.com https://fb.com/tailieudientucntt 7/35 Internet Protocol (IP) • IP used to connect multiple networks - Runs over a variety of physical networks - Most computers today speak IP • Every host has a unique 4-byte IP address - (Or at least thinks it has, when there is address shortage) - E.g., www.ietf.org → 132.151.6.21 • Packets are routed based on destination IP address - Address space is structured to make routing practical at global scale S - E.g., 171.66.*.* goes to Stanford - So packets need IP addresses in addition to MAC addresses CuuDuongThanCong.com D https://fb.com/tailieudientucntt 8/35 Layering • Stick packets inside packets - E.g., an Ethernet packet may encapsulate an IP packet - An IP router forwards a packet from one Ethernet to another, creating a new Ethernet packet containing the same IP packet - In principle, an inner layer should not depend on outer layers E.g., IP packets should be independent of Ethernet [Annoyingly, TCP (next) has a checksum that violates this] CuuDuongThanCong.com https://fb.com/tailieudientucntt 9/35 ARP [RFC826] • When forwarding an IP packet from Ethernet A to Ethernet B, what MAC address should you use? - If destination host physically connected, use its MAC address - Otherwise, use MAC address of next router (given IP address) • Must map IP addresses into physical addresses • ARP – address resolution protocol - Broadcast request for MAC address of IP address - Everybody learns the requesting node’s MAC address (since broadcast request has requester’s MAC and IP addresses) - Target machine responds with its MAC address • OS keeps ARP cache w IP→MAC addr mappings - Periodically discard entries that have not been refreshed - E.g., run “arp -a” on Unix to see contents of ARP cache CuuDuongThanCong.com https://fb.com/tailieudientucntt 10/35 ... Email: 25 - Finger: 79 - Web / HTTP: 80 • Example: Interacting with www .stanford. edu - Browser resolves IP address of www .stanford. edu (171.67.216.15) - Browser connects to TCP port 80 on 171.67.216.15... Address space is structured to make routing practical at global scale S - E.g., 171.66.*.* goes to Stanford - So packets need IP addresses in addition to MAC addresses CuuDuongThanCong.com D https://fb.com/tailieudientucntt