Tải bản đầy đủ (.ppt) (113 trang)

Computer Networking: A Top Down Approach Featuring the Internet - Chapter 3 Transport Layer ppt

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.04 MB, 113 trang )

Chapter 3
Transport Layer

A note on the use of these ppt slides:
We’re making these slides freely available to all (faculty, students, readers).
They’re in PowerPoint form so you can add, modify, and delete slides
(including this one) and slide content to suit your needs. They obviously
represent a lot of work on our part. In return for use, we only ask the
following:
 If you use these slides (e.g., in a class) in substantially unaltered form,
that you mention their source (after all, we’d like people to use our book!)
 If you post any slides in substantially unaltered form on a www site, that
you note that they are adapted from (or perhaps identical to) our slides, and
note our copyright of this material.
Thanks and enjoy! JFK/KWR
All material copyright 1996-2006
J.F Kurose and K.W. Ross, All Rights Reserved

Computer Networking:
A Top Down Approach
Featuring the Internet,
3rd edition.
Jim Kurose, Keith Ross
Addison-Wesley, July
2004.

Transport Layer 3-1


Chapter 3: Transport Layer
Our goals:


Ì understand
principles
behind transport
layer services:
r

r
r
r

multiplexing/demultipl
exing
reliable data transfer
flow control
congestion control

Ì learn about

transport layer
protocols in the
Internet:
r

r

r

UDP: connectionless
transport
TCP: connection-oriented

transport
TCP congestion control

Transport Layer 3-2


Chapter 3 outline
Ì 3.1 Transport-

layer services
Ì 3.2 Multiplexing
and
demultiplexing
Ì 3.3
Connectionless
transport: UDP
Ì 3.4 Principles of
reliable data
transfer

Ì 3.5 Connection-

oriented transport:
TCP
r
r
r
r

segment structure

reliable data transfer
flow control
connection management

Ì 3.6 Principles of

congestion control
Ì 3.7 TCP congestion
control
Transport Layer 3-3


Transport services and protocols
Ì provide logical

network
data link
physical

network
data link
physical

ca
gi
lo

le

nd

-e
nd

network
data link
physical

a
tr

network
data link
physical

network
data link
physical

rt
po
ns

communication between
app processes running on
different hosts
Ì transport protocols run
in end systems
r send side: breaks app
messages into segments,
passes to network layer

r rcv side: reassembles
segments into messages,
passes to app layer
Ì more than one transport
protocol available to
apps
r Internet: TCP and UDP

application
transport
network
data link
physical

application
transport
network
data link
physical

Transport Layer 3-4


Transport vs. network layer
Ì network layer:

logical
communication
between hosts
Ì transport layer:

logical
communication
between processes
r

relies on, enhances,
network layer services

Household analogy:
12 kids sending
letters to 12 kids
Ì processes = kids
Ì app messages =
letters in envelopes
Ì hosts = houses
Ì transport protocol =
Ann and Bill
Ì network-layer
protocol = postal
service

Transport Layer 3-5


Internet transport-layer protocols
Ì reliable, in-order

delivery (TCP)
r


no-frills extension of
“best-effort” IP

Ì services not

network
data link
physical

network
data link
physical

rt
po
ns

r

network
data link
physical

a
tr

unordered delivery:
UDP

nd

-e
nd

Ì unreliable,

network
data link
physical

le

r

congestion control
flow control
connection setup

network
data link
physical

ca
gi
lo

r

application
transport
network

data link
physical

application
transport
network
data link
physical

available:
r
r

delay guarantees
bandwidth guarantees

Transport Layer 3-6


Chapter 3 outline
Ì 3.1 Transport-

layer services
Ì 3.2 Multiplexing
and
demultiplexing
Ì 3.3
Connectionless
transport: UDP
Ì 3.4 Principles of

reliable data
transfer

Ì 3.5 Connection-

oriented transport:
TCP
r
r
r
r

segment structure
reliable data transfer
flow control
connection management

Ì 3.6 Principles of

congestion control
Ì 3.7 TCP congestion
control
Transport Layer 3-7


Multiplexing/demultiplexing
Multiplexing at send host:
gathering data from multiple
sockets, enveloping data with
header (later used for

demultiplexing)

Demultiplexing at rcv host:
delivering received segments
to correct socket
= socket
application
transport
network
link

= process
P3

P1
P1

application
transport
network

P2

P4

application
transport
network
link


link

physical

host 1

physical

host 2

physical

host 3

Transport Layer 3-8


How demultiplexing works
Ì host receives IP datagrams

each datagram has source IP
address, destination IP address
r each datagram carries 1
transport-layer segment
r each segment has source,
destination port number
Ì host uses IP addresses & port
numbers to direct segment to
appropriate socket
r


32 bits
source port #

dest port #

other header fields

application
data
(message)
TCP/UDP segment format

Transport Layer 3-9


Connectionless demultiplexing
Ì Create sockets with

port numbers:
DatagramSocket mySocket1 = new
DatagramSocket(12534);
DatagramSocket mySocket2 = new
DatagramSocket(12535);

Ì UDP socket identified

by
(dest


two-tuple:

IP address, dest port
number)

Ì When host receives

UDP segment:
r

r

checks destination port
number in segment
directs UDP segment to
socket with that port
number

Ì IP datagrams with

different source IP
addresses and/or
source port numbers
directed to same
socket

Transport Layer 3-


Connectionless demux (cont)

DatagramSocket serverSocket = new DatagramSocket(6428);
P2

SP: 6428
DP: 9157

client
IP: A

P1
P1

P3

SP: 9157
DP: 6428

SP: 6428
DP: 5775

server
IP: C

SP: 5775
DP: 6428

Client
IP:B

SP provides “return address”


Transport Layer 3-


Connection-oriented demux
Ì TCP socket

identified by 4tuple:
r
r
r
r

source IP address
source port number
dest IP address
dest port number

Ì recv host uses all

four values to
direct segment to
appropriate socket

Ì Server host may

support many
simultaneous TCP
sockets:
r


each socket identified by
its own 4-tuple

Ì Web servers have

different sockets
for each connecting
client
r

non-persistent HTTP will
have different socket for
each request

Transport Layer 3-


Connection-oriented demux
(cont)
P1

P4

P5

P2

P6


P1
P3

SP: 5775
DP: 80
S-IP: B
D-IP:C

client
IP: A

SP: 9157
DP: 80
S-IP: A
D-IP:C

server
IP: C

SP: 9157
DP: 80
S-IP: B
D-IP:C

Client
IP:B

Transport Layer 3-



Connection-oriented demux:
Threaded Web Server
P1

P2

P4

P1
P3

SP: 5775
DP: 80
S-IP: B
D-IP:C

client
IP: A

SP: 9157
DP: 80
S-IP: A
D-IP:C

server
IP: C

SP: 9157
DP: 80
S-IP: B

D-IP:C

Client
IP:B

Transport Layer 3-


Chapter 3 outline
Ì 3.1 Transport-

layer services
Ì 3.2 Multiplexing
and
demultiplexing
Ì 3.3
Connectionless
transport: UDP
Ì 3.4 Principles of
reliable data
transfer

Ì 3.5 Connection-

oriented transport:
TCP
r
r
r
r


segment structure
reliable data transfer
flow control
connection management

Ì 3.6 Principles of

congestion control
Ì 3.7 TCP congestion
control
Transport Layer 3-


UDP: User Datagram Protocol

[RFC 768]

Ì “no frills,” “bare

bones” Internet
transport protocol
Ì “best effort” service,
UDP segments may be:
r lost
r delivered out of order to
app
Ì connectionless:
r no handshaking between
UDP sender, receiver

r each UDP segment
handled independently of
others

Why is there a UDP?
Ì no connection

establishment (which
can add delay)
Ì simple: no connection
state at sender,
receiver
Ì small segment header
Ì no congestion control:
UDP can blast away as
fast as desired

Transport Layer 3-


UDP: more
Ì often used for

streaming multimedia
apps
Length, in
r loss tolerant
bytes of UDP
r rate sensitive
segment,


32 bits
source port #

dest port #

length

checksum

including

Ì other UDP uses
header
r DNS
r SNMP
Ì reliable transfer over
UDP: add reliability
at application layer
r application-specific
error recovery!

Application
data
(message)
UDP segment format

Transport Layer 3-



UDP checksum
Goal: detect “errors” (e.g., flipped bits) in transmitted
segment
Sender:

Receiver:

Ì treat segment

Ì compute checksum of

contents as sequence
of 16-bit integers
Ì checksum: addition
(1’s complement sum)
of segment contents
Ì sender puts checksum
value into UDP
checksum field

received segment
Ì check if computed
checksum equals checksum
field value:
r NO - error detected
r YES - no error detected. But
maybe errors nonetheless?
More later ….

Transport Layer 3-



Internet Checksum Example
Ì Note
r

When adding numbers, a carryout from the most
significant bit needs to be added to the result

Ì Example: add two 16-bit integers

1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
wraparound 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
sum 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0
checksum 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1

Transport Layer 3-


Chapter 3 outline
Ì 3.1 Transport-

layer services
Ì 3.2 Multiplexing
and
demultiplexing
Ì 3.3
Connectionless
transport: UDP

Ì 3.4 Principles of
reliable data
transfer

Ì 3.5 Connection-

oriented transport:
TCP
r
r
r
r

segment structure
reliable data transfer
flow control
connection management

Ì 3.6 Principles of

congestion control
Ì 3.7 TCP congestion
control
Transport Layer 3-


Principles of Reliable data transfer
Ì important in app., transport, link layers
Ì top-10 list of important networking topics!


Ì characteristics of unreliable channel will determine complexity of reliable

data transfer protocol (rdt)

Transport Layer 3-


Principles of Reliable data transfer
Ì important in app., transport, link layers
Ì top-10 list of important networking topics!

Ì characteristics of unreliable channel will determine complexity of reliable

data transfer protocol (rdt)

Transport Layer 3-


Principles of Reliable data transfer
Ì important in app., transport, link layers
Ì top-10 list of important networking topics!

Ì characteristics of unreliable channel will determine complexity of reliable

data transfer protocol (rdt)

Transport Layer 3-


Reliable data transfer: getting started

rdt_send(): called from above,
(e.g., by app.). Passed data to
deliver to receiver upper layer

send
side

udt_send(): called by rdt,
to transfer packet over
unreliable channel to receiver

deliver_data(): called by
rdt to deliver data to upper

receive
side

rdt_rcv(): called when packet
arrives on rcv-side of channel

Transport Layer 3-


Reliable data transfer: getting started
We’ll:
Ì incrementally develop sender, receiver
sides of reliable data transfer
protocol (rdt)
Ì consider only unidirectional data
transfer

r

but control info will flow on both directions!

Ì use finite state machines (FSM) transition
event causing state to
specify sender, receivertaken on state transition
actions
state: when in this
“state” next state
uniquely determined
by next event

state
1

event
actions

state
2

Transport Layer 3-


×