ch 1 بروتوكول
ch 1 بروتوكول
Grading Method
Course work 20 %
Midterm Exam 30 %
Final Exam 50 %
References:
• Cisco CCENT-CCNA ICND1 100-101 Official Cert Guide
• Computer networking a top-down approach 6th edition
Chapter 1
Transport Layer
1
Chapter 1: Transport Layer
our goals:
understand learn about Internet
principles behind transport layer protocols:
transport layer UDP: connectionless
services: transport
multiplexing, TCP: connection-oriented
demultiplexing reliable transport
reliable data transfer TCP congestion control
flow control
congestion control
1-1
1-2
2
1-3
network
data link
physical
effort) physical
network
data link
transport
network
physical data link
delay guarantees
bandwidth guarantees
1-5
3
TCP vs UDP
1-6
1-7
4
Port Number Groups
The Internet Assigned Numbers Authority (IANA) is the standards body
responsible for assigning various addressing standards, including port numbers.
There are different types of port numbers:
1-8
1-9
10
5
Multiplexing/demultiplexing
multiplexing at sender:
handle data from multiple demultiplexing at receiver:
sockets, add transport header use header info to deliver
(later used for demultiplexing) received segments to correct
socket
application
1-10
11
Multiplexing/ Demultiplexing
1-11
12
6
Connectionless demux: example
DatagramSocket
DatagramSocket serverSocket = new
DatagramSocket DatagramSocket
mySocket2 = new mySocket1 = new
DatagramSocket (6428); DatagramSocket
(9157); application (5775);
application application
P1
P3 P4
transport
transport transport
network
network link network
link physical link
physical physical
13
Connection-oriented demux
TCP socket identified server host may support
by 4-tuple: many simultaneous TCP
source IP address sockets:
source port number each socket identified by
dest IP address its own 4-tuple
dest port number web servers have
demux: receiver uses different sockets for
all four values to direct each connecting client
segment to appropriate non-persistent HTTP will
socket have different socket for
each request
1-13
14
7
Connection-oriented demux: example
application
application P4 P5 P6 application
P3 P2 P3
transport
transport transport
network
network link network
link physical link
physical server: IP physical
address B
15
1-15
16
8
UDP: User Datagram Protocol [RFC 768]
“no frills,” “bare bones” UDP use:
Internet transport streaming multimedia
protocol apps (loss tolerant, rate
“best effort” service, sensitive)
UDP segments may be: DNS
lost SNMP
delivered out-of-order reliable transfer over
to app
UDP:
connectionless:
add reliability at
no handshaking application layer
between UDP sender,
receiver application-specific error
recovery!
each UDP segment
handled independently
of others
1-16
17
length checksum
why is there a UDP?
no connection
application establishment (which can
data add delay)
(payload) simple: no connection
state at sender, receiver
small header size
UDP segment format no congestion control:
UDP can blast away as
fast as desired
1-17
18
9
UDP checksum
Goal: detect “errors” (e.g., flipped bits) in transmitted
segment
sender: receiver:
treat segment contents, compute checksum of
including header fields, received segment
as sequence of 16-bit check if computed
integers
checksum equals checksum
checksum: addition field value:
(one’s complement
sum) of segment NO - error detected
contents YES - no error detected.
sender puts checksum But maybe errors
value into UDP nonetheless? More later
checksum field ….
1-18
19
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
1-19
20
10
TCP: Overview RFCs: 793,1122,1323, 2018, 2581
21
1-21
22
11
TCP seq. numbers, ACKs
outgoing segment from sender
sequence numbers: source port # dest port #
sequence number
byte stream “number” of acknowledgement number
1-22
23
User
types
‘C’ Seq=42, ACK=79, data = ‘C’
host ACKs
receipt of
‘C’, echoes
Seq=79, ACK=43, data = ‘C’ back ‘C’
host ACKs
receipt
of echoed
‘C’ Seq=43, ACK=80
1-23
24
12
TCP round trip time, timeout
Q: how to set TCP Q: how to estimate RTT?
timeout value? SampleRTT: measured
time from segment
longer than RTT transmission until ACK
but RTT varies receipt
too short: premature ignore retransmissions
timeout, unnecessary SampleRTT will vary, want
retransmissions estimated RTT “smoother”
average several recent
too long: slow reaction measurements, not just
to segment loss current SampleRTT
1-24
25
350
300
250
RTT (milliseconds)
200
sampleRTT
150
EstimatedRTT
100
1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106
time (seconnds)
time (seconds) 1-25
SampleRTT Estimated RTT
26
13
TCP round trip time, timeout
timeout interval: EstimatedRTT plus “safety margin”
large variation in EstimatedRTT -> larger safety margin
estimate SampleRTT deviation from EstimatedRTT:
DevRTT = (1-)*DevRTT +
*|SampleRTT-EstimatedRTT|
(typically, = 0.25)
1-26
27
1-27
28
14
TCP sender events:
data rcvd from app: timeout:
create segment with retransmit segment
seq # that caused timeout
seq # is byte-stream restart timer
number of first data ack rcvd:
byte in segment if ack acknowledges
start timer if not previously unacked
already running segments
think of timer as for update what is known
oldest unacked to be ACKed
segment
start timer if there are
expiration interval: still unacked segments
TimeOutInterval
1-28
29
SendBase=92
Seq=92, 8 bytes of data Seq=92, 8 bytes of data
timeout
ACK=100
X
ACK=100
ACK=120
SendBase=120
30
15
TCP: retransmission scenarios
Host A Host B
X
ACK=120
cumulative ACK
1-30
31
1-31
32
16
TCP fast retransmit
Host A Host B
timeout ACK=100
ACK=100
ACK=100
ACK=100
Seq=100, 20 bytes of data
33
IP
flow control code
receiver controls sender, so
sender won’t overflow
receiver’s buffer by transmitting from sender
too much, too fast
receiver protocol stack
1-33
34
17
TCP flow control
receiver “advertises” free
buffer space by including to application process
rwnd value in TCP header
of receiver-to-sender
segments RcvBuffer buffered data
RcvBuffer size set via
socket options (typical default rwnd free buffer space
is 4096 bytes)
many operating systems
autoadjust RcvBuffer TCP segment payloads
sender limits amount of
unacked (“in-flight”) data to receiver-side buffering
receiver’s rwnd value
guarantees receive buffer
will not overflow
1-34
35
Connection Management
before exchanging data, sender/receiver “handshake”:
agree to establish connection (each knowing the other willing
to establish connection)
agree on connection parameters
application application
network network
36
18
TCP 3-way handshake
1-36
37
closed
Socket connectionSocket =
welcomeSocket.accept();
L Socket clientSocket =
SYN(x) newSocket("hostname","port
number");
SYNACK(seq=y,ACKnum=x+1)
create new socket for SYN(seq=x)
communication back to client listen
SYN SYN
rcvd sent
SYNACK(seq=y,ACKnum=x+1)
ESTAB ACK(ACKnum=y+1)
ACK(ACKnum=y+1)
L
1-37
38
19
TCP: closing a connection
client, server each close their side of connection
send TCP segment with FIN bit = 1
respond to received FIN with ACK
on receiving FIN, ACK can be combined with own FIN
simultaneous FIN exchanges can be handled
1-38
39
LAST_ACK
FINbit=1, seq=y
TIMED_WAIT can no longer
send data
ACKbit=1; ACKnum=y+1
timed wait
for 2*max CLOSED
segment lifetime
CLOSED
1-39
40
20