240 likes | 384 Views
CS423UG Operating Systems. Networking. Indranil Gupta Lecture 31 Nov 7, 2005. Content. Network Naming Routing Contention TCP. Datagrams vs Virtual Circuits. Virtual Circuit: Communication circuit that user assumes error free and in-order
E N D
CS423UG Operating Systems Networking Indranil Gupta Lecture 31 Nov 7, 2005
Content • Network • Naming • Routing • Contention • TCP CS 423UG - Operating Systems, Indranil Gupta
Datagrams vs Virtual Circuits • Virtual Circuit: • Communication circuit that user assumes error free and in-order • If a packet arrives out of order, it is held until its predecessors arrive. • Virtual circuit == circuit switching (e.g., telephone network) • Nodes need not be intelligent VC does all transmission • In some circumstances, order is less important than speed (order may even be unimportant in some applications). • Datagram: • Packets transported to destinations as isolated units (no ordering) • Message broken into several packets reassembled by end host. • The network does no error checking; that is done by the hosts. • Datagrams = store-and forwardpacket switching scheme. • Messages may arrive at their destination faster, since they will not be held up if out of order. • Requires more work from the end-nodes to ensure order CS 423UG - Operating Systems, Indranil Gupta
Network Hardware for Single Machine • Network Interface Card (NIC) • Includes some RAM to hold incoming and outgoing packets • Before packet transmitted, the packet must be fully copied from the main memory RAM to NIC RAM. • Note: Interconnection networks are synchronous once packet transmission begins, bits must flow at constant rate. • Same applies to incoming packets. • Network Interface cards also have one or more DMA channels or even a complete CPU. • The DMA channels copy packets between NIC board and the main memory RAM at high speeds. • If separate CPU, then main CPU can offload some work to network board, such as handling reliable transmission, etc. CS 423UG - Operating Systems, Indranil Gupta
Network Hardware for Distributed Systems • Local-Area Network (LAN) • Low latency for short messages • High bandwidth for long messages • Bus, Crossbar, ring, or star • E.g., 10, 100 Mbps(Ethernet), 100 Mbps (FDDI), 155 622 Mbps (ATM), 622Mbps 1 Gbps (HiPPI) , 802.11 a,b,g wireless LAN (WLAN) • Client-server configurations supported • Broadcast (send messages to all other nodes on this LAN) easy • Connects hosts, bridges, routers that are located close-by (e.g., CS dept. has one or few LANs) • Wide-Area Network (WAN) • Point to point (T1 (1.2Mbps), T3 (45Mbps), packet switched (ATM (155Mbps-10Gbps)) • Broadcast requires repeated message sends • High latency (speed of light and buffer sizes), medium/high-bandwidth. • E.g., UIUC has one (or a few) WANs. • Metropolitan-Area Network (MAN) • 100 Mbps FDDI, 155, 622 Mbps (ATM) • Low latency, high bandwidth, scalable. E.g, Chicago has one / few MANs CS 423UG - Operating Systems, Indranil Gupta
Specialized Network Nodes Form “internal nodes” in network graph • Intelligent Hubs • On a star Ethernet, filters out traffic not destined for specific host • Passive Hubs • On a star Ethernet, broadcasts every packet down each link • Bridges (sometimes Gateways) • Route between one kind of network and another • E.g., interconnect IP networks over T1 trunks and Ethernets • Routers • Switch packets between subnets. Make clever routing decisions. • Firewall • Filter packets based on IP numbers, applications, or port addresses. CS 423UG - Operating Systems, Indranil Gupta
Gateway CS 423UG - Operating Systems, Indranil Gupta
Low-Level Communication Software • Copying packets Big problem for high-performance networking • Copying latency (to and from RAM) can dominate • Kernel copying may double delay and half bandwidth • Solutions: • Map interface to user space allow user to bypass kernel write directly to interface board • BUT • Several processes may need access to interface (address space conflict) • Solution: Map the interface board into all processes that need it • But need to avoid race conditions (requires) synchronization mechanisms. Difficult!!! Hence, use this only if only one process needs the network board. • Also, • Kernel might need access to the network itself (e.g., to access file system). • Kernel and user sharing interface bad idea • Solution: Have two network interface boards, one mapped to user space for application traffic, one mapped to kernel space for OS traffic only. CS 423UG - Operating Systems, Indranil Gupta
User-Level Communication Software • Message passing paradigm is used : send and receive methods • send(dest, &mptr) - sends message, pointed to by mptr, to destination dest • Sender blocks until the mesage is sent. • receive(addr, &mptr) - receives message, pointed to by mptr. • The receiver listens at the address addr (consisting of CPU number and a process or port number) for incoming messages. Blocks until msg arrives. • Two types of calls • Blocking (also called synchronous calls) • Sending process suspended while message being sent • Similarly, receive does not return until msg received in buffer • Non-blocking calls (also called asynchronous calls) • Returns control before the message is sent. Interrupt triggerred when msg sent • Several choices on sending side: • Blocking send (CPU idle during message transmission) • Non-blocking send with copy (CPU time wasted for the extra copy) • Non-blocking send with interrupt ( programming difficult) • Copy on write (extra copy probable needed eventually) CS 423UG - Operating Systems, Indranil Gupta
Issues for Distributed Systems • Naming and name resolution • How do processes locate each other for communication ? • Need a good strategy to remember names of target • Routing strategies • How are messages sent through the network and passed through internal nodes so they reach the correct destination node? • Connection strategies • How do two processes send a sequence of messages? • Contention • How do we solve conflicts in the network? CS 423UG - Operating Systems, Indranil Gupta
Naming (or how Akamai makes $) • Logical Name • Often hierarchical name. cs.uiuc.edu is ``domain'' • Network Address (Internet IP address) • 128.174.240.** is ``cs.uiuc.edu'' • Physical Name (Network Address) • Ethernet address or Token Ring Address • Address processes/ports within system (host, id) pair • Domain name service (DNS) maps each logical name to IP address • In the Web, each URL maps to the IP address of server • Akamai maps to several Akamai servers that cache web content! (that’s how they make Millions of $$$$!) CS 423UG - Operating Systems, Indranil Gupta
Routing • Network is a graph • Sender and destination have many intermediate nodes • Routing algorithm at each intermediate node • Decides which neighbor to forward a packet to • Fixed Routing - Path set from one point to another • Desn't change unless h/w failure (E.g., telephone network) • Virtual Circuit - Path fixed for a communictn session. • E.g., Telephone networks • Dynamic Routing • Messages may go different routes (Internet datagrams) CS 423UG - Operating Systems, Indranil Gupta
Connection Strategies • Circuit switching • Like the inter-state roads or telephone system carriers • Link is dedicated for each communication. • Message Switching • Entire message routed hop-by-hop (like military convoy) • Temporary links established for each message transfer • Packet Switching • Variable length messages are broken down into packets. • Switching occurs per packet at each node • Packets reassembled into messages at destination CS 423UG - Operating Systems, Indranil Gupta
Contention - Collision Detect • On a LAN • Listen before you talk on the link. • During transmission, listen to ensure no parallel communication • When collision occurs, use back off strategy • To avoid busy wait, wait for random # of time slots • Random wait increases exponentially • With increasing retransmission attempts • Does not prevent starvation, but tries to. CS 423UG - Operating Systems, Indranil Gupta
Contention Free - Token Passing • Pass token around network – special msg • Analogous to passing microphone to talk • If a node has the token • Can transmit one packet but must then pass on the token. • Provides fair message transmission • Lost tokens must be replaced. • Use time out (problem: multiple tokens?) • Use election algorithm to choose a node to create a token. CS 423UG - Operating Systems, Indranil Gupta
Contention Free - Message Slots • Circulate empty messages continuously • Node grabs empty slot, fills it with message. • Receiving node removes message and replaces empty message. • Avoids separate packet and token transmission CS 423UG - Operating Systems, Indranil Gupta
Internet Protocol Stack • Network Protocol • IP version 4, coming version 6. • This protocol is responsible for transmitting IP datagrams. • Transport Protocols • User Datagram Protocol (UDP) • UDP/IP is an unreliable, connectionless transport protocol • Uses IP to transport datagrams and adds error correction • Uses protocol port address to specify destination process • Transmission Control Protocol (TCP) • TCP/IP is a reliable stream protocol for communicating • Achieves flow control and congestion control CS 423UG - Operating Systems, Indranil Gupta
TCP/IP Protocol Layers END USER APPLICATION FTP, TELNET, SMTP, NSP, SNMP Layers 5-7 TCP UDP Layers 4 IP Layers 1-3 IEEE802.X LAN/WAN CS 423UG - Operating Systems, Indranil Gupta
Robustness • Failure Detection • When lack of acknowledgment • Use hand-shaking and time-out schemes • Reconfiguration • Notification and updation of routing tables • Recovery from Failure • Repaired links and routers must be integrated into the system gracefully and smoothly • Else what can happen ? CS 423UG - Operating Systems, Indranil Gupta
Socket – what’s that? Client socket (146.86.5.2/1625) Web server socket (161.25.19.9/80) CS 423UG - Operating Systems, Indranil Gupta
Sockets • Communication endpoint • Machines don’t understand human users • Identifies end users as (IP Address + Port #) • Client-server • Server listens to a port, client connects to it • Telnet Port 23, ftp port 21, • HTTP (Web server) port 80 CS 423UG - Operating Systems, Indranil Gupta
Ports • Ports < 1024, standard • Ports > 1024, user created • All connections unique • (161.25.19.8:20) CS 423UG - Operating Systems, Indranil Gupta
Sockets • Connection-oriented (TCP) Sockets • Virtual circuit • Connectionless (UDP) Sockets • Datagrams – that’s all the Internet routers understand! • Multicast (UDP) Socket • Multicast=send a message to a group of IP addresses (not just one destination) • E.g., conference on yahoo messenger CS 423UG - Operating Systems, Indranil Gupta
Reminders • Reading for this lecture: Relevant parts of Section 8.3 • Reading for next lecture: See URL posted on website • If you have any remaining questions about MP3, please talk to/email the TAs. CS 423UG - Operating Systems, Indranil Gupta