introduction 1-1 lecture 2 computer networking: a top down approach 6 th edition jim kurose, keith...
TRANSCRIPT
Introduction 1-1
Lecture 2
Computer Networking: A Top Down Approach 6th edition Jim Kurose, Keith RossAddison-WesleyMarch 2012
CS3516:
These slides are generated from those made available by the authors of our text.
Introduction
Lecture 2: outline1.5 protocol layers, service models2.7 socket programming with UDP and
TCP.1.3 network core
packet switching, circuit switching, network structure
1-2
Introduction
Protocol “layers”Networks are
complex,with many
“pieces”: hosts routers links of
various media applications protocols hardware,
software
Question: is there any hope of
organizing structure of network?
…. or at least our discussion of
networks?
1-3
Introduction
Organization of air travel
a series of steps
ticket (purchase)
baggage (check)
gates (load)
runway takeoff
airplane routing
ticket (complain)
baggage (claim)
gates (unload)
runway landing
airplane routing
airplane routing
1-4
Introduction
ticket (purchase)
baggage (check)
gates (load)
runway (takeoff)
airplane routing
departureairport
arrivalairport
intermediate air-trafficcontrol centers
airplane routing airplane routing
ticket (complain)
baggage (claim
gates (unload)
runway (land)
airplane routing
ticket
baggage
gate
takeoff/landing
airplane routing
Layering of airline functionality
layers: each layer implements a service via its own internal-layer actions relying on services provided by layer
below
1-5
Introduction
Why layering?dealing with complex systems: explicit structure allows identification,
relationship of complex system’s pieces layered reference model for discussion
modularization eases maintenance, updating of system change of implementation of layer’s service
transparent to rest of system e.g., change in gate procedure doesn’t
affect rest of system layering considered harmful?
1-6
Introduction
Internet protocol stack application: supporting
network applications FTP, SMTP, HTTP
transport: process-process data transfer TCP, UDP
network: routing of datagrams from source to destination IP, routing protocols
link: data transfer between neighboring network elements Ethernet, 802.111 (WiFi), PPP
physical: bits “on the wire”
application
transport
network
link
physical
1-7
Introduction
ISO/OSI reference model presentation: allow
applications to interpret meaning of data, e.g., encryption, compression, machine-specific conventions
session: synchronization, checkpointing, recovery of data exchange
Internet stack “missing” these layers! these services, if needed,
must be implemented in application
needed?
application
presentation
session
transport
network
link
physical
1-8
Introduction
source
applicationtransportnetwork
linkphysical
HtHn M
segment Ht
datagram
destination
applicationtransportnetwork
linkphysical
HtHnHl M
HtHn M
Ht M
M
networklink
physical
linkphysical
HtHnHl M
HtHn M
HtHn M
HtHnHl M
router
switch
Encapsulationmessage M
Ht M
Hn
frame
1-9
Application Layer 2-10
Lecture 2: outline
1.5 protocol layers, service models2.7 socket programming with UDP
and TCP. How does this relate to Project 1?
1.3 network core packet switching, circuit switching,
network structure
Application Layer 2-11
Socket programming
goal: learn how to build client/server applications that communicate using sockets
socket: door between application process and end-end-transport protocol
Internet
controlledby OS
controlled byapp developer
transport
application
physical
link
network
process
transport
application
physical
link
network
processsocket
Application Layer 2-12
Socket programming
Two socket types for two transport services:
UDP: unreliable datagram TCP: reliable, byte stream-oriented
Application Example:1. Client reads a line of characters (data)
from its keyboard and sends the data to the server.
2. The server receives the data and converts characters to uppercase.
3. The server sends the modified data to the client.
4. The client receives the modified data and displays the line on its screen.
Application Layer 2-13
Socket programming with UDPUDP: no “connection” between client &
server no handshaking before sending data sender explicitly attaches IP destination
address and port # to each packet rcvr extracts sender IP address and port#
from received packet
UDP: transmitted data may be lost or received out-of-order
Application viewpoint: UDP provides unreliable transfer of groups
of bytes (“datagrams”) between client and server
Client/server socket interaction: UDP
closeclientSocket
read datagram fromclientSocket
create socket:clientSocket =socket(AF_INET,SOCK_DGRAM)
Create datagram with server IP andport=x; send datagram viaclientSocket
create socket, port= x:serverSocket =socket(AF_INET,SOCK_DGRAM)
read datagram fromserverSocket
write reply toserverSocketspecifying client address,port number
Application 2-14
server (running on serverIP) client
Application Layer 2-15
Example app: UDP client
from socket import *
serverName = ‘hostname’
serverPort = 12000
clientSocket = socket(socket.AF_INET,
socket.SOCK_DGRAM)
message = raw_input(’Input lowercase sentence:’)
clientSocket.sendto(message,(serverName, serverPort))
modifiedMessage, serverAddress =
clientSocket.recvfrom(2048)
print modifiedMessage
clientSocket.close()
Python UDPClientinclude Python’s socket library
create UDP socket for server
get user keyboardinput
Attach server name, port to message; send into socket
print out received string and close socket
read reply characters fromsocket into string
Application Layer 2-16
Example app: UDP server
from socket import *
serverPort = 12000
serverSocket = socket(AF_INET, SOCK_DGRAM)
serverSocket.bind(('', serverPort))
print “The server is ready to receive”
while 1: message, clientAddress = serverSocket.recvfrom(2048) modifiedMessage = message.upper() serverSocket.sendto(modifiedMessage, clientAddress)
Python UDPServer
create UDP socket
bind socket to local port number 12000
loop forever
Read from UDP socket into message, getting client’s address (client IP and port)
send upper case string back to this client
Application Layer 2-17
Socket programming with TCPclient must contact
server server process must
first be running server must have
created socket (door) that welcomes client’s contact
client contacts server by:
Creating TCP socket, specifying IP address, port number of server process
when client creates socket: client TCP establishes connection to server TCP
when contacted by client, server TCP creates new socket for server process to communicate with that particular client allows server to talk
with multiple clients source port numbers
used to distinguish clients (more in Chap 3)
TCP provides reliable, in-orderbyte-stream transfer (“pipe”) between client and server
application viewpoint:
Application Layer 2-18
Client/server socket interaction: TCP
wait for incomingconnection requestconnectionSocket =serverSocket.accept()
create socket,port=x, for incoming request:serverSocket = socket()
create socket,connect to hostid, port=xclientSocket = socket()
server (running on hostid) client
send request usingclientSocketread request from
connectionSocket
write reply toconnectionSocket
TCP connection setup
closeconnectionSocket
read reply fromclientSocket
closeclientSocket
Application Layer 2-19
Example app: TCP client
from socket import *
serverName = ’servername’
serverPort = 12000
clientSocket = socket(AF_INET, SOCK_STREAM)
clientSocket.connect((serverName,serverPort))
sentence = raw_input(‘Input lowercase sentence:’)
clientSocket.send(sentence)
modifiedSentence = clientSocket.recv(1024)
print ‘From Server:’, modifiedSentence
clientSocket.close()
Python TCPClient
create TCP socket for server, remote port 12000
No need to attach server name, port
Application Layer 2-20
Example app: TCP server
from socket import *serverPort = 12000serverSocket = socket(AF_INET,SOCK_STREAM)serverSocket.bind((‘’,serverPort))serverSocket.listen(1)print ‘The server is ready to receive’while 1: connectionSocket, addr = serverSocket.accept() sentence = connectionSocket.recv(1024) capitalizedSentence = sentence.upper() connectionSocket.send(capitalizedSentence) connectionSocket.close()
Python TCPServer
create TCP welcomingsocket
server begins listening for incoming TCP requests
loop forever
server waits on accept()for incoming requests, new socket created on return
read bytes from socket (but not address as in UDP)
close connection to this client (but not welcoming socket)
Application Layer 2-21
Socket programming
Two socket types for two transport services:
UDP: unreliable datagram• Connectionless• Best effort• No checking to see if send was successful
TCP: reliable, byte stream-oriented • Connection established before data transfer can begin• The network can still garble, lose, or put packets out of
order. It’s up to TCP to make it right.• Guaranteed successful delivery.
Application Layer 2-22
Project 1
Your starter code for Project 1
Project1_thread_example.c
Project1_Starter_Client.c
AddressTranslation.c
Gettysburg.html Mickey.jpg
Use this code foryour server.
Use this code foryour client.
Support files.
Introduction
Lecture 2: roadmap1.5 protocol layers, service models2.7 socket programming with UDP and
TCP1.3 network core
packet switching, circuit switching, network structure
1-23
Introduction
mesh of interconnected routers
packet-switching: hosts break application-layer messages into packets forward packets from
one router to the next, across links on path from source to destination
each packet transmitted at full link capacity
The network core
1-24
Introduction
Packet-switching: store-and-forward
takes L/R seconds to transmit (push out) L-bit packet into link at R bps
store and forward: entire packet must arrive at router before it can be transmitted on next link
one-hop numerical example:
L = 7.5 Mbits R = 1.5 Mbps one-hop
transmission delay = 5 sec
more on delay shortly …1-25
sourceR bps destination
123
L bitsper packet
R bps
end-end delay = 2L/R (assuming zero propagation delay)
Introduction
Packet Switching: queueing delay, loss
A
B
CR = 100 Mb/s
R = 1.5 Mb/sD
Equeue of packetswaiting for output link
1-26
queuing and loss: If arrival rate (in bits) to link exceeds
transmission rate of link for a period of time: packets will queue, wait to be transmitted on
link packets can be dropped (lost) if memory
(buffer) fills up
Network Layer 4-27
Two key network-core functions
forwarding: move packets from router’s input to appropriate router output
routing: determines source-destination route taken by packets
routing algorithms
routing algorithm
local forwarding tableheader value output link
0100010101111001
3221
1
23
0111
dest address in arrivingpacket’s header
Introduction
Alternative core: circuit switchingend-end resources
allocated to, reserved for “call” between source & dest:
In diagram, each link has four circuits. call gets 2nd circuit in
top link and 1st circuit in right link.
dedicated resources: no sharing circuit-like
(guaranteed) performance
circuit segment idle if not used by call (no sharing)
Commonly used in traditional telephone networks
1-28
Introduction
Circuit switching: FDM versus TDM
FDM
frequency
timeTDM
frequency
time
4 users
Example:
1-29
Introduction
Packet switching versus circuit switching
example: 1 Mb/s link each user:
• 100 kb/s when “active”• active 10% of time
circuit-switching: 10 users
packet switching: with 35 users,
probability > 10 active at same time is less than .0004 *
packet switching allows more users to use network!
N users
1 Mbps link
Q: what happens if > 35 users ?
…..
1-30* Check out the online interactive exercises for more examples
http://media.pearsoncmg.com/aw/aw_kurose_network_2/applets/transmission/delay.html
Introduction
great for bursty data resource sharing simpler, no call setup
excessive congestion possible: packet delay and loss protocols needed for reliable data transfer,
congestion control Q: How to provide circuit-like behavior?
bandwidth guarantees needed for audio/video apps
still an unsolved problem (chapter 7)
is packet switching a “slam dunk winner?”
Q: human analogies of reserved resources (circuit switching) versus on-demand allocation (packet-switching)?
Packet switching versus circuit switching
1-31
Internet structure: network of networks
End systems connect to Internet via access ISPs (Internet Service Providers) Residential, company and university ISPs
Access ISPs in turn must be interconnected. So that any two hosts can send packets to
each other Resulting network of networks is very complex
Evolution was driven by economics and national policies
Let’s take a stepwise approach to describe current Internet structure
Internet structure: network of networks
Question: given millions of access ISPs, how to connect them together?
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnetaccess
net
accessnet
…
………
…
…
Internet structure: network of networks
Option: connect each access ISP to every other access ISP?
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnetaccess
net
accessnet
…
………
…
…
…
…
………
connecting each access ISP to each other directly doesn’t
scale: O(N2) connections.
Internet structure: network of networks
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnetaccess
net
accessnet
…
………
…
…
Option: connect each access ISP to a global transit ISP? Customer and provider ISPs have economic agreement.
globalISP
Internet structure: network of networks
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnetaccess
net
accessnet
…
………
…
…
But if one global ISP is viable business, there will be competitors ….
ISP B
ISP A
ISP C
Internet structure: network of networks
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnetaccess
net
accessnet
…
………
…
…
But if one global ISP is viable business, there will be competitors …. which must be interconnected
ISP B
ISP A
ISP C
IXP
IXP
peering link
Internet exchange point
Internet structure: network of networks
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnetaccess
net
accessnet
…
………
…
…
… and regional networks may arise to connect access nets to ISPS
ISP B
ISP A
ISP C
IXP
IXP
regional net
Internet structure: network of networks
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnet
accessnetaccess
net
accessnet
…
………
…
…
… and content provider networks (e.g., Google, Microsoft, Akamai ) may run their own network, to bring services, content close to end users
ISP B
ISP A
ISP B
IXP
IXP
regional net
Content provider network
Introduction
Internet structure: network of networks
at center: small # of well-connected large networks “tier-1” commercial ISPs (e.g., Level 3, Sprint, AT&T, NTT),
national & international coverage content provider network (e.g, Google): private network
that connects it data centers to Internet, often bypassing tier-1, regional ISPs
1-40
accessISP
accessISP
accessISP
accessISP
accessISP
accessISP
accessISP
accessISP
Regional ISP Regional ISP
IXP
IXP
Tier 1 ISP Tier 1 ISP Google
IXP
Introduction
Tier-1 ISP: e.g., Sprint
…
to/from customers
peering
to/from backbone
…
………
POP: point-of-presence
1-41