450 likes | 551 Views
Networks. 15. Connecting Computers Using the Telephone Network. Local Computer. Remote Computer. CPU. CPU. Memory. Serial Port. Serial Port. Memory. Modem. Modem. Switched Telephone Network. Data Networks. CPU. CPU. Memory. Network Device. Network Device. Memory.
E N D
Networks 15 Operating Systems: A Modern Perspective, Chapter 15
Connecting Computers Using the Telephone Network Local Computer Remote Computer CPU CPU Memory Serial Port Serial Port Memory Modem Modem Switched Telephone Network Operating Systems: A Modern Perspective, Chapter 15
Data Networks CPU CPU Memory Network Device Network Device Memory Specialized Data Network • WANs, MANs, and LANs • Specialized communication protocols • Multidrop • Packet oriented • Looks like other devices… make it look like a file ... Operating Systems: A Modern Perspective, Chapter 15
Multidrop Network S S Network R R • Multiple senders • Can address multiple receivers Operating Systems: A Modern Perspective, Chapter 15
S S Data Packet Based R R Packet Network S S Telephone Circuit Based R R Operating Systems: A Modern Perspective, Chapter 15
Multidrop Packet Network • To transmit/receive: • Sender marshals data into a packet • Network interface hardware transforms data for physical transmission • Network deliver packets to variable destination • Receiver converts physical signal back into a data packet • Receiver unmarshals packet into data • Need a widely-agreed upon set of protocols Operating Systems: A Modern Perspective, Chapter 15
Protocol Tasks • Control information delivery rates • Pass data across networks • Provide fast/reliable IPC-like communication • Support logical byte streams • Create other models for communication • File transfer • Procedure call paradigm • Shared memory paradigm • Translate machine-dependent data representations • … and more … Operating Systems: A Modern Perspective, Chapter 15
Standardizing Protocols • ANSI X.25 • ARPAnet • ISO Open Systems Interconnect (OSI) model • Now widely used as a reference architecture • 7-layer model • Provides framework for specific protocols (such as IP, TCP, FTP, RPC, RSVP, …) Operating Systems: A Modern Perspective, Chapter 15
ISO OSI Model Application Application Presentation Presentation Session Session Transport Transport Network Network Data Link Data Link Physical Physical Operating Systems: A Modern Perspective, Chapter 15
ISO OSI Model Data Link Data Link Physical Physical Examples • Physical/Data Link layer networks: Ethernet, Wireless, ATM • Often called the “media access control” (MAC) layer Operating Systems: A Modern Perspective, Chapter 15
Low Level Protocols • Physical layer: Signaling technology • Data link layer: Frame management • All done in hardware • Examples • Ethernet • Token ring • X.25 • ATM Operating Systems: A Modern Perspective, Chapter 15
Ethernet (CSMA/CD) • Asynchronous • Carrier Sense • Multiple Access • Collision Detection • Backoff Operating Systems: A Modern Perspective, Chapter 15
Wireless • IEEE 802.11 (“WiFi”) • IEEE 802.15 (“Bluetooth”) Backbone Ad hoc networks Operating Systems: A Modern Perspective, Chapter 15
Stop-and-wait Flow Control Sender transmits a frame; Sender sets a time-out on the transmission; Sender waits for an ACKnowledgment; ... if (Sender receives ACKnowledgment) continue; if (frame times-out) Retransmit timed-out frame; (a) Transmitter Receiver accepts the frame; Receiver transmit the ACKnowledgment; (b) Receiver Operating Systems: A Modern Perspective, Chapter 15
ISO OSI Model Network Network Data Link Data Link Physical Physical Examples • Physical/Data Link layer networks: Ethernet, Token Ring, ATM • Network layer net: The Internet Operating Systems: A Modern Perspective, Chapter 15
Network Layer • Primary purpose is to combine networks • Internet protocol (IP) is dominant protocol • Creates an internet address space • Implements packet routing across networks Host X Network A Network B Network C Host R Host S Host Y Operating Systems: A Modern Perspective, Chapter 15
Addressing & Routing Host X 3b4e87 3b6209 Network A Network C 3b4e62 3b4e55 3b621a Host R Host Y • Host X does not know how to send to Host Y • Can send a frame to Host R for forwarding • What should it tell Host R? Operating Systems: A Modern Perspective, Chapter 15
Addressing & Routing 128.123.234.033 128.229.244.109 Host X To: 128.229.244.006 From: 128.123.234.033 Network Layer data 3b4e87 3b6209 Network A Network C 3b4e62 3b4e55 3b621a Host R Host Y 128.123.234.063 128.123.234.188 128.229.244.006 • Host X does not know how to send to Host Y • Can send a frame to Host R for forwarding • What should it tell Host R? • Internet address spans all machines Operating Systems: A Modern Perspective, Chapter 15
Addressing & Routing 128.123.234.033 To: 3b4e55 From: 3b4e87 128.229.244.109 Host X To: 128.229.244.006 From: 128.123.234.033 Network Layer data 3b4e87 3b6209 Network A Network C 3b4e62 3b4e55 3b621a Host R Host Y 128.123.234.063 128.123.234.188 128.229.244.006 • Host X does not know how to send to Host Y • Can send a frame to Host R for forwarding • What should it tell Host R? • Internet address spans all machines • Send encapsulated packet to Host R with Host Y Operating Systems: A Modern Perspective, Chapter 15
Addressing & Routing 128.123.234.033 128.229.244.109 Host X 3b4e87 3b6209 Network A Network B Network C 3b4e62 3b4e55 3b621a Host R Host S Host Y 128.123.234.063 128.123.234.188 128.229.244.006 • Host X does not know how to send to Host Y • Can send a frame to Host R for forwarding • What should it tell Host R? • Internet address spans all machines • Send encapsulated packet to Host R with Host Y Operating Systems: A Modern Perspective, Chapter 15
Addressing & Routing 128.123.234.033 128.229.244.109 Host X 3b4e87 3b6209 Network A Network B Network C To: 3b621a From: ... 3b4e62 3b4e55 3b621a Host R Host Y To: 128.229.244.006 From: 128.123.234.033 Network Layer data 128.123.234.063 128.123.234.188 128.229.244.006 • Host X does not know how to send to Host Y • Can send a frame to Host R for forwarding • What should it tell Host R? • Internet address spans all machines • Send encapsulated packet to Host R with Host Y • Data Link frame is received by Host Y Operating Systems: A Modern Perspective, Chapter 15
More on the Network Layer • Implements internet addressing & routing • ARPAnet IP protocol is dominant – the foundation for the Internet • Intermediate hosts are called gateways • Connected to two or more networks • Runs IP routing software • Read pages 496-501 Operating Systems: A Modern Perspective, Chapter 15
Using Data Link and Network Layer Addresses Network Layer 0x80C31A80837E 128.123.234.012 Data Link Layer Frame Data Link Layer Network Layer Packet Operating Systems: A Modern Perspective, Chapter 15
ISO OSI Model Transport Transport Network Network Data Link Data Link Physical Physical Examples • Physical/Data Link layer networks: Ethernet, Token Ring, ATM • Network layer net: The Internet • Transport layer net: TCP-based network Operating Systems: A Modern Perspective, Chapter 15
Transport Layer • Provides yet another address extension • IP references only networks and hosts • Transport layer adds ports -- logical endpoints • Address form is <net, host, port> • Two primary protocols (both from ARPAnet) • User Datagram Protocol (UDP) • User-space interface to IP packets • No guarantee that packet will be delivered • Transmission Control Protocol (TCP) • Provides a stream-oriented interface to the network • Reliable delivery Operating Systems: A Modern Perspective, Chapter 15
ISO OSI & TCP/IP ISO OSI Session ISO OSI Session ISO OSI packet ISO OSI packet ISO OSI TLI ARPAnet TCP ISO OSI frame IP frame ISO OSI Network ARPAnet IP Ethernet packet MAC Ethernet Operating Systems: A Modern Perspective, Chapter 15
Domain Name Server (DNS) • IP uses 32-bit addresses • 128.138.241.1 • “anchor.cs.colorado.edu” • DNS: anchor.cs.colorado.edu128.138.241.1 • Huge table • Distributed/managed according to domain • .edu, .com, .net, .gov, … .us, .ca, are domains • .colorado is a sub domain managed by CU • .cs is a sub domain managed by Computer Sci • anchor is a computer in .cs (in .colorado, in .edu) • anchoris on net 128.138.241, and is host number 1 Operating Systems: A Modern Perspective, Chapter 15
DNS .edu First-Level Domain • Supports TCP • Uses UDP .colorado .edu Domain .cs .colorado Domain anchor neon pawnee .cs Domain Operating Systems: A Modern Perspective, Chapter 15
The DNS Protocol Stack UDP packet ISO OSI Session DNS Resolver ISO OSI packet UDP packet ISO OSI TLI ARPAnet UDP ISO OSI frame IP frame ISO OSI Network ARPAnet IP Ethernet packet MAC Ethernet Operating Systems: A Modern Perspective, Chapter 15
ports port numbers DNS resolve P P P P 0 1 2 n Host: 34 Net: 128.138.34 Communication Ports • Global name for a “mailbox” • Will be many ports at one <net, host> mumble.cs.colorado.edu Transport Layer Network Layer Low Layers Operating Systems: A Modern Perspective, Chapter 15
P P P P Communication Ports • Global name for a “mailbox” • Will be many ports at one <net, host> • Each port can be bound to an address <128.138.249, 34, 1> 0 1 2 n Transport Layer Network Layer Host: 34 On Net 128.138.34 Low Layers 128.138.249.34 Operating Systems: A Modern Perspective, Chapter 15
Sharing Names Transport Layer Global Address Space (5623, 56, 2046) (3456, 77, 6785) (9876, 88, 3434) (31978, 12, 1234) send(…,(31978, 12, 1234), …); Process A on Host #12 on Net #31978 Process A Process B 0x001a4772 Bind Port 1234 The OS on Host #12 on Net #31978 Operating Systems: A Modern Perspective, Chapter 15
s = socket(…) s BSD Sockets • Sockets are comm ports in UNIX, Windows, etc. • Semantics resemble pipes (files) • Bidirectional int socket(int addressFamily, int socketType, int protocolNo) Operating Systems: A Modern Perspective, Chapter 15
P BSD Sockets (cont) • Once a socket has been created, it can be bound to an internet port s Operating Systems: A Modern Perspective, Chapter 15
P BSD Sockets (cont) • Once a socket has been created, it can be bound to an internet port int bind(int skt, struct sockadrr *addr, int addrLength) s Operating Systems: A Modern Perspective, Chapter 15
UDP • Datagram (“connectionless”) service • Similar to disk I/O level of service • Logically associated with an IP packet & Data Link frame (but not physically) • Best-effort delivery of datagrams, but: • Datagram may be dropped (lost) • Datagrams may be delivered out of order • Efficient, relative to TCP Operating Systems: A Modern Perspective, Chapter 15
Using UDP /* Set up a socket to talk to the server */ skt = socket(AF_INET, SOCK_DGRAM, 0); host = gethostbyname(remoteHostName); bzero(&remote, sizeof(remote)); remote.sin_family = host->h_addrtype; remote.sin_port = htons(remotePort); bcopy(host->h_addr, &remote.sin_addr, host->h_length); /* Export the socket to a port (and IP address) */ host = gethostbyname(localHostName); bzero(&local, sizeof(local)); local.sin_family = host->h_addrtype; local.sin_port = htons(localPort); bcopy(host->h_addr, &local.sin_addr, host->h_length); if(bind(skt, &local, sizeof(local))) { printf("Bind error ... restart\n"); exit(1); } . . . sendto(s, outBuf, strlen(outBuf), 0, remote, sizeof(remote)); if((len = recv(s, inBuf, BUFLEN, 0)) > 0) {. . .} Operating Systems: A Modern Perspective, Chapter 15
TCP • Connected (or virtual circuit) protocol • Interface allows programmer to read/write a byte stream over the network • Byte stream is mapped into a series of packets • Reliable delivery • Each packet must be acknowledged • Effectively 2 packets per transmission • Must open/close a connection before use Operating Systems: A Modern Perspective, Chapter 15
Using TCP -- Client skt = socket(AF_INET, SOCK_STREAM, 0); host = gethostbyname(serverHostName); bzero(&listener, sizeof(listener)); listener.sin_family = host->h_addrtype; listener.sin_port = htons(port); bcopy(host->h_addr, &listener.sin_addr, host->h_length); if(connect(skt, &listener, sizeof(listener))) { printf("Connect error ... restart\n"); printf("(Must start Server end first)\n"); exit(1); }; . . . write(s, outBuf, BUFLEN); if((len = read(s, inBuf, BUFLEN)) > 0) {. . .} Operating Systems: A Modern Perspective, Chapter 15
Using TCP -- Server skt = socket(AF_INET, SOCK_STREAM, 0); /* Produce an inet address */ host = gethostbyname(serverHostName); bzero(&listener, sizeof(listener)); listener.sin_family = host->h_addrtype; listener.sin_port = htons(port); bcopy(host->h_addr, &listener.sin_addr, host->h_length); if(bind(skt, &listener, sizeof(listener))) { printf("Bind error ... restart\n"); exit(1); } listen(skt, BACKLOG); /* Listen for a request */ newSkt = accept(skt, &client, &clientLen); if (fork() == 0) { close(skt); /* Child doesn't need listener socket */ . . . } close(newSkt); /* Parent doesn't need the new socket */ if((len = read(s, inBuf, BUFLEN)) > 0) { . . .} write(s, outBuf, BUFLEN); Operating Systems: A Modern Perspective, Chapter 15
ISO OSI Model Presentation Presentation Session Session Transport Transport Network Network Data Link Data Link Physical Physical Examples • Physical/Data Link layer networks: Ethernet, Token Ring, ATM • Network layer net: The Internet • Transport layer net: TCP-based network • Presentation/Session layer net: http/html, RPC, PVM, MPI Operating Systems: A Modern Perspective, Chapter 15
ISO OSI Model Application Application Presentation Presentation Session Session Transport Transport Network Network Data Link Data Link Physical Physical Examples • Physical/Data Link layer networks: Ethernet, Token Ring, ATM • Network layer net: The Internet • Transport layer net: TCP-based network • Presentation/Session layer net: http/html, RPC, PVM, MPI • Applications, e.g., WWW, window system, numerical algorithm Operating Systems: A Modern Perspective, Chapter 15
A Firewall Internet Firewall Organization’s Intranet Internal Host Internal Host Internal Host Internal Host Operating Systems: A Modern Perspective, Chapter 15
Client-Server Paradigm • Making a connection in TCP is an example of the client-server paradigm for distributed computing • Active component is the client • Runs autonomously • Decides when it wants to use server • Passive component is the server • Persistent • Always waiting for a client to request service • Not a machine -- just software Operating Systems: A Modern Perspective, Chapter 15