Download presentation
Presentation is loading. Please wait.
Published byKristin Byrd Modified over 9 years ago
1
CompSci 356: Introduction to Computer Networks Lecture 3: Hardware and physical links Chap 1.4, 2 of [PD] Xiaowei Yang xwy@cs.duke.edu
2
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
3
Network architectures Layering is an abstraction that captures important aspects of the system, provides service interfaces, and hides implementation details
4
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
5
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
6
The protocol graph of Internet 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 Link layer Network layer Transport layer Applicatoin layer
7
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: Move packets from source host to destination host – Functions: 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
8
The Open Systems Interconnection (OSI) architecture Seven-layer
9
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
10
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
12
Multiplexing & Demultiplexing Same ideas apply up and down the protocol graph
13
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
14
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)
15
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
16
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
17
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
18
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
19
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)
20
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
21
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
22
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
23
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
24
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)
25
Example Application: Client #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 host\n"); exit(1); }
26
Example Application: Client /* translate host name into peer’s IP address */ hp = gethostbyname(host); if (!hp) { fprintf(stderr, "simplex-talk: unknown host: %s\n", host); exit(1); } /* build address data structure */ bzero((char *)&sin, sizeof(sin)); sin.sin_family = AF_INET; bcopy(hp->h_addr, (char *)&sin.sin_addr, hp->h_length); sin.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] = ’\0’; len = strlen(buf) + 1; send(s, buf, len, 0); }
27
Example Application: Server #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.sin_family = AF_INET; sin.sin_addr.s_addr = INADDR_ANY; sin.sin_port = htons(SERVER_PORT); /* setup passive open */ if ((s = socket(PF_INET, SOCK_STREAM, 0)) < 0) { perror("simplex-talk: socket"); exit(1); }
28
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); }
29
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
30
An Example
31
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? A simple TCP/IP Example
32
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
33
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
34
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-3ceff955" 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?
35
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
36
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.
37
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
38
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: ftp21finger79 telnet23http80 smtp 25nntp 119
39
Requesting a TCP Connection 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 connect(s, (struct sockaddr*)&sin, sizeof(sin))
40
Invoking the IP Protocol 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) ip_output()
41
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 Router137.tcpip-lab.edu (128.143.137.1).
42
Invoking the device driver The IP module at Argon, tells its Ethernet device driver to send an Ethernet frame to address 00:e0:f9:23:a8:20 Ethernet address of the default router is found out via ARP ether_output
43
The route from Argon to Neon Note that the router has a different name for each of its interfaces.
44
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
45
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
46
The IP protocol at Router71, tells its Ethernet device driver to send an Ethernet frame to address 00:20:af:03:98:28 Invoking the Device Driver at the Router
47
Sending another Ethernet frame The Ethernet device driver of Router71 sends the Ethernet frame to the Ethernet NIC, which transmits the frame onto the wire.
48
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
49
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
50
The simplest network is one link plus two nodes Hi Alice… ?
51
Sender side Hi Alice
52
Receiver side
53
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
54
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
55
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
56
DMA and programmed I/O DMA – Adaptor directly reads and writes the host memory without CPU involvement PIO – CPU moves data
57
Recap: Put bits on the wire Each node (e.g. a PC) connects to a network via a network adaptor. The adaptor delivers data between a node’s memory and the network. A device driver is the program running inside the node that manages the above task. At one end, a network adaptor encodes and modulates a bit into signals on a physical link. At the other end, a network adaptor reads the signals on a physical link and converts it back to a bit.
58
Encoding bits into signals 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 Non-return to zero Non-return to zero inverted
59
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
60
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
61
Wavelength = Speed / Frequency Speed = how fast it travels in unit time Frequency = how many cycles it goes through in unit time
62
Electromagnetic spectrum 2.4GHZ WIFI
63
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
64
Bandwidth Bandwidth is a measure of the width of a frequency band. E.g., a telephone line supports a frequency band 300-3300hz 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
65
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 LightInMedium 2500m of copper: 2500/(2/3 * 3*10 8 ) = 12.5μS
66
Delay x bandwidth product 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 Which has higher bandwidth?
67
High speed versus low speed links A high speed link can send more bits in a unit time than a low speed link 1MB of data, 100ms one-way delay How long will it take to send over different speed of links?
68
1Mbps, 100ms, 1MB data Delay * Bandwidth = 100Kb 1MB/100Kb = 80 pipes of data 80 * 100ms + 100ms = 8.1s Transfer time = propagation time + transmission time + queuing time
69
1Gbps, 100ms, 1MB data Delay * Bandwidth = 100Mb 1MB/100Mb = 0.08 pipe of data TransferTime = 0.08 * 100ms + 100ms = 108ms Throughput = TransferSize/TransferTime = 1MB/108ms = 74.1Mbps
70
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
71
Cables CAT-5: twisted pair Coaxial: thick and thin Fiber 10BASE2 cable, thin-net 200m 10Base4, thick-net 500m CAT-5
72
Leased lines Tx series speed: multiple of 64Kpbs – Copper-based transmission DS-1 (T1): 1,544, 24*64kpbs DS-2 (T2): 6,312, 96*64kps DS-3 (T3): 44,736, 672*64kps 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
73
Last mile links Wired links – POTS: 28.8-56Kbps (Plain old telephone service) – ISDN: 64-128Kbps (Integrated Services Digital Network) – xDSL: 128Kbps-100Mbps (over telephone lines) Digital Subscriber Line – CATV: 1-40Mpbs (shared, over TV cables) Wireless links – Wifi, WiMax, Bluetooth, ZigBee, …
74
Central OfficeSubscriber premises Local loop Runs on existing copper 18,000 feet at 1.544Mbps 9,000 at 8.448 Mbps ADSL 1.5-8.4Mpbs 16-640Kpbs Central office Nbrhood optical Network unit Subscriber premises OC links 13-55Mpbs 1000-4500 feet of copper VDSL (Very high) Symmetric xDSL wiring Must install VDSL transmission hardware
75
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 – WiFi, Bluetooth, Infrared
76
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
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.