Sunteți pe pagina 1din 16

15-441 Computer Networks

Mor Har hol-Balter

Le ture 2
August 28, 2002

Le ture 2: Pa ket-swit hing vs. Cir uit-swit hing, Layering


& Proto ols
Announ ement: Please remember to look at lass Web page, to get le ture notes and see
s hedule and readings:
http://www. s. mu.edu/srini/15-441/F02

Please read le ture notes immediately after ea h lass. They are here to help you better
digest the lass, given that I usually talk pretty fast during lass. They are not meant as a
substitute for lass!
Remember to ome to o e hours! We want to get to know you.
As we said last time, the rst three le tures are overview, after that, we'll slowly de ne ea h
pie e of the network starting from the highest-level layer and working our way downwards.
Continuing with our overview ...

1 Pa ket-swit hing vs. Cir uit-swit hing


Consider a network. Suppose that Appli ation A on Host A wants to send a message to
Appli ation B on Host B, on the other side of the network. Host A might start by breaking
up its message into individual pa kets.
There are two general types of network design: Pa ket-Swit hing and Cir uit-Swit hing.
Pa ket-Swit hing networks have the property that ea h of the pa kets in the message
would travel independently to Host B. Ea h pa ket is a self- ontained unit, ontaining the
address of Host B. Su h a pa ket is referred to as a datagram. It ould be the ase that
all datagrams take di erent paths. The datagrams might arrive out-of-order at Host B.

By ontrast, in Cir uit-Swit hing networks, before Host A an send the rst pa ket to
Host B, a onne tion ( ir uit) must be established between App. A and App. B. This
is one single path. Whenever Host A sends stu to Host B it will send it over this path.
Pa kets don't need to arry the address of Host B. Instead they just arry their ir uit
identi er. When App A is done, it tears down onne tion.
The above is the main di eren e between Pa ket-Swit hing and Cir uit-Swit hing.
1

A5

A2

A1

A4

A3

Figure 1: Pa ket-swit hing

A
A5

A4 A3

A2 A1

Figure 2: Cir uit-swit hing


Now we look at some onsequen es of the above de nition.
Pa ket Loss omparison: Statisti al multiplexing vs. TDM

First observe that Pa ket-Swit hing an result in pa ket loss.


Question:

How does loss o ur?

Loss o urs when run out of room in router's bu er. There are so many pa kets
that want to go on some outgoing link that we don't have room to hold them in the outoing
bu er for that link. We'd like to be able to temporarily in rease the outgoing bandwidth
on the link (so as to get pa kets out faster) or in rease the bu er length (so as to have room
to store extra pa kets), but unfortunately these are nite xed quantities.
Answer:

Question:

Can loss be eliminated under Pa ket-swit hing? Under Cir uit-swit hing?

Pa ket-Swit hing is a free-for-all. There is no way to make reservations of


bandwidth or bu er spa e, sin e the pa kets move independently of ea h other. Pa kets
arriving at router from di erent ows are handled in FCFS order ( rst- ome- rst-served).
For this reason Pa ket-Swit hing often alled statisti al multiplexing.
Answer:

Cir uit-Swit hing an ontrol loss. Bandwidth and bu er spa e may be reserved for the
onne tion at the time of onne tion setup.
Note, Cir uit-Swit hing doesn't have to mean that a link an only be used by one ir uit.
A link may be shared by several ir uits. These are often alled virtual ir uits. Ea h
reserves a portion of bandwidth. Ea h thinks that it is the only ir uit. The way in whi h
ir uits share a link under Cir uit-swit hing is to use TDM time-division multiplexing.
Time Division Multiplexing for es the ir uits to take turns. Be ause one of the big reasons

for doing Cir uit-Swit hing is to be able to make bandwidth reservations for the onne tion,
reservations are very often linked to de nition of Cir uit-Swit hing. But this is not always
the ase.

C
(a)

AC B A C B A C B A

(b)
Figure 3: (a) Shows link whose bandwidth is shared by 3 Virtual Cir uits, A, B, and C,
ea h re eiving 1/3 of the bandwidth. (b) Shows how the taking turns a tually happens, using
TDM, on a pa ket-by-pa ket basis.
Question:

Give an example of a Cir uit-Swit hing network?

Telephone. De nitely get your own ir uit and guaranteed bandwidth, so hear
well. ATM networks (we'll des ribe these in detail later in ourse).

Answer:

Question:
Answer:

Is the Internet Pa ket-swit hed or Cir uit-Swit hed?

Pa ket-Swit hed ... although not everyone is happy with that de ision.

Throughput omparison: Statisti al multiplexing vs. TDM

Pa ket-Swit hing allows whi hever pa ket arrived rst to go rst, regardless of whi h ow
it omes from. In Cir uit-Swit hing, ows have spe i ed slots (turns), and you an only
go on during your turn. This makes Cir uit-Swit hing ine ient. Cir uit-Swit hing wastes
bandwidth if one onne tion has nothing to send during its turn, but another one does.
Example:

Suppose user A sends data over a link in following bursty manner: 1/10th of
the time A is a tive generating data at 100 Kbps. 9/10th of the time A is sleeping. (We
an't ontrol when the generating a tivity is taking pla e)
Question:

support?

Under Cir uit-Swit hing, if we have a 1Mbps link, how many su h users an we

10. And no delays for any of them, regardless of when ea h user hooses to
generate data.

Answer:

It turns out that under Pa ket-Swit hing, we an usually support 30 users with almost no
delay (assuming the users are un orrelated).
Question:

What's the probability that more than 10 (11 or more) users are a tive at on e?

Answer:
Pr f>

10 users are a tive at on eg <

30
11

!  11
1


10

= :0005

Thus under Pa ket-Swit hing, even with 30 users, the probability that there will be a delay
is less than :0005.
Sin e real ows are in fa t bursty, as in the above example, promoters of Pa ket-Swit hing
like to say that: \Pa ket-Swit hing almost always has similar delay performan e to Cir uitSwit hing while allowing for 3x more users."
However the advantage of Cir uit-Swit hing wrt delay is that Cir uit-Swit hing an provide
guaranteed upper bounds on delay (and guaranteed zero loss), whereas Pa ket-Swit hing
an not.
Question:
Answer:

le tures.

Give an example of an appli ation for whi h you'd want to use ir uits.

Anything where delay might be riti al. Audio tape. We'll dis uss this in later

Overhead omparison

With Cir uit-Swit hing, the sender has to wait until the onne tion has been established
before sending. With Pa ket-Swit hing, ommuni ation an start immediately.
Routing Table omparison

Routers ontain information (usually in the form of a table) whi h tell them where to
forward a pa ket.
In the ase of pa ket-swit hing, the pa ket arries with it the address of its destination host.
Ea h router stores a table whi h tells it to whi h adja ent router it should send the pa ket
as a fun tion of the datagram's destination address.
Next Router

Destination Address
128.2.6.15

R2

128.2.97.3

R4

132.3.4.15

R2

138.3.4.14

R2

Figure 4: Routing table in routers in the ase of pa ket-swit hing networks.


In the ase of Virtual Cir uits, the pa ket ontains a
totally spe i es its route.

Virtual Cir uit Number

whi h

But how is this done? Given a network with n nodes, there many be
exponentially-many di erent possible Virtual Cir uits. If ea h Virtual Cir uit in the network
has a unique Virtual Cir uit number, the Virtual Cir uit number ould be huge! We don't
want to arry something so huge in our header.
Big Question:

There's a tually a simple solution. I will des ribe this during the se ond half of
the ourse. You an try to gure it out yourself right now if you like. The point is that in
Cir uit-Swit hing you an a tually usually get away with mu h smaller routing tables
than with pa ket-swit hing. This is why Cir uit-Swit hing is often touted for its speed.
Answer:

It's true that the total number of Virtual Cir uits in the network may be huge.
However the number of Virtual Cir uits passing through a single router is likely not big at
all.

Hint:

Summary of Comparison between Pa ket-Swit hing and Cir uit-Swit hing

Remember that the Internet is Pa ket-Swit hed, not Cir uit-Swit hed.
To summarize, we in lude here a summary omparison of Cir uit-Swit hing vs. Pa ketSwit hing:
Pa ket-Swit hing:


Every pa ket arries destination IP address { pa kets alled datagrams.

No guarantees about loss.

No guarantees about delay: best-e ort

Better use of bandwidth: statisti al-multiplexing { free for all

No startup overhead for setting up onne tion, but per-pa ket pro essing overhead is
typi ally higher than in Cir uit-Swit hing.
Routers are dumb (simple).

Cir uit-Swit hing:




Every pa ket arries Virtual Cir uit Identi er header { pa kets often alled ells
(ATM-speak).

Typi ally, Guaranteed no loss due to reservation.

Typi ally, Guarantees about delay due to reservation.

Wastes bandwidth { too rigid.

Initial startup overhead for setting up onne tion, but very fast forwarding of pa kets
thereafter. We'll see later in the ourse that this is due to being able to get away with
a very short ir uit identi er.
Routers maintain some state.

Another idea: Message Swit hing

In Message-Swit hing, whole message a ts like a single pa ket, not broken up.
Question:

What are the pros of message swit hing over pa ket swit hing?
6

Message swit hing skips overhead of unbundling and bundling. Re all pa ket
swit hing must break message into pa kets. Furthermore, in Pa ket-Swit hing, the pa kets
mu h ea h arry a destination header { overhead.
Answer:

Question:
Answer:

What are the ons of message swit hing over pa ket swit hing?

Can't take as mu h advantage of pipelining, given the store-and-forward model.

A little bit of history { the war between Pa ket-Swit hing and Cir uitSwit hing








In 1960's Telephone Network was the dominant ommuni ation network. It used
Cir uit Swit hing be ause voi e must be transmitted at a onstant rate.
In 1967 ARPANET was started by the government resear h agen y ARPA. This was
the rst pa ket-swit hed network.
By 1972, ARPANET was up to a whopping 15 nodes.
During this time, various other pa ket-swit hed networks were introdu ed. Also during this time Ethernet was introdu ed as a te hnology that worked well for small
distan es.
In 1974 the notion of a \network of networks" was introdu ed and people started talking about minimalism, best-e ort servi e, stateless routers, and de entralized ontrol.
During the 1980's ATM (a ir uit-swit hing te hnology) be ame huge be ause of its
speed and almost won out against the ARPANET. However, the ARPANET prevailed
and be ame what we now all the Internet.
A lot of the work on ARPANET was done via Computer S ien e departments, and
other networks like CSnet, that onne ted only CS departments.
In 1989 the Web was introdu ed
In 1995 the US government transferred ontrol of the Internet ba kbone to private
arriers { all those ISPs and NBPs.
More re ently delay-sensitive appli ations (intera tive-audio) have en ouraged resear hers to start thinking about how to make pa ket-swit hing more like ir uitswit hing.
Today we have about 100 million ma hines on the Internet.

Be ause Pa ket-swit hing won the war, throughout most of the ourse we will only talk
about pa ket-swit hing. However we will ome ba k to ir uit-swit hing and spend a whole
le ture on it about half-way through the ourse (see s hedule on lass web page).

2 Layering and Proto ols


2.1

Motivation

Remember Pa ket-Swit hing provides no performan e guarantees. Spe i ally no delay


guarantees and no guarantees wrt loss.
But our appli ations often demand more.
App may demand no loss.
App may demand predi table delays.
How an we give this to app?
Wrt predi table delays, Internet an't help you be ause it's a Pa ket-Swit hing network so
no ontrol over queueing delays.
So what's typi ally done for delay-sensitive appli ations like video over the
Internet or audio over the Internet?
Question:

10 minute wait before video starts. Allows for future delays of up to 10 minutes
in re eiving pa kets. If pa ket arrived > 10 minutes late, it's just dropped.

Answer:

We'll have a detailed le ture about multimedia over the Internet later in lass.
Question:

So what does the Internet do about loss? Do we just live with it?

Answer: No. There's a proto ol alled TCP - Transmission Control Proto ol whi h
sits on top of the Pa ket-Swit hing layer and makes sure that there are no losses.

How do you think that TCP an manage to enfor e that there will be no loss,
given that it's running on top of IP, whi h is a Pa ket-Swit hed layer?

Question:

Answer: TCP keeps tra k of the pa kets and when it dete ts a loss it asks the IP layer to
resend the pa ket.

But what is a \layer"? That's the topi of this se tion.


Network layering an't be de ned in a senten e. There are several important notions involved:
8

Bla k-box abstra tion

Proto ols

En apsulation

Multiplexing/Demultiplexing

We will dis uss ea h of these aspe ts of layering, while at the same time using as our example
the layering used in the Internet, a.k.a. the Internet Proto ol Sta k.
2.2

The on ept of bla k-box abstra tion

Remember our overall Goal: To get Appli ation A at host H1 to intera t in a meaningful
way (reliably) with Appli ation B at host H2 over the network.
Layering is an approa h used for building a network that an do this.
Layering is the notion of relying on lower-layer servi es as a bla k box | just like we
do when we write ode! (Fun tion foo is de ned in terms of a (simpler) fun tion foobar.
Fun tion foobar is de ned in terms of a (simpler) fun tion foobarbar. And so on, until we
get to the really basi stu .
There are two advantages of layering (just like there are two advantages to using
abstra tion in your ode). What are these?

Question:
Answer:

1. It de omposes the problem of building a network into more manageable omponents.


2. It provides a more modular design { more exible if you want to modify a single layer.
Question: There are also disadvantages to layering (just like the disadvantage to using
abstra tion in your ode). What are these?

In writing ode, the reason my students give me for not wanting to use abstra tion
is that, although leaner, it makes the ode a lot longer. Also sometimes a lot of arguments
need to be passed up from one level of abstra tion to the next (from one fun tion to the
next), and this wouldn't be ne essary if you ould just put all the ode into one routine.
These are some of the same reasons why some people argue against layering. We'll dis uss
this in more depth later in the ourse.
Answer:

Qui k Example of bla k-box abstra tion:

Suppose have lient pro ess on Host H1 talking to web server pro ess on Host H2 (Appli ation Layer). When the lient wants to talk to the server, it writes into a so ket { we'll
study these next le ture. The lient trusts that there is some implementation of so kets
(Transport Layer) that takes the message from the lient pro ess to the server pro ess. The
lient doesn't need to know anything about how this works. It's all a bla k box to the lient.
This type of abstra tion happens at lower levels too. There is software that implements
these so ket alls, i.e., it allows one pro ess to talk to another pro ess (Transport Layer),
but that software assumes that the existen e of a fun tion whi h an send a pa ket from
one host to another (far away) host (Network Layer). It doesn't know or are how this lower
fun tion is implemented. It just wants to use it as a bla k box. Similarly, the fun tion whi h
an send a pa ket from one host to another (far away) host (Network Layer), relies on a
lower-level fun tion whi h an send a pa ket from one router or host to a neighboring router
or host (Data Link Layer) (here neighbor is a little looser than you might be thinking), et ..
Network ode is organized in this way. These di erent levels of abstra tion are referred to
as layers. It is often said that ea h layer \o ers a servi e" to the higher layer.
Every host and router in the Internet has 5 layers as shown below. Their organization is
similar to the above Qui k Example.
Layer 5

Application

Layer 4

Transport

Layer 3

Network

Layer 2

Data Link

Layer 1

Physical

Figure 5: Layering in the Internet: the Internet proto ol sta k.


Note, your book des ribes the OSI { Open Systems Inter onne tion layering ar hite ture, whi h shows two more layers: The Presentation and Session layers. We will ignore
these during our overview, sin e they are often left out of network ode, or bundled in with
another layer.

10

2.3

The on ept of proto ols

Ea h of the layers in the above sta k an be implemented by one of several


hen e the name Internet proto ol sta k.

proto ols,

A proto ol is an agreement between parties on how ommuni ation between the parties
should take pla e. This in ludes the language to be used in ommuni ation, how to take
turns in speaking, how to terminate the onversation, et ..
We Ameri ans have a proto ol that says: when you see someone you know, you say \Hi,
how are you?" and then ontinue walking without waiting for any answer. The other party
understands that they should reply with \Hi, how are you?" and also ontinue walking
without waiting for any answer. Sin e all parties understand this, it works quite well. If
someone were to deviate from the proto ol, by a tually answering the question, it would
ause problems.
In the same way Network proto ols an exist between omputer programs or hardware
omponents.
As we said earlier, ea h of the layers may be implemented by one of several proto ols. Let's
dis uss these proto ols a bit.
In the Appli ation Layer, there are many proto ols available to us. For example, HTTP,
whi h de nes the exa t language that a Client's Browser pro ess should use when speaking
to a Web server pro ess. Another example, ftp, is a proto ol whi h transfers les from
one host to another host. SMTP is the Simple Mail Transfer Proto ol whi h is used in
ommuni ating between your mail pro ess (elm or pine) and a mail server whi h houses
your mail.
In the Transport Layer there are also many proto ols available to us. The most popular
are TCP { Transport Control Proto ol and UDP { User Datagram Proto ol.
is onsidered a bare-bones minimal transport layer. All it does is the bare-minimum
fun tion required by a transport layer { i.e. it provides a way for a pro ess on ma hine A
to talk to a pro ess on ma hine B, while making use of the power of the network layer to
send pa kets from ma hine A to ma hine B. Remember that the network layer may send
these pa kets out of order, may lose pa kets, et .. UDP does not orre t for this. It only
makes sure that whi hever of the pa kets arrive, end up being dire ted to pro ess B.
UDP

is onsidered a full-servi e transport layer. In addition to providing a way for pa kets


to move between pro esses, it also makes sure that the pa kets arrive in order and that they
are not lost. TCP does all sorts of other things as well, like ontrolling ongestion in the
network by ontrolling the rate at whi h one pro ess sends pa kets to another.

TCP

11

Question:

than UDP?

You might be thinking, why not always use TCP, sin e it does so mu h more

TCP has a high overhead, whi h means it adds a lot of delay, and also variability
in delay. Many appli ations therefore prefer to run on top of UDP. For example your video
server might prefer to use UDP, sin e loss is not so ru ial and variability in delay is ru ial.
However your mail server will de nitely run on top of TCP, sin e it's important that none
of those pa kets of mail get lost.

Answer:

For the Network Layer there is only one proto ol. This is IP { the Internet Proto ol,
whose job it is to forward pa kets from one host to another in a Pa ket-Swit hed manner.
Most of what we study in this ourse will be proto ols, so I won't belabor it further now.
The proto ol at a given layer de nes two things:
First, for the given layer i, the proto ol at layer i de nes the interfa e/language/syntax
that layer i + 1 will use to a ess the \servi e" that layer i provides. For example, there
are di erent transport level proto ols (e.g., TCP and UDP). These would ea h provide
a di erent so ket interfa e to the Appli ation level. I think of this as master-to-slave
ommuni ation.
Se ondly, the proto ol de nes a language/order by whi h \peer" layers an talk to ea h other
on di erent ma hines. Realize that ea h ma hine has this whole sta k of layers implemented.
When an appli ation running on Host H1 ommuni ates with an appli ation running on
Host H2, then the transport proto ol on H1 will \indire tly" be ommuni ating with the
same transport proto ol on H2. Likewise the network proto ol on H1 will \indire tly" be
ommuni ating with the network proto ol on H2, et .. To understand what we mean by
this peer-to-peer ommuni ation, we need to turn to the notion of en apsulation.
2.4

The on ept of en apsulation and headers

Consider a Client Appli ation on host H1 whi h wants to send a message to a Web Server
Appli ation on host H2. The Client's message is written in the \language" HTTP (a
proto ol). The Client appli ation writes its message into a so ket and then TCP (the
transport proto ol) magi ally takes the message to the so ket on the server where the
transport proto ol on the server then hands the message up to the Server appli ation (the
server reads from its so ket).
Let's look at how TCP a hieves its fun tions. First, TCP has to make sure to get the
message to the right pro ess on the target host (the server). TCP is passed the appropriate
information about the target pro ess from the Appli ation layer via the so ket all (we'll
see this next lass). However it needs to make sure that when the message gets to the target
12

Application

Application

Transport

Transport

Network

Network

Link

Link

Physical

Physical

Figure 6: Communi ation between the layers


host, the target host's TCP proto ol knows where to send the message. How an this be
done? Before we answer, observe that TCP also has to do many other things. For example,
it segments long messages into shorter \segments" (pa kets in the transport layer are alled
segments), whi h must somehow arrive at the server in the orre t order. How an TCP
ensure this?
To a hieve both of the above fun tions, TCP needs to atta h a header to ea h segment that
it sends. This header at the very least must ontain a sequen e number for the segment so
that TCP on the server side an put the segments ba k in the orre t order (remember that
the network layer, whi h TCP relies on, might deliver these segments in a random order).
This header should also in lude an identi er for the target pro ess, so that the TCP layer
on the target ma hine knows where to deliver the message.
In Network-speak we say: TCP on the lient end takes the message given by the Client
appli ation, hops it up, and atta hes a header to ea h pie e. We say that the appli ation's message has been en apsulated by TCP within a new TCP-level-message. TCP on
the lient end then sends the TCP-level-message to the server's TCP (via the help of the
network layer). The server's TCP reads the TCP header, whi h gives it the information it
needs to do what it needs to do. It then strips away this header and passes the original
appli ation-level-message to the right server pro ess.
This on ept of adding header happens at every level of the proto ol sta k, regardless of
whether a message is being hopped up or not. There is always important information
whi h the lient-side layer needs to ommuni ate to its peer server-side layer. Thus by the
time a message is sent, several headers have been atta hed to it by the lient side. These
headers are all stripped in the opposite order at the server end.
13

Application level message


Transport
Segments
Network
Layer
Data
link
Layer

M1

TH M2

NH TH M1

NH TH M2

LH NH TH M1

LH NH TH M1

TH

Source
Figure 7: Illustration of how message M is divided into 2 segments (pa kets) M1 and M2.

Headers are then added to both M1 and M2. Headers get added all the way down the
sour e's sta k. Headers get stripped all the way up the destination's sta k (just reverse the
arrows). The header added last at the sour e will ( onveniently) be the rst to be stripped
at the destination. TH { Transport layer header above at the very least ontains the
destination pro ess. NH { Network layer header above at the very least ontains the
destination IP address. LH { Link layer header above at the very least ontains the
neighbor address (MAC address).

14

2.5

The on ept of multiplexing and demultiplexing

There's only one implementation for the network layer. That's IP, the Internet Proto ol.
However, there are multiple implementations of the other layers. For example there are two
transport layers: TCP and UDP. If the sour e uses a parti ular implementation (for example
the sour e host uses the TCP proto ol at the transport layer) then it would like to onvey
to the destination host that it too should use the TCP proto ol when interpreting the
information.
How do you think the sour e host onveys to the destination host that it's using
TCP (as opposed to UDP or some other transport proto ol)?

Question:

The sour e host does this by spe ifying \TCP" in the network-layer pa ket
header. When the network-layer pa ket header is stripped on the target host, the target
host's network layer sees the TCP and knows to pass the segment up to its TCP proto ol,
rather than its UDP proto ol.
Answer:

The transport proto ol does the same kind of thing when it embeds the destination pro ess
into its transport-layer header, so that the target host's transport proto ol knows whi h
pro ess to pass the message to in the appli ation layer.
This form of multiplexing at the sour e and
ea h layer of the proto ol sta k.
2.6

demultiplexing

at the target happens at

Qui k Test

Just to make sure you're still awake ....


Review Question:

layer?

What's the di eren e between the transport layer and the network

The network layer provides ommuni ation between two hosts. The transport
layer provides ommuni ation between two pro esses.
Answer:

Re all the Internet Proto ol sta k. Re all that ea h layer relies on the servi es of the layer
below it. Re all how pa kets are en apsulated with header information for ea h layer, and
later those headers are stripped. As we go through this ourse, we will have a mu h better
understanding of what goes in the headers. Hint: Adding and stripping headers is one of

our favorite test questions.

Consider Figure 8 below showing the order of how layers are added and removed. Point:


When leaving a host/router/et ., we add headers.


15

When arriving at a host/router/et ., we strip headers.

Application

Application

TH M

Transport

Transport

TH M

NH TH M

Network

Network

NH TH M

Link

Link

Physical

Physical

LH NH TH M

PH LH NH TH M

LH NH TH M

PH LH NH TH M

Figure 8: Adding and stripping of headers.


Question:

What's the di eren e between a hub and bridge and a router?

Usually: Hubs only speak layer 1 { they are just a repeater of the signal. Bridges
only implement 2 layers. They don't speak IP. They don't know about IP addresses. Routers
implement 3 layers, as shown in Figure 9 below.

Answer:

Application

Application
TCP

TCP
Network

Data Link

Wires
Host

Data Link

Network

Network

Data Link

Data Link

Wires

Wires

Wires

Bridge

Router

Host

Figure 9: Hosts, routers and bridges ea h ontain a di erent set of layers.

16

S-ar putea să vă placă și