Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Operating Systems - Networks

2,311 views

Published on

From the Operating Systems course (CMPSCI 377) at UMass Amherst, Fall 2007.

Published in: Technology, Education
  • Be the first to comment

Operating Systems - Networks

  1. 1. Operating Systems CMPSCI 377 Networks Emery Berger University of Massachusetts Amherst UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science
  2. 2. Networks Goal: Efficient, correct, robust message passing  between two separate nodes Local area network (LAN) – nodes in single  building, fast & reliable (Ethernet) Media: twisted-pair, coax, fiber  Bandwidth: 10-1,000MB/s  Wide area network (WAN) – nodes across large  geographic area (Internet) Media: fiber, microwave links, satellite channels  Bandwidth: 1.544MB/s (T1), 45 MB/s (T3)  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 2
  3. 3. Principles of Net Communication Data broken into packets (~ 1Kb)  Basic unit of transfer  Computers & routers control packet flow  Road analogy:  Packets = cars  Network = roads  Computer = traffic lights (intersection)  Too many packets on shared link/node =  traffic jam UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 3
  4. 4. Communication Protocols Protocol: agreed-upon rules for  communication Protocol stack: layers that comprise  networking software Each layer N provides service to layer N+1  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 4
  5. 5. Traditional Layers Application layer – applications that use the net  Presentation layer – data format conversion  (big/little endian) Session layer – implements communication strategy  (e.g., RPC) Transport layer – reliable end-to-end communication  Network layer – routing & congestion control  Data link control layer – reliable point-to-point  communication over unreliable channel Physical layer – electrical/optical signaling across “wire”  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 5
  6. 6. TCP/IP Protocol Stack Internet standard protocol stack  TCP: reliable protocol – packets received in order  UDP (user datagram protocol) – unreliable   No guarantee of delivery UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 6
  7. 7. Packet Format All info needed to  recreate original message Packets may arrive  out of order need sequence  number Data segment  contains headers for higher protocol layers & application data UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 7
  8. 8. Sockets Standard API for network programming  Duplex communication (2-way)  Can configure sockets to use UDP or TCP  UDP – best for lossy communication  Pings, video, audio, other multimedia  Sends datagrams (packets)  TCP – most stuff  Sends reliable stream of bytes  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 8
  9. 9. Socket communication Sockets (in TCP) send stream of bytes  Multiple sends may be combined  into one received message To send multiple application-level  messages, must have application level protocol E.g., 4-bytes = message type, 4-bytes =  message length, plus message UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 9
  10. 10. Client-side: using sockets Creates socket  int fd = socket (AF_INET, SOCK_STREAM, 0)  Converts hostname to IP address with  getaddrinfo getaddrinfo (name, portStr, NULL, portNum)  Connects to host  connect (fd, addr, len); // from getaddrinfo  Once connected, can send or recv  send (fd, data, amount, 0);  recv (fd, buf, len, 0);  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 10
  11. 11. Server-side: using sockets As before:  Create socket as before  Convert hostname to IP address with getaddrinfo  but in passive mode hint.ai_flags = AI_PASSIVE  getaddrinfo (name, portStr, &hint, &addrinfo)  Binds socket to address:  bind (fd, addr, len); // from getaddrinfo  Listens for connection:  listen (fd, 1); // number of waiting msgs  Accepts connection ) new socket  int newfd = accept (fd, addr, len);  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 11
  12. 12. Exercise Lamest web server ever  Wait for connections on localhost port 80  Read message until first newline (‘n’)  Send <html><body>Hello  world</body></html> Use:  int fd = socket (AF_INET, SOCK_STREAM, 0)  getaddrinfo (name, portStr, &hint, &addrinfo)  bind (fd, addr, addrlen)  int v = listen (fd, 1)  int newfd = accept (fd, addr, len)  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 12
  13. 13. Network Topologies Connection of nodes impacts:  Maximum & average communication time  Fault tolerance  Expense  Two basic topologies:  Bus (for LANs)  Point-to-point  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 13
  14. 14. Bus Network Topologies Bus nodes connect to common network  Linear bus – single shared link  Nodes connect directly to each other via bus  Inexpensive (linear in # of nodes)  Tolerant of node failures  Ethernet LAN  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 14
  15. 15. Bus Network Topologies Ring bus – single shared circular link  Same technology & tradeoffs as linear bus  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 15
  16. 16. Point-to-Point Network Topologies Fully-connected  Each message takes one “hop”  Node failure – no effect on communication with  others Expensive – impractical for WANs  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 16
  17. 17. Point-to-Point Network Topologies Fully-connected  Each message takes one “hop”  Node failure – no effect on communication with  others Expensive – impractical for WANs  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 17
  18. 18. Point-to-Point Network Topologies Fully-connected  Each message takes one “hop”  Node failure – no effect on communication with  others Expensive – impractical for WANs  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 18
  19. 19. Point-to-Point Network Topologies Fully-connected  Each message takes one “hop”  Node failure – no effect on communication with  others Expensive – impractical for WANs  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 19
  20. 20. Point-to-Point Network Topologies 2 1 3 4 Partially connected  Links between some, but not all nodes  Less expensive, less tolerant to failures  Single node failure can partition network  Several hops – requires routing  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 20
  21. 21. Point-to-Point Network Topologies I want to go 2 to Node 4! 1 3 4 Partially connected  Links between some, but not all nodes  Less expensive, less tolerant to failures  Single node failure can partition network  Several hops – requires routing  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 21
  22. 22. Point-to-Point Network Topologies I want to go 2 to Node 4! 1 3 4 Partially connected  Links between some, but not all nodes  Less expensive, less tolerant to failures  Single node failure can partition network  Several hops – requires routing  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 22
  23. 23. Point-to-Point Network Topologies Tree structure: network hierarchy  Messages fast between direct descendants  Max message cost?  Not failure tolerant  Any interior node fails – network partitioned  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 23
  24. 24. Point-to-Point Network Topologies Star network: all nodes connect to central node  Each message takes how many hops?  Not failure tolerant  Inexpensive – sometimes used for LANs  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 24
  25. 25. Point-to-Point Network Topologies One-directional ring  Given n nodes, max hops?  Inexpensive  Fault-tolerant?  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 25
  26. 26. Point-to-Point Network Topologies Bi-directional ring  Given n nodes, max hops?  Inexpensive  Fault-tolerant? One node? Two?  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 26
  27. 27. Point-to-Point Network Topologies Doubly-connected ring: nodes connected to  neighbors & one more distant Given n nodes, max hops?  Fault-tolerant?  More expensive  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 27
  28. 28. The End UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 28
  29. 29. Distributed Systems Distributed system: physically separate processors  connected by one or more communication links  no shared clock or memory P2 P1 P4 P3 Most systems today distributed in some way   e-mail, file servers, network printers, remote backup, web... UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 29
  30. 30. Parallel vs. Distributed Systems Tightly coupled systems: “parallel  processing” Processors share clock, memory, run one OS  Frequent communication  Loosely coupled systems: “distributed  computing” Each processor has own memory, runs  independent OS Infrequent communication  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 30
  31. 31. Advantages of Distributed Systems Resource sharing  Computational speedup  Reliability  Communication  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 31
  32. 32. Advantages of Distributed Systems Resource sharing  Resources need not be replicated  Shared files  Expensive (scarce) resources can be shared  Poster-size color laser printers  Processors present same environment to  user Keeping files on file server  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 32
  33. 33. Advantages, continued Computational speedup  n processors = n times computational power  SETI@home  Problems must be decomposable into  subproblems Trivial = embarrassingly parallel  Coordination & communication required  between cooperating processes Synchronization  Exchange of results  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 33
  34. 34. Advantages, continued Reliability  Replication of resources provides fault  tolerance One node crashes, user works on another one  Performance degradation but system available  Must avoid single point of failure  Single, centralized component of system  Example: central file servers  UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 34
  35. 35. Advantages, continued Communication  Users/processes on different systems can  communicate Mail, transaction processing systems like  airlines & banks, www UNIVERSITY OF MASSACHUSETTS AMHERST • Department of Computer Science 35

×