Скачать презентацию Comp Sci 356 Introduction to Computer Networks Lecture Скачать презентацию Comp Sci 356 Introduction to Computer Networks Lecture

e69b1b7996d0649eb80a6cce0ad5de3c.ppt

  • Количество слайдов: 76

Comp. Sci 356: Introduction to Computer Networks Lecture 3: Hardware and physical links Chap Comp. Sci 356: Introduction to Computer Networks Lecture 3: Hardware and physical links Chap 1. 4, 2 of [PD] Xiaowei Yang [email protected] duke. edu

Overview • Network architectures • Application Programming Interface • Hardware and physical layer – Overview • Network architectures • Application Programming Interface • Hardware and physical layer – Nuts and bolts of networking – Nodes – Links • Bandwidth, latency, throughput, delay-bandwidth product • Physical links

Network architectures • Layering is an abstraction that captures important aspects of the system, Network architectures • Layering is an abstraction that captures important aspects of the system, provides service interfaces, and hides implementation details

Protocols • The abstract objects that make up the layers of a network system Protocols • The abstract objects that make up the layers of a network system are called protocols • Each protocol defines two different interfaces – Service interface – Peer interface

Network architectures • A protocol graph represents protocols that make up a system – Network architectures • A protocol graph represents protocols that make up a system – Nodes are protocols – Links are depend-on relations • Set of rules governing the form and content of a protocol graph are called a network architecture • Standard bodies such as IETF govern procedures for introducing, validating, and approving protocols

The protocol graph of Internet Applicatoin layer Transport layer Network layer Link layer • The protocol graph of Internet Applicatoin layer Transport layer Network layer Link layer • No strict layering. One can do cross-layer design • Hourglass shaped: IP defines a common method for exchanging packets among different networks • To propose a new protocol, one must produce both a spec and one/two implementations

Functions of the Layers • Data Link Layer: – Service: Reliable transfer of frames Functions of the Layers • Data Link Layer: – Service: Reliable transfer of frames over a link Media Access Control on a LAN – Functions: Framing, media access control, error checking • Network Layer: – Service: – Functions: Move packets from source host to destination host Routing, addressing • Transport Layer: – Service: Delivery of data between hosts – Functions: Connection establishment/termination, error control, flow control, congestion control • Application Layer: – Service: Application specific (delivery of email, retrieval of HTML documents, reliable transfer of file) – Functions: Application specific

The Open Systems Interconnection (OSI) architecture Seven-layer The Open Systems Interconnection (OSI) architecture Seven-layer

 • International Telecommunications Union (ITU) publishes protocol specs based on the OSI reference • International Telecommunications Union (ITU) publishes protocol specs based on the OSI reference model – X dot series • Physical layer: handles raw bits • Data link layer: aggregate bits to frames. Network adaptors implement it • Network layer: handles host-to-host packet delivery. Data units are called packets • Transport: implements process channel. Data units are called messages • Session layer: handles multiple transport streams belong to the same applications • Presentation layer: data format, e. g. , integer format, ASCII string or not • Application layer: application specific protocols

Encapsulation • Upper layer sends a message using the service interface • A header, Encapsulation • Upper layer sends a message using the service interface • A header, a small data structure, to add information for peer-to-peer communication, is attached to the front message – Sometimes a trailer is added to the end • Message is called payload or data • This process is called encapsulation

Multiplexing & Demultiplexing • Same ideas apply up and down the protocol graph Multiplexing & Demultiplexing • Same ideas apply up and down the protocol graph

Overview • Network architectures • Application Programming Interface • Hardware and physical layer – Overview • Network architectures • Application Programming Interface • Hardware and physical layer – Nuts and bolts of networking – Nodes – Links • Bandwidth, latency, throughput, delay-bandwidth product • Physical links

Application Programming Interface • Interface exported by the network • Since most network protocols Application Programming Interface • Interface exported by the network • Since most network protocols are implemented (those in the high protocol stack) in software and nearly all computer systems implement their network protocols as part of the operating system, when we refer to the interface “exported by the network”, we are generally referring to the interface that the OS provides to its networking subsystem • The interface is called the network Application Programming Interface (API)

Application Programming Interface (Sockets) • Socket Interface was originally provided by the Berkeley distribution Application Programming Interface (Sockets) • Socket Interface was originally provided by the Berkeley distribution of Unix - Now supported in virtually all operating systems • Each protocol provides a certain set of services, and the API provides a syntax by which those services can be invoked in this particular OS

Socket • What is a socket? – The point where a local application process Socket • What is a socket? – The point where a local application process attaches to the network – An interface between an application and the network – An application creates the socket • The interface defines operations for – – Creating a socket Attaching a socket to the network Sending and receiving messages through the socket Closing the socket

Socket • Socket Family – PF_INET denotes the Internet family – PF_UNIX denotes the Socket • Socket Family – PF_INET denotes the Internet family – PF_UNIX denotes the Unix pipe facility – PF_PACKET denotes direct access to the network interface (i. e. , it bypasses the TCP/IP protocol stack) • Socket Type – SOCK_STREAM is used to denote a byte stream – SOCK_DGRAM is an alternative that denotes a message oriented service, such as that provided by UDP

Creating a Socket int sockfd = socket(address_family, type, protocol); • The socket number returned Creating a Socket int sockfd = socket(address_family, type, protocol); • The socket number returned is the socket descriptor for the newly created socket • int sockfd = socket (PF_INET, SOCK_STREAM, 0); • int sockfd = socket (PF_INET, SOCK_DGRAM, 0); The combination of PF_INET and SOCK_STREAM implies TCP

Client-Serve Model with TCP Server – Passive open – Prepares to accept connection, does Client-Serve Model with TCP Server – Passive open – Prepares to accept connection, does not actually establish a connection Server invokes int bind (int socket, struct sockaddr *address, int addr_len) int listen (int socket, int backlog) int accept (int socket, struct sockaddr *address, int *addr_len)

Client-Serve Model with TCP Bind – Binds the newly created socket to the specified Client-Serve Model with TCP Bind – Binds the newly created socket to the specified address i. e. the network address of the local participant (the server) – Address is a data structure which combines IP and port Listen – Defines how many connections can be pending on the specified socket

Client-Serve Model with TCP Accept – Carries out the passive open – Blocking operation Client-Serve Model with TCP Accept – Carries out the passive open – Blocking operation • Does not return until a remote participant has established a connection • When it does, it returns a new socket that corresponds to the new established connection and the address argument contains the remote participant’s address

Client-Serve Model with TCP Client – Application performs active open – It says who Client-Serve Model with TCP Client – Application performs active open – It says who it wants to communicate with Client invokes int connect (int socket, struct sockaddr *address, int addr_len) Connect – Does not return until TCP has successfully established a connection at which application is free to begin sending data – Address contains remote machine’s address

Client-Serve Model with TCP In practice – The client usually specifies only remote participant’s Client-Serve Model with TCP In practice – The client usually specifies only remote participant’s address and let’s the system fill in the local information – Whereas a server usually listens for messages on a well-known port – A client does not care which port it uses for itself, the OS simply selects an unused one

Client-Serve Model with TCP Once a connection is established, the application process invokes two Client-Serve Model with TCP Once a connection is established, the application process invokes two operation int send (int socket, char *msg, int msg_len, int flags) int recv (int socket, char *buff, int buff_len, int flags)

Example Application: Client #include <stdio. h> #include <sys/types. h> #include <sys/socket. h> #include <netinet/in. Example Application: Client #include #include #include #include #include #define SERVER_PORT 5432 #define MAX_LINE 256 int main(int argc, char * argv[]) { FILE *fp; struct hostent *hp; struct sockaddr_in sin; char *host; char buf[MAX_LINE]; int s; int len; if (argc==2) { host = argv[1]; } else { fprintf(stderr, "usage: simplex-talk hostn"); exit(1); }

Example Application: Client /* translate host name into peer’s IP address */ hp = Example Application: Client /* translate host name into peer’s IP address */ hp = gethostbyname(host); if (!hp) { fprintf(stderr, "simplex-talk: unknown host: %sn", host); exit(1); } /* build address data structure */ bzero((char *)&sin, sizeof(sin)); sin_family = AF_INET; bcopy(hp->h_addr, (char *)&sin. sin_addr, hp->h_length); sin_port = htons(SERVER_PORT); /* active open */ if ((s = socket(PF_INET, SOCK_STREAM, 0)) < 0) { perror("simplex-talk: socket"); exit(1); } if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) { perror("simplex-talk: connect"); close(s); exit(1); } /* main loop: get and send lines of text */ while (fgets(buf, sizeof(buf), stdin)) { buf[MAX_LINE-1] = ’’; len = strlen(buf) + 1; send(s, buf, len, 0); } }

Example Application: Server #include <stdio. h> #include <sys/types. h> #include <sys/socket. h> #include <netinet/in. Example Application: Server #include #include #include #include #include #define SERVER_PORT 5432 #define MAX_PENDING 5 #define MAX_LINE 256 int main() { struct sockaddr_in sin; char buf[MAX_LINE]; int len; int s, new_s; /* build address data structure */ bzero((char *)&sin, sizeof(sin)); sin_family = AF_INET; sin_addr. s_addr = INADDR_ANY; sin_port = htons(SERVER_PORT); /* setup passive open */ if ((s = socket(PF_INET, SOCK_STREAM, 0)) < 0) { perror("simplex-talk: socket"); exit(1); }

Example Application: Server if ((bind(s, (struct sockaddr *)&sin, sizeof(sin))) < 0) { perror( Example Application: Server if ((bind(s, (struct sockaddr *)&sin, sizeof(sin))) < 0) { perror("simplex-talk: bind"); exit(1); } listen(s, MAX_PENDING); /* wait for connection, then receive and print text */ while(1) { if ((new_s = accept(s, (struct sockaddr *)&sin, &len)) < 0) { perror("simplex-talk: accept"); exit(1); } while (len = recv(new_s, buf, sizeof(buf), 0)) fputs(buf, stdout); close(new_s); } }

Overview • Network architectures • Application Programming Interface • Hardware and physical layer – Overview • Network architectures • Application Programming Interface • Hardware and physical layer – Nuts and bolts of networking – Nodes – Links • Bandwidth, latency, throughput, delay-bandwidth product • Physical links

An Example An Example

A simple TCP/IP Example argon. tcpip-lab. edu ( A simple TCP/IP Example argon. tcpip-lab. edu ("Argon") neon. tcpip-lab. edu ("Neon") Web request Web page Web client Web server • A user on host argon. tcpip-lab. edu (“Argon”) makes web access to URL http: //neon. tcpip-lab. edu/index. html. • What actually happens in the network?

HTTP Request and HTTP response • Web server runs an HTTP server program • HTTP Request and HTTP response • Web server runs an HTTP server program • HTTP client Web browser runs an HTTP client program • sends an HTTP request to HTTP server • HTTP server responds with HTTP response

HTTP Request GET /example. html HTTP/1. 1 Accept: image/gif, */* Accept-Language: en-us Accept-Encoding: gzip, HTTP Request GET /example. html HTTP/1. 1 Accept: image/gif, */* Accept-Language: en-us Accept-Encoding: gzip, deflate User-Agent: Mozilla/4. 0 Host: 192. 168. 123. 144 Connection: Keep-Alive

HTTP Response HTTP/1. 1 200 OK Date: Sat, 25 May 2002 21: 10: 32 HTTP Response HTTP/1. 1 200 OK Date: Sat, 25 May 2002 21: 10: 32 GMT Server: Apache/1. 3. 19 (Unix) Last-Modified: Sat, 25 May 2002 20: 51: 33 GMT ETag: "56497 -51 -3 ceff 955" Accept-Ranges: bytes Content-Length: 81 Keep-Alive: timeout=15, max=100 Connection: Keep-Alive Content-Type: text/html Internet Lab Click here for the Internet Lab webpage. • How does the HTTP request get from Argon to Neon?

From HTTP to TCP • To send request, HTTP client program establishes an TCP From HTTP to TCP • To send request, HTTP client program establishes an TCP connection to the HTTP server Neon. • The HTTP server at Neon has a TCP server running

Resolving hostnames and port numbers • Since TCP does not work with hostnames and Resolving hostnames and port numbers • Since TCP does not work with hostnames and also would not know how to find the HTTP server program at Neon, two things must happen: 1. The name “neon. tcpip-lab. edu” must be translated into a 32 -bit IP address. 2. The HTTP server at Neon must be identified by a 16 -bit port number.

Translating a hostname into an IP address • The translation of the hostname neon. Translating a hostname into an IP address • The translation of the hostname neon. tcpip-lab. edu into an IP address is done via a database lookup – gethostbyname(host) • The distributed database used is called the Domain Name System (DNS) • All machines on the Internet have an IP address: argon. tcpip-lab. edu 128. 143. 137. 144 neon. tcpip-lab. edu 128. 143. 71. 21

Finding the port number • Note: Most services on the Internet are reachable via Finding the port number • Note: Most services on the Internet are reachable via well-known ports. E. g. All HTTP servers on the Internet can be reached at port number “ 80”. • So: Argon simply knows the port number of the HTTP server at a remote machine. • On most Unix systems, the well-known ports are listed in a file with name /etc/services. The well-known port numbers of some of the most popular services are: ftp 21 finger 79 telnet 23 http 80 smtp 25 nntp 119

Requesting a TCP Connection connect(s, (struct sockaddr*)&sin, sizeof(sin)) • The HTTP client at argon. Requesting a TCP Connection connect(s, (struct sockaddr*)&sin, sizeof(sin)) • The HTTP client at argon. tcpip-lab. edu requests the TCP client to establish a connection to port 80 of the machine with address 128. 141. 71. 21

Invoking the IP Protocol ip_output() • The TCP client at Argon sends a request Invoking the IP Protocol ip_output() • The TCP client at Argon sends a request to establish a connection to port 80 at Neon • This is done by asking its local IP module to send an IP datagram to 128. 143. 71. 21 • (The data portion of the IP datagram contains the request to open a connection)

Sending the IP datagram to the default router • Argon sends the IP datagram Sending the IP datagram to the default router • Argon sends the IP datagram to its default router • The default gateway is an IP router • The default gateway for Argon is Router 137. tcpip -lab. edu (128. 143. 137. 1).

Invoking the device driver ether_output • The IP module at Argon, tells its Ethernet Invoking the device driver ether_output • The IP module at Argon, tells its Ethernet device driver to send an Ethernet frame to address 00: e 0: f 9: 23: a 8: 20 • Ethernet address of the default router is found out via ARP

The route from Argon to Neon • Note that the router has a different The route from Argon to Neon • Note that the router has a different name for each of its interfaces.

Sending an Ethernet frame • The Ethernet device driver of Argon sends the Ethernet Sending an Ethernet frame • The Ethernet device driver of Argon sends the Ethernet frame to the Ethernet network interface card (NIC) • The NIC sends the frame onto the wire

Forwarding the IP datagram • The IP router receives the Ethernet frame at interface Forwarding the IP datagram • The IP router receives the Ethernet frame at interface 128. 143. 137. 1 1. recovers the IP datagram 2. determines that the IP datagram should be forwarded to the interface with name 128. 143. 71. 1 • The IP router determines that it can deliver the IP datagram directly

Invoking the Device Driver at the Router • The IP protocol at Router 71, Invoking the Device Driver at the Router • The IP protocol at Router 71, tells its Ethernet device driver to send an Ethernet frame to address 00: 20: af: 03: 98: 28

Sending another Ethernet frame • The Ethernet device driver of Router 71 sends the Sending another Ethernet frame • The Ethernet device driver of Router 71 sends the Ethernet frame to the Ethernet NIC, which transmits the frame onto the wire.

Data has arrived at Neon • Neon receives the Ethernet frame • The payload Data has arrived at Neon • Neon receives the Ethernet frame • The payload of the Ethernet frame is an IP datagram which is passed to the IP protocol. • The payload of the IP datagram is a TCP segment, which is passed to the TCP server

Overview • Network architectures • Application Programming Interface • Hardware and physical layer – Overview • Network architectures • Application Programming Interface • Hardware and physical layer – Nuts and bolts of networking – Nodes – Links • Bandwidth, latency, throughput, delay-bandwidth product • Physical links

The simplest network is one link plus two nodes Hi Alice… ? The simplest network is one link plus two nodes Hi Alice… ?

Sender side Hi Alice Sender side Hi Alice

Receiver side Receiver side

What actually happened • On the sender side – Payload (“Hi Alice) is encapsulated What actually happened • On the sender side – Payload (“Hi Alice) is encapsulated into a packet – The packet is encapsulated into a frame (a block of data) – The frame is transmitted from main memory to the network adaptor – At the adaptor, the frame is encoded into a bit stream – The encoded bit stream is modulated into signals and put on the wire

The reverse process at the receiver • On the receiver side – Signals demodulated The reverse process at the receiver • On the receiver side – Signals demodulated into a bit stream – The bit stream decoded into a frame – The frame is delivered to a node’s main memory – Payload is decapsulated from the frame

A typical adaptor • A bus interface to talk to the host memory and A typical adaptor • A bus interface to talk to the host memory and CPU • A link interface to talk to the network • A CSR typically maps to a memory location – A device writes to CSR to send/receive data – Reads from CSR to learn the state – Adapter interrupts the host when receiving a frame

DMA and programmed I/O • DMA – Adaptor directly reads and writes the host DMA and programmed I/O • DMA – Adaptor directly reads and writes the host memory without CPU involvement • PIO – CPU moves data

Recap: Put bits on the wire • Each node (e. g. a PC) connects Recap: Put bits on the wire • Each node (e. g. a PC) connects to a • At one end, a network adaptor encodes and modulates a bit into signals on a network via a network adaptor. physical link. • The adaptor delivers data between a node’s memory and the network. • At the other end, a network adaptor reads • A device driver is the program running inside the node that the signals on a physical link and manages the above task. converts it back to a bit.

Encoding bits into signals • Non-return to zero inverted • Encoding binary data into Encoding bits into signals • Non-return to zero inverted • Encoding binary data into high/low signals • Modulation and demodulation turn the high/low signals into wave forms: a complex topic • Ignore the details, only consider the upper lay function: encoding in next lecture

Framing • Signals always present on a link: how to determine the start/end of Framing • Signals always present on a link: how to determine the start/end of a transmission? – Data are embedded into blocks of data called frames – Framing determines where the frame begins and ends is the central task of a network adaptor

Link properties • Network links are implemented on different media that transmit signals – Link properties • Network links are implemented on different media that transmit signals – Electromagnetic waves – Acoustic waves • Frequency: how fast a wave oscillates every second • Wavelength: a pair of adjacent maxima or minima of a wave – Speed of light / frequency = wavelength

Wavelength = Speed / Frequency Speed = how fast it travels in unit time Wavelength = Speed / Frequency Speed = how fast it travels in unit time Frequency = how many cycles it goes through in unit time

Electromagnetic spectrum 2. 4 GHZ WIFI Electromagnetic spectrum 2. 4 GHZ WIFI

Full-duplex and half-duplex • How many bit streams can be encoded on it • Full-duplex and half-duplex • How many bit streams can be encoded on it • One: then nodes connected to the link must share access to the link – Computer bus • Full-duplex: one in each direction on a point-to-point link • Half-duplex: two end points take turns to use it

Bandwidth • Bandwidth is a measure of the width of a frequency band. E. Bandwidth • Bandwidth is a measure of the width of a frequency band. E. g. , a telephone line supports a frequency band 300 -3300 hz has a bandwidth of 3000 hz • Bandwidth of a link normally refers to the number of bits it can transmit in a unit time – A second of time as distance – Each bit as a pulse of width

Propagation delay • How long does it take for one bit to travel from Propagation delay • How long does it take for one bit to travel from one end of link to the other? • Length Of Link / Speed Of Light. In. Medium • 2500 m of copper: 2500/(2/3 * 3*108) = 12. 5μS

Delay x bandwidth product Which has higher bandwidth? • Measure the volume of a Delay x bandwidth product Which has higher bandwidth? • Measure the volume of a “pipe”: how many bits can the sender sends before the receiver receives the first bit • An important concept when constructing high-speed networks • When a “pipe” is full, no more bits can be pumped into it

High speed versus low speed links • A high speed link can send more High speed versus low speed links • A high speed link can send more bits in a unit time than a low speed link • 1 MB of data, 100 ms one-way delay • How long will it take to send over different speed of links?

 • • • 1 Mbps, 100 ms, 1 MB data Delay * Bandwidth • • • 1 Mbps, 100 ms, 1 MB data Delay * Bandwidth = 100 Kb 1 MB/100 Kb = 80 pipes of data 80 * 100 ms + 100 ms = 8. 1 s Transfer time = propagation time + transmission time + queuing time

 • • 1 Gbps, 100 ms, 1 MB data Delay * Bandwidth = • • 1 Gbps, 100 ms, 1 MB data Delay * Bandwidth = 100 Mb 1 MB/100 Mb = 0. 08 pipe of data Transfer. Time = 0. 08 * 100 ms + 100 ms = 108 ms • Throughput = Transfer. Size/Transfer. Time = 1 MB/108 ms = 74. 1 Mbps

Commonly Used Physical Links • Different links have different transmission ranges – Signal attenuation Commonly Used Physical Links • Different links have different transmission ranges – Signal attenuation • Cables – Connect computers in the same building • Leased lines – Lease a dedicated line to connect far-away nodes from telephone companies

Cables • CAT-5: twisted pair • Coaxial: thick and thin • Fiber CAT-5 10 Cables • CAT-5: twisted pair • Coaxial: thick and thin • Fiber CAT-5 10 BASE 2 cable, thin-net 200 m 10 Base 4, thick-net 500 m

Leased lines • Tx series speed: multiple of 64 Kpbs – Copper-based transmission • Leased lines • Tx series speed: multiple of 64 Kpbs – Copper-based transmission • DS-1 (T 1): 1, 544, 24*64 kpbs • DS-2 (T 2): 6, 312, 96*64 kps • DS-3 (T 3): 44, 736, 672*64 kps • OC-N series speed: multiple of OC-1 – Optical fiber based transmission • OC-1: 51. 840 Mbps • OC-3: 155. 250 Mbps • OC-12: 622. 080 Mbps

Last mile links • Wired links – POTS: 28. 8 -56 Kbps (Plain old Last mile links • Wired links – POTS: 28. 8 -56 Kbps (Plain old telephone service) – ISDN: 64 -128 Kbps (Integrated Services Digital Network) – x. DSL: 128 Kbps-100 Mbps (over telephone lines) • Digital Subscriber Line – CATV: 1 -40 Mpbs (shared, over TV cables) • Wireless links – Wifi, Wi. Max, Bluetooth, Zig. Bee, …

x. DSL wiring 1. 5 -8. 4 Mpbs 16 -640 Kpbs Central Office Subscriber x. DSL wiring 1. 5 -8. 4 Mpbs 16 -640 Kpbs Central Office Subscriber premises Local loop Runs on existing copper 18, 000 feet at 1. 544 Mbps 9, 000 at 8. 448 Mbps 13 -55 Mpbs OC links Central office ADSL Nbrhood optical Network unit Subscriber premises 1000 -4500 feet of copper Must install VDSL (Very high) transmission hardware

Wireless links • Wireless links transmit electromagnetic signals through space – Used also by Wireless links • Wireless links transmit electromagnetic signals through space – Used also by cellular networks, TV networks, satellite networks etc. • Shared media – Divided by frequency and space • FCC determines who can use a spectrum in a geographic area, ie, “licensing” – Auction is used to determine the allocation – Expensive to become a cellular carrier • Unlicensed spectrum – Wi. Fi, Bluetooth, Infrared

Summary • Network architectures • Application Programming Interface • Hardware and physical layer – Summary • Network architectures • Application Programming Interface • Hardware and physical layer – Nuts and bolts of networking – Nodes – Links • Bandwidth, latency, throughput, delay-bandwidth product • Physical links