Lecture10

advertisement
COP 5611 Operating Systems Spring 2010
Dan C. Marinescu
Office: HEC 439 B
Office hours: M-Wd 2:00-3:00 PM
Lecture 10



Reading Assignment: Chapter 7 from the online textbook
A progress report for the project is due on every Monday.
Last time:


Network properties
Today:

Layering
 Link layer
 Network layer

Next time

Routing
2
Networks encounter a avst range of
D ata rate s
Prop agati on, trans mis si on, qu euin g, and proce ss ing d elay s.
Loads
Num bers o f use rs
Networks traverse hostile envir
onments
Noi se d amag es d ata
Links sto p working
Best-effort networks have
Varia ble d elay s
Varia ble tran smi ss ion rate s
D is carde d pac kets
D upl ica te pac kets
Maxi mum p ack et len gth
Reo rd ered de live ry
3
Recovery of lost packets
A
se nd re ques t,
se t ti mer
B
ti me
req uest 1
res pons e 1
receive respo nse,
res et timer
X
se nd re ques t,
se t ti mer
req uest 2
ti mer e xp ires,
res end reque st,
se t ne w time r
receive respo nse,
res et timer
X
overl oade d
fo rwa rder
di sca rds
req uest
pa cket.
req uest 2’
res pons e 2’
X
4
Duplicate requests
B
A
req uest 3
se nd re ques t,
se t ti mer
X
ti mer e xp ires,
res end reque st,
se t ne w time r
receive respo nse,
res et timer
req uest 3’
X
overl oade d fo rwa rder
di sca rds re spon se 3
du plicate arrives at B
B s ends resp onse 3’
res pons e 3’
5
Delays and recovery lead to duplicate response
B
A
se nd re ques t,
se t ti mer
req uest 4
res pons e 4
ti mer e xp ires,
res end
receive
res pons e,
res et timer
req uest 4’
X
res pons e 4’
pa cket containi ng re spon se
ge ts d elayed
du plicate arrives at B
B s ends resp onse 4’
receive
du plicate
res pons e
6
Layering


Simplify the design
Example- RPC
7
Client-server communication based on RPC
resu lt 
FIR E
(#, target, ac tion)
Client stub
request:
Prepare
request
mes sage.
Send to
service
Wait for
res pons e.
proc: FIRE
args:
3
type: integer
value: 2
type: string
value: “Lucifer”
type: pro ced ure
value: EV ADE
proc edureFIR E (nmi ss, where, reac t)
...
retur n resu lt
Service stub
Receiv e
request
mes sage.
Call
requested
procedure.
Prepare
res pons e
mes sage.
Send to client.
res pons e:
acknowledgment
type: string
value: “dest royed”
8
Main prog ram
ap plicati on p rotocol
calle d pro ced ure
RPC cl ient stu b
pre sentatio n pro tocol
RPC service s tub
9
Main prog ram
fi re
(return)
RPC cl ient stu b
se nd_
me ssag e
ap plicati on p rotocol
fi re
pre sentatio n pro tocol
(return)
RPC service s tub
se nd_
me ssag e
receive_
me ssag e
Clie nt n etwork
p ackage
calle d pro ced ure
tra nspo rt pro tocol
receive_
me ssag e
Service n etwork
pa ckage
10
Multiple protocols may be supported at each layer
La ye r One
A
La ye r Two
La ye r Thre e
B
J
X
C
K
D
L
Y
Z
11
Multiplexing and Demultiplexing
P1
P2
P3
P1
P4
P4
Sending side
12
P2
Receiving side
P3
Network layers for store and forward networks

Every module has three interfaces:

To the layers above
 To the layers below
 To the peer layer on another system


Each layer hides the operation of the layer below from the layer
above and provides its own interpretation of the important features
of the layers below.
A minimum of three layers are necessary:
Link layer  move data from one point to another. Includes
 Network layer  forward data through intermediate node towards the
destination
 End-to-end-layer  provides all the functions required by the
application including


Encapsulation: each layer treats information received from the
layers above as raw data and adds control information (headers
and trailers) understood only by its peer.
13
Link layer
DATA
L INK _SEND
NETW ORK _HA NDLE
B
A
Li nk
La ye r
(pk t, link2)
li nk 1
li nk
pro tocol
C
Li nk
La ye r
li nk 2
LT DATA LH
li nk
pro tocol
Li nk
La ye r
14
Network layer
DATA
NETW ORK_ SEND
(s egme nt, “IP”, na p_11 97)
ne twork
Netw ork
La yer
Netw ork
La yer
pro tocol
NT DATA NH
lINK_SE ND (pa cke t, link 2)
Link
La yer
LT NT DATA NH LH
li nk 2
li nk
pro tocol
L INK _SEND
(pa cke t, link 5)
NETWOR K_HANDL E
Link
La yer
Link
La yer
li nk5
15
End-to-end layer
FIR E
(7, “Lu cife r”, eva de)
FIR E
DATA
End-to-End
Layer
(RPC)
end -to-en d
End-to-End
Layer
(RPC)
(7, “Lu cife r”, eva de)
protoco l
ET DATA EH
Netw ork
Layer
Netw ork
Layer
Netw ork
Layer
NT ET DATA EH NH
Link
Layer
Link
Layer
Link
Layer
Link
Layer
LT NT ET DATA EH NH LH
16
Layering in different network architectures

OSI –has 7 layers

The upper four layers are:





Internet is based on a model including






Application
Presentation  translate data formats and emulate the semnatics of RPC
Transport  deal with lost, duplicate, out of order, segments
Session  deals with connectivity
Application
Transport – transports segments
Network – transports packets
Data Link – transports frames
Applications are very diverse and it makes no sense for a lower
layer to implement functions required by higher layers.
The end-to-end argument  application knows best
17
Example of an end-to end argument


Should we have a checksum implemented at the link layer or should
leave it for the application protocol e.g., a file transfer protocol?
If we implement it at the link layer 

Advantage: detect earlier an error
 Disadvantage: the data may still be affected by errors when buffered at
the upper layers.
18
Application, Transport, Network, and Data Link Layer
Protocols
Application Layer
HTTP
FTP
TELNET
NFS RPC
DNS
Transport Layer
TCP
UDP
Network Layer
IP
Data Link Layer
Satellite
Ethernet
Wireless
SNTP
Hourglass communication model
Teleconferencing
Videoconferencing
Application Layer
RealAudio
Telnet
WWW
Email
Transport Layer
Network Layer
FTP
TCP
UDP
IP
ATM
Physical and Data Link Layers
20
Dial-up
Modems
LANs
Wireless
Direct Cable
Broadcast
Frame
Sateliite
Relay
Network composition

Network composition:
Mapped composition  A network layer is built directly on another
network layer by mapping directly higer-layer network addresses to
lower-layer network addresses. Example:
 Internetworking  interconnect several networks together, e.g., the
Internet
 Recursive composition  a network layer rests on a link layer that it is
itself a complete network. Examples:
 Overlay networks. E.g., Gnutella

21
Network composition. The overlay network Gnutella uses
for its link layer an end-to-end transport protocol of the
Internet. In turn, the Internet uses for one of its links an
end-to-end transport protocol of a dial-up phone system
Fil e Tra nsfe r Progra m (en d-to-e nd l ayer)
Fil e tra nsfe r syste m
Gnute lla (network la ye r)
Tran sport Proto col (end -to-en d la ye r)
Internet Proto col (netwo rk l ayer)
dia led con nection (end -to-en d la ye r)
tel epho ne s wi tch (netwo rk l ayer) (lin k
layer)
physi cal wire (l ink layer)
Internet
(lin k
layer)
dia l-up
tel epho ne
netwo rk
22
More about the link layer


Function: push bits from one place to another
In this architecture the link layer combines:

MAC (medium access control layer)
 The physical layer





Analog worlds
Capacity of a communication channel
Capacity of a noisy communication channel
C= B x log (1+ signal/noise)
B is the bandwidth in Hz
signal/noise – ratio of signal power to noise power
Signals attenuation
Signals are distorted over long distances
23
Serial transmission
V
1
0
1
0
1
0
1
0
1
ti me
24
How to push bits from A to B which do not share the same
clock? First raise the READY line
data
A
ready
B
acknowl edge
25
Signal attenuation and shape distortion
A
B
26
Error detection and error correction


Encode data with an error detection code.
Use error correction if necessary.
27
Framing


A pattern of bits serve as a frame delimiter – e.g., seven 1’s
Bit stuffing:
The sender: add a 0 whenever it encounters a pattern of six 1’s in data
 The receiver: remove a 0 following a pattern of six 1’s in data



Add a frame header
Add a frame trailer
28
Sender bit stuffing procedure
pr ocedureFRAME _ TO_ BIT (frame _data, le ngth)
on es_ in_a _row= 0
// Firs t sen d frame c onte nts
for i from 1 to le ngth do
SEND _BIT (frame _data[i]);
if frame _data[i] = 1 then
on es_ in_a _rowon es_ in_a _row +1;
if on es_ in_a _row= 6 then
// Stuff a zero so that da ta doe sn’ t
SEND _BIT (0);
// look like a framin g marke r
on es_ in_a _row 0;
else
on es_ in_a _row 0;
// Now sen d framin g marke r.
for i from 1 to 7 do
SEND _BIT (1)
29
Receiver bit stuffing procedure
pr ocedureBIT _ TO _FRAME (rcv d_bit)
on es_ in_a _rowintegerinitially 0
if on es_ in_a _row< 6 then
bits_in_frame  bits_in_frame + 1
frame _data[bits_in_frame]  rcv d_bit
if rcv d_bit = 1 then on es_ in_a _row on es_ in_a _row+ 1
else on es_ in_a _row 0
else
// This may be a s eve nth on e-bit in a row, che ck i t out.
if rcv d_bit = 0 then
on es_ in_a _row 0
// Stuffed b it, don 't us e it.
else
// This is the en d-of-fra me ma rk er
LINK _R EC EIVE (frame _data, (bits_in_frame - 6), link_id)
bits_in_frame  0
on es_ in_a _row 0
30
A network protocol may use multiple data link protocols
Network La ye r
Network pro tocol
Sta ndard
pro tocol
High
rob ustn ess
pro tocol
Experi mental
pro tocol
Li nk Layer
31
Multiple transport and data link protocols
Ad dress
In terne t Reso luti on Ap pletalk
Protoco l Protoco l Protoco l
Sta ndard
pro tocol
High
rob ustn ess
pro tocol
Path
Ve cto r
Exch ange
Protoco l
Experi mental
pro tocol
Network La ye r
Li nk Layer
32
Sending a frame
str uctureframe
str ucturec hec ked_ con tents
bit_string ne t_protoc ol
bit_string pa yloa d
bit_stringc hec ksu m
// multi plex ing p aramete r
// payl oad d ata
pr ocedureLINK _SEND (da ta_bu ffer, link_identifier, lin k_proto col, network_p ro toco
) l
frame instance ou tgoin g_frame
ou tgoin g_frame .che cke d_c onten ts.pa yloa
d da ta_bu ffer
ou tgoin g_frame .che cke d_c onten ts.ne t_protoc
ol da ta_bu ffer.network_p ro toco l
frame _len gth LENGTH (da ta_bu ffer) + he ader_length
ou tgoin g_frame .che cks um C HECK SUM (frame .che cke d_c onten ts
, frame _len gth)
s endp ro c link_p ro toco[tha
l
t_lin k.protoc ol]
// Selec t lin k protoc ol.
s endp ro c(ou tgoin g_frame, frame _len gth, link_identifier
) // Send fram e.
33
Receiving a frame
pr ocedureLINK _R EC EIVE (rec eive d_frame
, le ngth, link_id)
frame instance rec eive d_frame
if C HECK SUM (rec eive d_frame .che cke d_c onten,ts
le ngth) =
rec eive d_frame .che cks um
then
// Pas s go od pa cke ts up to nex t laye r.
go od_fram e_c ountgo od_fram e_c ount+ 1;
GIVE _TO _NETWORK _HANDLER (rec eive d_frame .che cke d_c onten ts.pa yloa
, d
rec eive d_frame .che cke d_c onten ts.ne t_protoc
);ol
else ba d_frame _co untba d_frame _co unt+ 1 // Ju st c ount d amag ed frame .
// Eac h network l ayer proto col hand ler mus t caSET
ll _HANDLER be fore the fi rs t pac ket
// for that proto col arri ves …
pr ocedureSET _HANDLER (ha ndle r_ proce dure
, ha ndle r_ protoc ol
)
ne t_han dler[ha ndle r_ protoc ol
]  ha ndle r_ proce dure
pr ocedureGIVE _TO _NETWORK _HANDLER (rec eive d_pa cke,tne two rk _protoc ol
)
ha ndle r ne t_han dler[ne two rk _protoc ol]
if (ha ndle r ° NULL ) call ha ndle r(rec eive d_pa cke,tne two rk _protoc ol
)
else un expe cted _protoc ol_ cou nt un expe cted _protoc ol_ cou nt+ 1
34
Link properties

We distinguish several types of links:

Point-to-point
 Broadcast links

Each link imposes a maximum transmission unit (MTU)  the
largest frame size which affects

Timing, un upper bound on link commitment time
 Error, the longer the frame the larger the probability of error for a given
error rate on the link
 Buffer space at each end
35
The network layer

A network can be viewed as consisting of
Network core – carries out segments from one communicating entity to
another
 Network periphery – hosting the communicating entities at attachment
points


Addressing – each communicating entity must have a unique
address.
36
35
netwo rk
attach ment
poi nt
01
07
24
33
Network
11
40
41
16
39
42
netwo rk
add ress
37
Internet Core and Edge
Server
Satellite
Ethernet
Database
Ethernet
Disk array
Edge Router
Satellite dish
Edge Router
Local ISP
Local ISP
Border Router
Local ISP
Regional ISP
Internet core
National Service Provider
NAP
NAP
National Service Provider
NAP
National Service Provider
Regional ISP
Local ISP
Border Router
Local ISP
Edge Router
Edge Router
Radio tower
Dialup System
38
PDA
Modem
Router
Input Port
LT - Line
Termination
Input Port
Data Link
Protocol
Output Port
Lookup
Forwarding
Queuing
Queuing
Switching
Fabric
Output Port
Input Port
Routing
Processor
39
Output Port
Data Link
Protocol
LT
Router supporting QoS (Quality of Service)
Shaper
Dispatcher
and Buffer
Acceptance
Classifier
Input
flows
40
Policer
Output
link
Network model




The network layer transports packets
The network core consists of routers which forward packets using
routing tables
The input for network layer on a host at the periphery of the network
is a segment in a segment buffer at the transport layer.
The output is a link buffer
41
struc tur epac ket
bit_string so urce
bit_string des tina tion
bit_string end _protoc ol
bit_string pay load
proc edureNETWOR K _ SEND (se gmen t_buffe r, des tina tion,
network_ protoc ol, end _protoc ol)
pac ket instance outg oing _pac ket
outg oing _pac ket.p aylo ad se gmen t_buffe r
outg oing _pac ket.e nd_p ro tocoend
l
_protoc ol
outg oing _pac ket.s ourc e MY _ NETWOR K _ADDRESS
outg oing _pac ket.d estinatio n des tina tion
NETWOR K _HANDLE (outg oing _pac ket
, net_ protoc ol)
42
proc edureNETWOR K _ HANDLE (net_ pac ket, net_ protoc ol)
pac ket instance net_ pac ket
if net_ pac ket.de stin ation° MY _NETWOR K _ADDRESS then
nex t_hop  LOOKUP (net_ pac ket.de stin ation, forwarding _table)
LINK _ SEND (net_ pac ket, nex t_hop, lin k_proto col, net_ protoc ol)
else
GIVE _TO _END _LAYER (net_ pac ket.pa yloa d
,
net_ pac ket.en d_proto col
, net_ pac ket.so urce)
43
Segm ent prese nted to
the netwo rk l ayer
DATA
Packet pres ente d to
the lin k l ayer
sourc e &
destination
end
protocol
DATA
Fram e
app earin g
on the link
frame netw ork sourc e &
mark protocol destination
end
protocol
DATA
chec k frame
sum mark
Exampl e
1111111
RPC
“Fire”
97142 1111111
55316
IP
41 —> 24
44
All hosts must have logical addresses


All devices have a physical address of the interface
Must obtain a logical address
45
Dynamic IP address assignment -DHCP
DHCP request
UDP datagram for the
DHCP server
Internet
DHCP response
UDP datagram for the
DHCP relay
DHCP relay
Local Area Network
DHCP request
broadcast frame
Laptop
DHCP response
unicast frame
Destination address:
the physical address
of host interface
DHCP
server
Download