740 likes | 755 Views
This lecture explores hardware and physical links in networking, covering topics such as sockets programming, network architectures, nodes, links, and physical layer concepts.
E N D
Lecture 3: Hardware and physical linksChap 1.4, 2 of [PD] Based partly on lecture notes by Xiaowei Yang, Rodrigo Fonseca, David Mazières, Phil Levis, John Jannotti
Overview • Sockets Programming Revisited • Network Architectures • Examples of Networking Principles • Hardware and physical layer • Nuts and bolts of networking • Nodes • Links • Bandwidth, latency, throughput, delay-bandwidth product • Physical links
IPs V. Ports : Server V. App. Plus: 43 Server has .. 12.32.43.23 Gmail: 23 The Internet Google Client has .. 12.32.43.23 Bing: 43 Server has .. 34.232.23.99 Xbox: 23 microsoft
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
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
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
Client-Server 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-Server 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-Server 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-Server 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-Server 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)
Overview • Sockets Programming Revisited • Network Architectures • Examples of Networking Principles • 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, provides service interfaces, and hides implementation details
Protocols Layer N+1 • 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 Layer N Layer N+1 Layer N-1 Layer N Layer N-1
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 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 Applicatoin layer Transport layer Network layer Link layer
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
Overview • Sockets Programming Revisited • Network Architectures • Examples of Networking Principles • Hardware and physical layer • Nuts and bolts of networking • Nodes • Links • Bandwidth, latency, throughput, delay-bandwidth product • Physical links
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 argon.tcpip-lab.edu neon.tcpip-lab.edu ("Argon") ("Neon") Web request Web page Web client Web server
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, 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 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 <HTML> <BODY> <H1>Internet Lab</H1> Click <a href="http://www.tcpip-lab.net/index.html">here</a> for the Internet Lab webpage. </BODY> </HTML> • How does the HTTP request get from Argon to Neon?
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 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.tcpip-lab.edu into an IP addressis 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 viawell-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 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))
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()
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).
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
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 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 128.143.137.1 recovers the IP datagram 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
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
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.
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 • Sockets Programming Revisited • Network Architectures • Examples of Networking Principles • Hardware and physical layer • Nuts and bolts of networking • Nodes • Links • Bandwidth, latency, throughput, delay-bandwidth product • Physical links
Layers, Services, Protocols Application Transport Network Link Physical Service: move bits to other node across link
Physical Layer (Layer 1) • Responsible for specifying the physical medium • Type of cable, fiber, wireless frequency • Responsible for specifying the signal (modulation) • Transmitter varies something (amplitude, frequency, phase) • Receiver samples, recovers signal • Responsible for specifying the bits (encoding) • Bits above physical layer -> chips
Modulation • Specifies mapping between digital signal and some variation in analog signal • Why not just a square wave (1v=1; 0v=0)? • Not square when bandwidth limited • Bandwidth – frequencies that a channel propagates well • Signals consist of many frequency components • Attenuation and delay frequency-dependent
Components of a Square Wave Graphs from Dr. David Alciatore, Colorado State University
Approximation of a Square Wave Graphs from Dr. David Alciatore, Colorado State University
Idea: Use Carriers • Only use frequencies that transmit well • Modulate the signal to encode bits OOK: On-Off Keying ASK: Amplitude Shift Keying
Idea: Use Carriers • Only use frequencies that transmit well • Modulate the signal to encode bits FSK: Frequency Shift Keying PSK: Phase Shift Keying
How Fast Can You Send? • Encode information in some varying characteristic of the signal. • If B is the maximum frequency of the signal C = 2B bits/s (Nyquist, 1928)
Can we do better? • So we can only change 2B/second, what if we encode more bits per sample? • Baud is the frequency of changes to the physical channel • Not the same thing as bits! • Suppose channel passes 1KHz to 2KHz • 1 bit per sample: alternate between 1KHz and 2KHz • 2 bits per sample: send one of 1, 1.33, 1.66, or 2KHz • Or send at different amplitudes: A/4, A/2, 3A/4, A • n bits: choose among 2n frequencies! • What is the capacity if you can distinguish M levels?
Hartley’s Law C = 2B log2(M) bits/s Great. By increasing M, we can have as large a capacity as we want! Or can we?