iLab TCP / UDP Florian Wohlfart wohlfart@in.tum.de Lehrstuhl fr - - PowerPoint PPT Presentation

ilab
SMART_READER_LITE
LIVE PREVIEW

iLab TCP / UDP Florian Wohlfart wohlfart@in.tum.de Lehrstuhl fr - - PowerPoint PPT Presentation

iLab TCP / UDP Florian Wohlfart wohlfart@in.tum.de Lehrstuhl fr Netzarchitekturen und Netzdienste Fakultt fr Informatik Technische Universitt Mnchen Lab 4 14ws 1 Outline Transport Layer UDP TCP MTCP / SCTP 2 Outline


slide-1
SLIDE 1

iLab

TCP / UDP Florian Wohlfart wohlfart@in.tum.de

Lehrstuhl für Netzarchitekturen und Netzdienste Fakultät für Informatik Technische Universität München

Lab 4 – 14ws

1

slide-2
SLIDE 2

Outline

Transport Layer UDP TCP MTCP / SCTP

2

slide-3
SLIDE 3

Outline

Transport Layer UDP TCP MTCP / SCTP

3

slide-4
SLIDE 4

Recap: Transport Layer

wireless LAN app 1 app 2 TCP/UDP IP app 1 app 2 TCP/UDP IP Ethernet driver WLAN driver IP Ethernet driver WLAN driver

application protocol application protocol transport protocol IP protocol IP protocol Ethernet protocol WLAN protocol

app 1 app 1 Ethernet router

4

slide-5
SLIDE 5

Transport Layer

Purposes

◮ application addressing ◮ reliable data transfer (optional) ◮ adjustment of transmission rate (optional) 5

slide-6
SLIDE 6

Ports

transport layer multiplexing / demultiplexing

Ports

◮ 16bit number (0..65535) ◮ used for adressing applications on a host

Well-known port numbers

◮ HTTP/HTTPS: TCP port 80/443 ◮ FTP: TCP port 20/21 ◮ SSH: TCP port 22 ◮ DNS: UDP and TCP port 53

see: http://www.iana.org/assignments/port-numbers

6

slide-7
SLIDE 7

Transport Protocol Implementations

User Datagram Protocol (UDP)

◮ unreliable service ("best effort") ◮ lightweight

Transmission Control Protocol (TCP)

◮ reliable ◮ connection oriented ◮ flow control and congestion control

Other

◮ Multipath TCP (MTCP) ◮ Stream Control Transmission Protocol (SCTP) 7

slide-8
SLIDE 8

Outline

Transport Layer UDP TCP MTCP / SCTP

8

slide-9
SLIDE 9

User Datagram Protocol (UDP)

15 16 31

source port destination port length checksum standardized in 1980 (RFC 768)

Functions

◮ port multiplexing / demultiplexing ◮ error checking (optional over IPv4)

Example Applications

◮ DNS (port 53) ◮ RIP (port 520) ◮ media streaming / realtime communication 9

slide-10
SLIDE 10

UDP Summary

Pros

◮ simple and lightweight ◮ transaction-oriented ◮ stateless ◮ low latency ◮ supports unidirectional communication

Cons

◮ unreliable ◮ unlimited sending rate may harm the network/receiver 10

slide-11
SLIDE 11

Outline

Transport Layer UDP TCP MTCP / SCTP

11

slide-12
SLIDE 12

Transmission Control Protocol (TCP)

standardized in 1981 (RFC 793), numerous updates/extensions

Functions

◮ port multiplexing / demultiplexing ◮ error checking ◮ reliable and ordered delivery ◮ stream-orientation ◮ control of sending-rate (avoid overloading the network or the

receiver)

Applications

◮ most reliable protocols ◮ e.g. HTTP (port 80) 12

slide-13
SLIDE 13

Background: Reliable Data Transfer

How does the sender know whether a packet was successfully transferred?

◮ requires feedback from the receiver ◮ requires identification of packets

Sender Receiver segment X segment Y ACK segment X ACK segment Y

13

slide-14
SLIDE 14

Reliable Data Transfer in TCP

sequence number

◮ initial SN is exchanged during connection establishment ◮ increased with every byte of payload sent ◮ indicates the first data byte of a segment

Sender Receiver SEQ=5035 SEQ=6059 SEQ=12 ACK=6059 SEQ=12 ACK=7083

14

slide-15
SLIDE 15

Reliable Data Transfer in TCP

acknowledgement number

◮ gives the next sequence number that the receiver is expecting ◮ also acknowledges all smaller sequence numbers

Sender Receiver SEQ=5035 SEQ=6059 SEQ=12 ACK=6059 SEQ=12 ACK=7083

15

slide-16
SLIDE 16

Retransmission after Timeout

◮ timeout at the sender triggers retransmission

Sender Receiver SEQ=1 SEQ=2 ACK=2

timeout

SEQ=2

16

slide-17
SLIDE 17

Fast Retransmit

◮ sender retansmits segment after receiving three duplicate ACKs

Sender Receiver S E Q = 1 SEQ=2 S E Q = 3 S E Q = 4 S E Q = 5 A C K = 2 A C K = 2 A C K = 2 A C K = 2 3 duplicate ACKs SEQ=2

17

slide-18
SLIDE 18

TCP header

3 4 6 7 15 16 31

source port destination port sequence number acknowledgement number hdr len resvd

N S C W R E C E U R G A C K P S H R S T S Y N F I N

window size checksum urgent pointer [options]

◮ up to 40 Bytes of header options

e.g. Window Scale, Selective Acknowledgment (SACK)

◮ header length: 20 – 60 Bytes 18

slide-19
SLIDE 19

Connection Establishment

3-way-handshake

◮ establish initial sequence number and window size ◮ negotiate options

Client Server [ S Y N ] S E Q = 7 [ S Y N , A C K ] S E Q = 1 3 A C K = 8 [ A C K ] S E Q = 8 A C K = 1 4

19

slide-20
SLIDE 20

Connection Establishment

3-way-handshake

◮ establish initial sequence number and window size ◮ negotiate options ◮ vulnerable to SYN-flood attacks → SYN cookies, TCPCT

Client Server [ S Y N ] S E Q = 7 [ S Y N , A C K ] S E Q = 1 3 A C K = 8 [ A C K ] S E Q = 8 A C K = 1 4

19

slide-21
SLIDE 21

Connection Teardown

4-way-handshake

◮ each side needs to terminate the connection

→ half-open connections possible

◮ initiator waits for a timeout before closing the connection

Initiator Reveiver [ F I N ] [ A C K ] [ F I N ] [ A C K ]

timeout

20

slide-22
SLIDE 22

Limiting the Sending-rate

Sending Window

◮ specifies the amount of data that the sender is allowed to send

after the last acknowledged segment

◮ is equal to the number of bytes that can be in transit ◮ sending_window = min(receive_window, cwnd)

Flow Control

◮ prohibits overloading the receiver ◮ receiver announces the current size of the receive_window in

the TCP header

◮ limited by the buffer size at the receiver 21

slide-23
SLIDE 23

Background: Network Congestion

Jacobson, Van. "Congestion avoidance and control." ACM SIGCOMM Computer Communication Review, 1988.

22

slide-24
SLIDE 24

Background: Network Congestion

◮ segments get lost due to full buffers in routers ◮ retransmissions even amplify a congestion

Jacobson, Van. "Congestion avoidance and control." ACM SIGCOMM Computer Communication Review, 1988.

22

slide-25
SLIDE 25

Background: Network Congestion

◮ segments get lost due to full buffers in routers ◮ retransmissions even amplify a congestion ◮ self-clocking creates an equilibrium at the max. sending-rate:

Jacobson, Van. "Congestion avoidance and control." ACM SIGCOMM Computer Communication Review, 1988.

22

slide-26
SLIDE 26

Congestion Control

Principles

◮ basic assumption: packet loss is only caused by congestion ◮ end-host driven: no support from the network necessary

Two phases

◮ Slow Start starts a connection: gradually increase the amount

  • f data in-transit until reaching the equilibrium

◮ Congestion Avoidance tries to keep the equilibrium state and

react to changes on the link

State

◮ current size of the congestion window (cwnd) ◮ slow start threshold (ssthresh) defines transition between

phases

23

slide-27
SLIDE 27

Congestion Control (cont.)

MSS = maximum segment size (ususally 1460 Byte)

Slow Start Phase

◮ initialization: cwnd = 1MSS, ssthresh ◮ when receiving an ACK: cwnd = cwnd + 1MSS

Congestion Avoidance Phase

◮ when receiving an ACK: increase cwnd using a cubic function

Packet Loss

◮ timeout: assumption: the network is congested

→ go to slow start, cwnd = 1MSS, ssthresh = 0.8 ∗ last_cwnd

◮ 3 duplicate ACKs: assumption: only a segment was lost

→ cwnd = ssthresh + 3MSS

24

slide-28
SLIDE 28

TCP CUBIC

25

slide-29
SLIDE 29

TCP Options

Window Scaling

◮ window scaling allows to increase the window size up to 4GB ◮ default window size max. 65 KB (16bit field) ◮ Example: 16MBit/s, 150ms RTT, bandwidth-delay product:

16MBit/s ∗ 0.15s = 2, 400Kbit = 300KB

◮ problem remains: sequence numbers (32bit) still limit the

amount of unacknowledged data

Selective Acknowledgements (SACK)

◮ allow the receiver to acknowledge ranges of segments ◮ avoid unnecessary retransmissions compared to cumulative

ACKs

26

slide-30
SLIDE 30

TCP Summary

Pros

◮ reliable ◮ stream-oriented ◮ sending-rate limitation

Cons

◮ complex and heavyweight ◮ state can be exploited ◮ packet loss in wireless networks interferes with congestion

control

27

slide-31
SLIDE 31

Outline

Transport Layer UDP TCP MTCP / SCTP

28

slide-32
SLIDE 32

Other Transport Layer Protocols

Multipath TCP (MTCP)

◮ idea: a TCP connection can use paths ◮ goal: maximize resource usage and increase redundancy ◮ compatible with standard TCP

Stream Control Transmission Protocol (SCTP)

◮ TCP/UDP hybrid: reliable, optional ordering, message-oriented ◮ other features: multihoming, 4-way-handshake, etc. ◮ problem: lack of support in middleboxes (firewalls, NATs, etc.) 29