1 / 45

Computer Networks

Computer Networks. Operating Systems and Networking CS 232. Advantages of Networked Systems. Resource sharing : users can share files, printers, ... Communication : file-sharing, e-mail, ftp, www, ... Speedup : two different benefits:

lorib
Download Presentation

Computer Networks

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer Networks Operating Systems and Networking CS 232

  2. Advantages of Networked Systems • Resource sharing: users can share files, printers, ... • Communication: file-sharing, e-mail, ftp, www, ... • Speedup: two different benefits: • If a task can be broken into N subtasks, run them in parallel to get faster turnaround time (distributed.net, SETI@home). • If one machine is heavily loaded, migrate some of its processes to lightly loaded machine (load balancing). • Reliability: If one machine fails, others can do its work. • Goal: Eliminate any single point of failure from the system. • No machine can have the only copy of a resource (redundance of both hardware and software resources).

  3. The TCP/IP Stack • Application layer protocols generate/receive data in messages 5 FTP SSH SMTP ... messages • Transport layer protocols provide reliability. 4 TCP UDP packets • TheInternet layer protocol (IP) moves packets across/between networks. 3 IP datagrams • The Network interface layer protocol moves packets across a network in frames. 2 Ethernet frames • TCP/IP is a layered protocol family: Hardware

  4. End-to-End Communication hosti hostj TCP/IP appi TCP/IP appj data Transport Transport packets Internet Internet datagrams Network Network frames network • A TCP/IP network is a collection of communication links and hosts, with each host having a TCP/IP stack. The stacks enable any two hosts to communicate in a point-to-point fashion. Each layer of the stack (at each end) performs its respective task. message Control info is also sent between specific layers...

  5. What a network looks like • A PC connects via Ethernet or wirelessly (or both) to a switch – an aggregation device (switch, hub, AP). • Anywhere from 4 to 100+ ports. • Everything connected to a switch is on the same LAN (generally). • They can all communicate “directly” with each other.

  6. What a network looks like (2) • Multiple switches connect to each other and to a router. • A router moves packets from one network to another. • Routers have anywhere from 2 to 100+ ports. • Routers connect together to form an internet. • Internet means the global internet. • Data on a network is in small 1500 byte (max) packets. • Each is handled independently. • Each device makes its best-effort to deliver each packet. • But if there is a problem, it simply (and often quietly) drops the packet.

  7. Role of each layer: Layer 2 • Network interface layer: responsible for getting packets across the local network. • Must address each packet with its destination MAC address. • Indicates what kind of higher-layer data it carries. • Layer 2 is hardware-dependent. • If layer 1 is copper, layer 2 needs to send voltages. • Optical fiber?: light. • Cell system?: radio signals. • Wireless?: radio signals. • Line of sight?: bonfires, smoke signals, or semaphores.

  8. Role of each layer: Layer 3 • IP layer: getting packets across multiple networks. • Incoming (received from layer 2): Accepts packet with (one of) its IP addresses. • Outgoing (sending to layer 2): Determine which layer 2 interface to use to the next machine/destination. • Every packet carries its dest IP address. • Break packet up into chunks that can be sent on layer 2. • Combine these on a router  forwards packets between networks, from source host on source network to destination host on the destination network. • Must indicate what kind of data it carries. • Is totally hardware independent.

  9. Role of each layer: Layer 4 • Transport layer: responsible for providing reliability. • TCP: provides complete reliability (or indicates to the higher layer that it has failed). • UDP: provides no reliability. • Indicates what application’s data it carries by indicating a destination port. • Layer 5 (Application): sends/receives data on a port, with a certain protocol, to/from a certain destination.

  10. Role of each layer: Layer 5 • Application: sends/receives data on a port, with a certain protocol, to/from a certain destination. • Typically uses the sockets API to communicate with layers 4 and 3. • A socket is created and configured with information about which layer 4 to use, destination IP address (layer 3), etc.

  11. Encapsulation and Demultiplexing • A lower layer protocol can carry different higher layer protocols • Multiplexing: the sharing of a service by multiple “users”. • When a packet is received, during processing the OS must be able to figure out what protocol each layer is carrying. • Demultiplexing: splitting the received data up to be sent on to the proper handler. • Encapsulation means header and data from a higher layer “wrapped” up as the payload (data) of the next lower layer. • Lower layer must have a type field that indicates what kind of data/protocol it is carrying.

  12. The Client-Server Model • An always-running server (or daemon) that provides a specific service: hosti hostj client app server app • A client that contacts a server to access the service it offers: network • Most TCP/IP applications use the client-server model, splitting a network application into two parts: Servers for specificservices use well-known ports: echo 7 ftp-data 20 smtp 25 daytime 13 ftp-cntl 21 dns 53 quote 17 ssh 22 finger 79

  13. Medium-sized example • Host 153.106.4.77 runs http client to get the web page from host 153.106.4.1, Calvin’s main web server.

  14. Encap, Mux, Demux in Example • Encapsulation: As data is passed from appl  tcp_out()  ipv4_out()  eth_out(), the header and payload from layer n is wrapped up as the payload of layer n-1. • Multiplexing (Mux): each layer n-1 can encapsulate data from any layer n. But, it labels the data by having a type field in its header. • Demultiplexing: on the receiving side each handler (e.g., eth_in()) decides what next layer’s function (ipv4_in(), ipv6_in()) to call based on that type value in the header, and, strips off the header, passing the result up (de-encapsulation).

  15. Picture dns ssh chrome rtp udp tcp tcpv6 udpv6 ipv4 ipv6 ethernet

  16. Sockets • Most TCP/IP applications communicate using an abstraction called a socket, that represents a communicationendpoint. • To provide a service to clients, a server: • creates a socket using a given protocol (TCP or UDP) and port • blocks, waiting for a client to send a request to its socket • receives a request via the socket, processes it • sends any results back to the client via the socket • To request service from a server, a client: • creates a socket • uses it to send a request for service to a server • uses it to receive any results from the server Sockets are the software API to TCP/IP.

  17. Protocols and Sockets • TCP is a connection-orientedprotocol, while UDP is a connection-lessprotocol. Choice of protocol affects the server’s behavior: A server using the TCP protocol behaves as follows: • it accepts a connection (blocking), aka listening • this operation returns a new socket s’ connected to the client • Two options: • Provide the service, return the results to the client via s’, and then listen for another connection (a single-threaded server); OR • Spawn a new thread for that client (that provides the service and returns result to the client via s’), and then listen for another connection (a multi-threaded server). If providing the service takes much time  multithreading.

  18. Protocols and Sockets (ii) By contrast, a server using the UDP protocol: • receives a datagram from a client requesting service via its socket (blocking) • performs the service, creates a datagram containing any results, and sends that datagram to the client via the same socket. A UDP server’s behavior is different from a TCP server’s because TCP maintains a sustained connection, while UDP is connectionless (just one pair of datagrams are exchanged). Servers using UDP can be multithreaded, but almost never are in practice, because multiple threads sharing the same socket mean accesses to it would have to be synchronized, voiding the benefits of multithreading.

  19. Java Sockets • Java provides different classes to represent various kinds of sockets, including: • ServerSocket is a class representing TCP server sockets, • Socket is a class representing TCP client sockets, and • DatagramSocket is a class representing UDP sockets, that provides send() and receive() methods by which clients and servers can send/receive DatagramPacket objects. Java also provides class InetAddress and other useful classes in its java.net package.

  20. Example: UDP Daytime Server • The daytime service provides the date and time on a host. import java.net.*; // DatagramSocket, ... class UDPDaytimeServer extends Object { public final int BUF_SIZE = 256; private DatagramSocket mySocket; private DatagramPacket myPacket; public UDPDaytimeServer(int port) { try { mySocket = new DatagramSocket(port); } catch (SocketException e) { System.err.println(e); } byte [] buffer = new byte[BUF_SIZE]; myPacket = new DatagramPacket(buffer, BUF_SIZE); } // … continued on next slide …

  21. UDP Daytime Server (ii) public void run() { for (;;) { try { mySocket.receive(myPacket); java.util.Date rightNow = new java.util.Date(); myPacket.setData( rightNow.toString().getBytes() ); mySocket.send(myPacket); } catch (java.io.IOException e) { System.err.println(e); } } } public static void main(String [] args) { if (args.length == 1) { UDPDaytimeServer me = new UDPDaytimeServer( Integer.parseInt(args[0]) ); me.run(); } else System.err.println("\nUsage: java UDPDaytimeServer <port>"); } }

  22. UDP Daytime Client • The client is symmetric to the server, but has no main loop... import java.net.*; class UDPDaytimeClient extends Object { public final int BUF_SIZE = 256; private DatagramSocket mySocket; private DatagramPacket myPacket; public UDPDaytimeClient(String host, int port) { try { InetAddress hostAddress = InetAddress.getByName(host); byte [] buffer = new byte[BUF_SIZE]; myPacket = new DatagramPacket(buffer, BUF_SIZE, hostAddress, port); mySocket = new DatagramSocket(); } catch (Exception e) { System.err.println(e); } } // … continued on next slide …

  23. UDP Daytime Client (ii) public void run() { try { mySocket.send(myPacket); mySocket.receive(myPacket); System.out.println( new String( myPacket.getData() ).trim() ); } catch (Exception e) { System.err.println(e); } } public static void main(String [] args) { if (args.length == 2) { UDPDaytimeClient me = new UDPDaytimeClient(args[0], Integer.parseInt(args[1])); me.run(); } else System.err.println( "\nUsage: java UDPDaytimeClient <host> <port>\n"); } }

  24. RPC hosti hostj // Thread s { void run() { // … y = t.f(x); // … } } // Thread t { // … int f(int i) { // … } // … } network • Sockets are “low-level” communication primitives. Theremote procedure call (RPC) is a higher level capability, whereby one thread invokes the method of another thread, which can be either on the local host or a remote host. Parameters and return-values permit the threads to communicate. The RPC system handles all underlying communication.

  25. RMI and CORBA • Java’s version of RPC is called remote method invocation (RMI), which is an object-oriented implementation of RPC. • RMI requires that all the pieces of a distributed application be written in Java, which may or may not be desirable… • Parts may already be written in a different language. The common object request broker architecture (CORBA) is a middle-ware alternative to RPC/RMI mechanisms that allows objects written in arbitrary languages (and on arbitrary platforms) to communicate. • The central piece of CORBA is the object request broker (ORB) through which all communication takes place.

  26. CORBA The local ORB then creates a skeleton, and remote ORBs create stubs for it. hosti hostj Client Object Stub Skeleton A client wishing to access that object does so through the stub of its local ORB; the ORB takes it from there. ORB ORB network (Internet InterORB Protocol) • An object registers itself by sending the ORB a description of its interface, written in interface definition language (IDL). IIOP is a protocol that runs “on top of” other protocols so that CORBA can be used on a wide variety of network platforms.

  27. Categorizing Networks • One way to categorize networks is by their geographic area: • A local area network (LAN) connects machines in a “small” area (e.g., building, campus, …) using network interface cards (NICs). • A wide area network (WAN) encompasses a “large” area (e.g., a city, country, …) using modems and telecom lines (telephone lines, microwave links, and satellite channels). Another way is by the communicationmedium they use: • Copperwire: phone lines or coaxial cable (electrons) • Optical fiber: glass fibers (photons) • Electromagnetic radiation: infrared, micro, or radio waves (modulated carrier signals)

  28. Network Topology • Bus: machines communicate via a shared medium (e.g., Ethernet): • simple, easy to expand • shared medium  limited scaleability ... • Star: machines communicate via a central node (e.g., a switch): • fairly simple, easy to expand • faster than bus • somewhat better scaleability • single failure point switch • Another way networks are categorized is by their topology:

  29. Network Topology (ii) • Ring: machines communicate via a shared circular medium: • fairly simple, easy to expand • faster than bus • limited scaleability ... • Point-to-point: machines communicate via dedicated links: • good scaleability • somewhat more complicated • slower communication • Other common topologies include:

  30. Network Design Issues • Naming/Addressing: How do two processes locate each other to communicate via the network? • Routing: How are messages sent through the network? • Packet Strategy: Networks break messages into packets. Are packets sent individually or as a sequence? • Connections: How do two processes send a sequence of messages? • Contention: How are conflicts for the network resolved? These issues must be addressed by any network designer, and we’ll see how the Internet protocol (IP) resolves them.

  31. Addressing: Layer 2 • Each layer has its own addressing mechanism. • Layer 2: MAC addresses • 48 bits (6 octets). • Universally unique: blocks are given out to companies that make devices that connect to network. • Required in ethernet header: src MAC and dest MAC. • Broadcast = all 1s. • Written in 6 hex pairs, e.g, 0d:33:ab:c7:ef:01

  32. Addressing: Layer 3 • Every machine must have a hardware-independent, unique address: IP address. • 32 bits (4 octets), written as four numbers, each 0-255: • e.g., 192.168.0.1, or 8.8.8.8, or 224.237.245.252 • 255.255.255.255 is the broadcast address • Each interface (connection to a network) has its own IP address. • All interfaces on a (layer 2) network must be on the same IP (layer 3) network.

  33. Addressing: Layer 4 • Addresses at layer 4 are ports: TCP ports or UDP ports. • A port identifies an application at layer 5. • Thus, a port often correlates with a protocol to use. • Ports are 16 bits in TCP/UDP, so values from 0 to 65535. • Well-known/reserved ports are from 0 to 1023. • /etc/services lists reserved ports on Linux/Mac OS.

  34. Name Resolution • IP hosts have names (calvin.edu) + addresses (153.106.4.1). • A domain-name service (DNS) server translates between these: • Both are unique; names are for humans, addresses for machines. Example: To find the address of www.cnn.com from calvin.edu: • Ask the local (calvin.edu) DNS server, which looks in its cache; • If not found, that server asks a root-level DNS server for .com server; • Ask the .com DNS server, which looks in its cache; • If not found, it returns the address of the cnn.com DNS server; • Ask the cnn.com DNS server, which returns the address. • Hierarchical searching/querying, with caching for efficiency. • To allow communication, a process gets a port from the OS. • A process address is thus a pair (hostAddress, port) • These (plus a protocol) uniquely identify an Internet service.

  35. Connection Strategies • If 2 processes must send/receive, how do we connect them? • Create a new connection per session: circuit switching • Phone call model, with connection = switched circuit • All traffic for the session takes this same route • Most overhead to setup/teardown; least overhead/message • Create a new “connection” per packet: packet switching • Post office model, with connection = dynamic route • If message has multiple packets, each may take different route • Least setup/teardown overhead; most overhead/message

  36. Packet Strategies • Most mechanisms break (varying-sized) messages into (fixed-sized) units called packets, frames, or datagrams. • The transmission control protocol (TCP) provides for the reliable delivery of multiple packets (i.e., a message): • connection-oriented: relatively slow, but reliable delivery ensured by ACK messages, time-outs, sequence numbers, … • The user datagram protocol (UDP) provides for “best-effort” delivery of a single packet: • connectionless: fast, but no reliability features UDP is useful when speed is more important than reliability; UDP can also send to multiple destinations with one packet.

  37. Routing Entities • A router routes traffic between networks (layer 3): • Forwards each packet “toward” its destination using routing table • Fixed routing: RT must be manually updated • Dynamic routing: routers use routing protocols to communicate network changes and update tables automatically. • Routers also often run DNS and DHCP and other services. • A switch switches traffic within a network (layer 2): • Specific switch-links are associated with specific MAC addresses • A hub broadcasts traffic withina network (layer 1)

  38. Contention • If 2 processes in a broadcast (bus, ring, etc) network send simultaneously contention. • Collision detection (CSMA/CD): Ethernet • sense the medium’s carrier wave; if it’s not busy, send message. • while sending, see if you are only hearing yourself (a collision) • If collision occurred, wait random length of time; try again. • Collision avoidance: wireless • Ask AP (access point) for time to talk, before talking.

  39. Supporting Protocols: DHCP • Once upon a time when a machine booted you had to enter the machine’s • IP address • Network mask • Default route • Now, the Dynamic Host Configuration Protocol client starts up, sends a broadcast over UDP to the DHCP server port. • Response includes all of the above, plus DNS server address, WINS server address, etc.

  40. Supporting Protocols: ARP • The Address Resolution Protocol maps Layer 3 addresses to Layer 2 addresses. • When a packet needs to be routed (layer 3), the next-hop IP address is determined from the routing table. But… • How to communicate with that next-hop machine? • Need its Layer 2 address. • An ARP request is sent that says, essentially, “I’m looking for <IP address>? Are you out there? If so, send me a response with your MAC address.” • Only that machine that matches <IP address> responds. • All machines must be able to respond.

  41. Supporting Protocols: IPv6 • 32-bit IPv4 addresses have run out!  In some places, if you have a new business and want a IPv4 address, too bad. They are gone. • IPv6 has 128-bit addresses: 2^128 addresses • 340,282,366,920,938,463,463,374,607,431,768,211,456 addresses (3.4 x 1038). • ~5 x 10^28 addresses per person… • Supports more efficient routing. • Supports better security.

  42. IPv6 • Completely new protocol – not compatible with IPv4. • Most machines today support dual stacks – an IPv4 stack and an IPv6 stack. • If you specify an IPv6 address in your socket API, the IPv6 stack is used. • Might get an IPv6 address if DNS resolves your hostname to an IPv6 address (through what is called a DNS quad-A record (“AAAA”)).

  43. IPv6 • The IPv6 and IPv4 Internet are essentially separate networks at this point. • What if you can only get an IPv6 address, but want to communicate with IPv4 services or vice versa? • Use a router to convert IPv6 packets to IPv4 and back again (or vice versa). • What if you need to communicate with an IPv6 service but your ISP only supports IPv4? • Host generates IPv6 packets tunneled within IPv4 packets. (Packet is layer 2 carrying layer 3 carrying layer 3 carrying layer 4, layer 5, etc.)

  44. Stuff We Didn’t Cover • Network, sub-network, and host part of IP addresses. • NAT, to support private networks. • Classful/classless/CIDR addressing. • ICMP • Network measurement, network management • VLANs

  45. Summary Networks: standalone machines communication devices. Sockets, RPC, and CORBA are different mechanisms used to facilitate communication in a networked/distributed system. Networks are frequently categorized by their: • Geographic area • Connection media • Topology Different network protocols have different strategies for handling names, routing, packets, connections, & contention. Internet services use TCP/IP, a 4-layer protocol stack. Routers route packets betweendifferent networks. Switches route packets within a network.

More Related