CompSci 356: Introduction to Computer Networks Lecture 3: Hardware and physical links Chap 1.4, 2 of...
-
Upload
kristin-byrd -
Category
Documents
-
view
219 -
download
0
Transcript of CompSci 356: Introduction to Computer Networks Lecture 3: Hardware and physical links Chap 1.4, 2 of...
CompSci 356: Introduction to Computer Networks
Lecture 3: Hardware and physical
linksChap 1.4, 2 of [PD]
Xiaowei Yang
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, provides service interfaces, and hides implementation details
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– 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
Link layer
Network layer
Transport layer
Applicatoin layer
Functions of the Layers• Data Link Layer:
– Service: Reliable transfer of frames over a linkMedia 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
• 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, 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
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 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 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 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 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 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 not
actually establish a connection
Server invokesint 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 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
• 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 it wants to communicate with
Client invokesint 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 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 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.h>#include <netdb.h>
#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);}
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);
}}
Example Application: Server#include <stdio.h>#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <netdb.h>#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);
}
Example Application: Serverif ((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– 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("Argon")
neon.tcpip-lab.edu("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 client
Argon
HTTP server
Neon
HTTP request
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
HTTP client
TCP client
Argon
HTTP server
TCP server
Neon
HTTP request / HTTP response
TCP connection
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 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.144neon.tcpip-lab.edu 128.143.71.21
HTTP client DNS Server
argon.tcpip-lab.edu 128.143.136.15
neon.tcpip-lab.edu
128.143.71.21
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 79telnet 23 http 80smtp 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
HTTP client
TCP client
argon.tcpip-lab.edu
Establish a TCP connectionto port 80 of 128.143.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)
TCP client
argon.tcpip-lab.edu
IP
Send an IP datagram to128.143.71.21
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
argon.tcpip-lab.edu
IP module
Ethernet
Send an Ethernet frameto 00:e0:f9:23:a8:20
ether_output
The route from Argon to Neon
• Note that the router has a different name for each of its interfaces.
neon.tcpip-lab.edu"Neon"
128.143.71.21
argon.tcpip-lab.edu"Argon"128.143.137.144
router137.tcpip-lab.edu"Router137"
128.143.137.1
router71.tcpip-lab.edu"Router71"128.143.71.1
Ethernet NetworkEthernet Network
Router
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
argon.tcpip-lab.edu128.143.137.14400:a0:24:71:e4:44
IP Datagram for Neon
router137.tcpip-lab.edu128.143.137.100:e0:f9:23:a8:20
Forwarding the IP datagram
• The IP router receives the Ethernet frame at interface 128.143.137.11. recovers the IP datagram2. 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
neon.tcpip-lab.edu"Neon"
128.143.71.21
argon.tcpip-lab.edu"Argon"128.143.137.144
router137.tcpip-lab.edu"Router137"
128.143.137.1
router71.tcpip-lab.edu"Router71"128.143.71.1
Ethernet NetworkEthernet Network
Router
• The IP protocol at Router71, tells its Ethernet device driver to send an Ethernet frame to address 00:20:af:03:98:28
router71.tcpip-lab.edu
IP module
Ethernet
Send a frame to00: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.
IP Datagram for Neon
neon.tcpip-lab.edu128.143.71.21
00:20:af:03:98:28
router71.tcpip-lab.edu128.143.71.1
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
HTTP server
neon.tcpip-lab.edu
TCP server
IP module
Ethernet
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
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 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 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 memory
without CPU involvement
• PIO– CPU moves data
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.
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
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– 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 timeFrequency = how many cycles it goes through in unit time
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.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
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*108) = 12.5μS
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 hashigher bandwidth?
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?
• 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
• 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
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
10BASE2 cable, thin-net
200m10Base4, thick-net500m
CAT-5
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
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, …
Central Office Subscriber premises
Local loopRuns on existing copper 18,000 feet at 1.544Mbps9,000 at 8.448 Mbps
ADSL
1.5-8.4Mpbs
16-640Kpbs
Central officeNbrhood optical
Network unitSubscriberpremises
OC links 13-55Mpbs
1000-4500 feet of copper
VDSL (Very high)Symmetric
xDSL wiring
Must install VDSLtransmission hardware
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