Вы находитесь на странице: 1из 19

CDS Wt

Chapter 3.4

Layer 4

Transport Layer
yer
3.4. Transport Lay

Think about…

• How do MAC addresses differ from that of the


Wt

network layer?
CDS

• What is flat and what is hierarchical addressing?


• Who defines the IP Address of a device?
• What is the decimal and binary range of the first
octet of class B IP addresses?
• Which octet(s) represent the network portion of a
class C IP address?
yer

• Which octet(s) represent the host portion of a class


3.4. Transport Lay

A IP address?
• How many Host addresses can be used in a Class C
Network?
• I it possible to have different Layer 3 Protocols
2 using the same Layer 2 System?

1
Wt
Content

• Introduction Layer 4
CDS

• TCP Protocol

• UDP Protocol

• Sockets
yer
3.4. Transport Lay

Protocol aspect of the OSI-Model


Wt

Endsystem 1 Endsystem 2
Layer 7 protocol
CDS

7 Layer 6 protocol 7
6 6
Transit-
5 system 5
4 4
3 3 3
2 2 2
1 1 1
yer
3.4. Transport Lay

transmission-system

Protocols are defined between the same layers of two systems.


They define rules and formats of message/information exchange.

2
TCP/IP Referencemodel
Wt

Process / Application
CDS

Application
FTP

Port
Transport
TCP UDP

IP Internet
IP-Address
yer
3.4. Transport Lay

Network-
N t k
Ethernet interface
MAC-Address
Hardware

Ethernet cable Transceiver

Why we need a transport layer?

• Layer 1 allows bit streams to be created and


Wt

to travel.
CDS

• Layer 2 packages those data packets into


frames to be converted to bit streams and
makes data-link delivery possible.
• Layer 3 packages data from upper layers in
packets and makes routing and network
delivery possible.
yer
3.4. Transport Lay

But they made no provision


for assuring our data reliably
travels end-to-end across
the often vast network path.
6

3
Wt
Purpose of the transport layer

• Transport and regulate the flow of


CDS

information from source to destination,


reliably and accurately
accurately.
• The end-to-end control:
– Sliding windows.
– Sequencing numbers.
– Acknowledgments.
yer

– Segmentation.
Segmentation
3.4. Transport Lay

– Multiplexing.

TCP and UDP


CDS Wt yer
3.4. Transport Lay

• The TCP/IP protocol of the OSI model Layer 4


(transport layer) has two protocols - TCP and UDP.

4
CDS Wt yer
3.4. Transport Lay
TCP/IP

Port
CDS Wt yer
3.4. Transport Lay

• Both TCP and UDP use port (or socket) numbers to


pass information to the upper layers.
10

5
Wt
Range of ports

• 2 bytes: 0 – 65535.
CDS

– Numbers below 255 : for public applications.


– Numbers from 255 - 1023 : assigned to companies for
marketable applications.
– Numbers above 1023 : are unregulated.

• End systems use port numbers to select


proper applications.
yer
3.4. Transport Lay

• Originating source port numbers are


dynamically assigned by the source host;
usually, it is a number larger than 1023.

11

Telnet port number


CDS Wt yer
3.4. Transport Lay

12

6
Wt
Content

• Introduction Layer 4
CDS

• TCP Protocol

• UDP Protocol

• Sockets
yer
3.4. Transport Lay

13

TCP
Wt

• TCP supplies a virtual circuit between end-


CDS

user applications.
pp These are its
characteristics:
– connection-oriented.
– reliable.
– divides outgoing messages into segments.
– reassembles messages at the destination station.
yer

– re
re-sends
sends anything not received.
received
3.4. Transport Lay

– reassembles messages from incoming segments.

14

7
CDS Wt yer
3.4. Transport Lay
TCP Header format

• Protocol that provides reliable


full-duplex data transmission.
15

TCP Header format: Port number


CDS Wt

• Source Port 16 bits.


• Destination Port 16 bits.
yer
3.4. Transport Lay

16

8
CDS Wt yer
TCP Header format: Sequence

• Sequence Number: 32 bits


3.4. Transport Lay

– The sequence number of the


first data octet in this segment
(except when SYN is present).
17

TCP Header format:


Acknowledgment
CDS Wt

• Acknowledgment Number: 32 bits


yer
3.4. Transport Lay

– This field contains the value of the


next sequence number the sender of
the segment is expecting to receive.

18

9
CDS Wt
TCP Header format: Code bits

• Control Bits: 8 bits


yer
3.4. Transport Lay

– ACK:
ACK A
Acknowledgment
k l d t field
fi ld significant
i ifi t
– RST: Reset the connection
– SYN: Synchronize sequence numbers
– FIN: No more data from sender
19

TCP Header format: Window


CDS Wt

• Window: 16 bits
yer
3.4. Transport Lay

– The number of data octets beginning


with the one indicated in the
acknowledgment field which the sender
of this segment is willing to accept.
20

10
CDS Wt yer
3.4. Transport Lay
TCP: Three way handshaking

21

TCP: Simple acknowledgment


CDS Wt yer
3.4. Transport Lay

22

11
CDS Wt yer
3.4. Transport Lay
TCP: Sliding acknowledgment

23

TCP: Sliding Acknowledgement


Wt

Principle
– Data-Packet includes Number of the first byte
CDS

– Acknowledgement: ACK –Flag and Number of the next expected databyte

Packet 1 Packet 2 Packet 3 Packet 4 Packet 5


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

S: Packet 1 (Seq.-No=0+1)
R: ACK, (Ack.-No=0+7)

S: Packet 2 (Seq.-No=0+7)
yer

R: ACK,
ACK (Ack
(Ack.-No=0+13)
-No=0+13)
3.4. Transport Lay

S: Packet 1 (Seq.-No=0+13)
R: ACK, (Ack.-No=0+19)

24

12
Wt
TCP: ACK and „sliding window“

Packet 1 Packet 2 Packet 3 Packet 4 Packet 5


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
CDS

S: Packet 1 (Seq.-Nr=0+1)
S: Packet 2 (Seq
S (Seq.-Nr=0+7)
Nr 0+7)
R: ACK, (Ack.-Nr=0+7)

Paket 1 Paket 2 Paket 3 Paket 4 Paket 5


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

S: Packet 3 (Seq.-Nr=0+13)
R: ACK, (Ack.-Nr=0+19)

Paket 1 Paket 2 Paket 3 Paket 4 Paket 5


yer

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
3.4. Transport Lay

S: Paket 4 (Seq.-Nr=0+19)
S: Packet 5 (Seq.-Nr=0+25)

Timeout ACK Paket 4: S: Packet 4 (Seq.-Nr=0+19)


R: ACK, (Ack.-Nr=0+31)
time

25

TCP: Sequence and


acknowledgment
CDS Wt yer
3.4. Transport Lay

26

13
Wt
TCP: disconnect

Process 1 Process 2

Send FIN,
CDS

sequence = n

Send ACK n+1 Receive FIN

Receive ACK
Inform Application

Send FIN, ACK n+1


Sequence m
yer
3.4. Transport Lay

Receive FIN

Send ACK m+1 Receive ACK

27

Content
Wt

• Introduction Layer 4
CDS

• TCP Protocol

• UDP Protocol

• Sockets
yer
3.4. Transport Lay

28

14
Wt
UDP

• UDP transports data unreliably between


CDS

hosts. Following are the characteristics:


– Connectionless.
– Unreliable.
– Transmit messages (called user datagrams).
– Provides no software checking for message delivery
(unreliable).
yer

– Does not reassemble incoming messages


messages.
3.4. Transport Lay

– Uses no acknowledgements.

29

UDP Header format


CDS Wt yer
3.4. Transport Lay

• UDP is a simple protocol that


exchanges datagrams, without
acknowledgments or guaranteed
30
delivery.

15
Wt
Review

• Transport layer regulates information flow to


CDS

ensure end-to-end connectivity between host


applications reliably and accurately.
• TCP and UDP port numbers.
• Three way handshaking and sliding
windows.
yer
3.4. Transport Lay

31

Content
Wt

• Introduction Layer 4
CDS

• TCP Protocol

• UDP Protocol

• Sockets
yer
3.4. Transport Lay

32

16
Wt
Ports and Sockets

• Port: 16 Bit , Process/Application


CDS

– well known p
ports: e.g..:
g FTP 20, 21
– ephemeral

• Sockets
– API: Application Programming Interface
– socket: { tcp, 193.44.234.3, 4711}
– connection
yer
3.4. Transport Lay

{TCP, source IP, source port, destination IP,


destination Port}

33

TCP- interfaces
Wt

OPEN (a/p) Process 2


Process 1
SEND
CDS

RECEIVE
STATUS
CLOSE
ABORT

.... port m ... .... port n ...


Timeout
Flags, Daten
TCP TCP
reliable
snd TCP connection
rcv
yer
3.4. Transport Lay

IP IP
unreliable
IP connection

34

17
Wt
TCP Connection states

ABORT

OPEN CLOSED disconnection ok


CDS

disconnect
connect
Flags
Flags snd
snd connected rcv
rcv
SEND,
„Three-Way“
RECEIVE,
Handshake
STATUS
ok
yer

Flags,Data
3.4. Transport Lay

Timeouts CLOSE
snd
rcv

connection = Socket pair


{TCP, source IP, source port} {TCP, destination IP, destination Port}

35

Connection states
ABORT
Wt

snd RST, delete TCB


CLOSED
OPEN (active)
OPEN (passive) Create TCB,
CDS

CLOSE
snd SYN
Create TCB delete TCB

rcv SYN
LISTEN SEND
snd SYN, ACK
snd SYN

SYN rec SYN


RCVD SYN rcv ACK of FIN
snd ACK
rcv ACK of SYN rcv SYN, ACK
SENT delete TCB
CLOSE
ESTAB snd ACK
snd FIN
Timeout=2MSL
CLOSE rcv FIN CLOSE
delete TCB FIN snd FIN
snd ACK
WAIT
yer

WAIT 1 CLOSE
CLOSING
3.4. Transport Lay

rcv FIN snd FIN


rcv ACK of FIN
snd ACK
rcv ACK of FIN LAST
FIN ACK
rcv FIN
WAIT 2
snd ACK TIME
WAIT

36

18
Wt
TCP: Header Format

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Source Port Destination Port


CDS

Sequence Number

Acknowledgment Number

Data U A P R S F
Reserved R C S S Y I Window
Offset G K H T N N

Checksum Urgent Pointer


yer

Options Padding
3.4. Transport Lay

data

37

TCP: Pseudo Header


Wt

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
CDS

Source Address

Destination Address

zero PTCL TCP Length

PTCL: Protokoll-Code
6: UDP
yer

7: TCP
3.4. Transport Lay

38

19

Вам также может понравиться