42
Networked & Distributed Systems TCP/IP Transport Layer Protocols UDP and TCP University of Glamorgan

Networked & Distributed Systems

Embed Size (px)

DESCRIPTION

University of Glamorgan. Networked & Distributed Systems. TCP/IP Transport Layer Protocols UDP and TCP. What do I cover?. what is left from TCP/IP Protocols: Transport Layer Protocols UDP TCP in more details Upper layer protocols (RARP), BOOTP, DHCP DNS Application Layer Protocols - PowerPoint PPT Presentation

Citation preview

Page 1: Networked & Distributed Systems

Networked & Distributed Systems

TCP/IP Transport Layer Protocols

UDP and TCP

University of Glamorgan

Page 2: Networked & Distributed Systems

What do I cover?

what is left from TCP/IP Protocols: Transport Layer Protocols

UDP TCP in more details

Upper layer protocols (RARP), BOOTP, DHCP DNS

Application Layer Protocols Telnet, FTP (TFTP), SMTP (POP3)

Page 3: Networked & Distributed Systems

Transport Layer Protocols

TCP and UDP

.....

Internet

Transport Layer

IP

UDP TCP RTP

Page 4: Networked & Distributed Systems

Transport Layer Protocols 2 main protocols TCP & UDP TCP – transmission control protocol

Connection oriented Reliable –sequence of numbered segments &

acknowledgments with any required re-transmissions

Flow control – sliding windows UDP – user datagram protocol

Connectionless Unreliable delivery of single segments

(datagrams) Errors detected but not corrected (No acks)

Page 5: Networked & Distributed Systems

TCP/UDP analogies TCP as a telephone call

Make a connection – ring number– Verifies connectivity

Use connection – communicate– Reliability “can you repeat that please?”– Flow control – normal human courtesy

Close connection – receiver down UDP as a letter

Write it, address it, post it, hope it gets there

Page 6: Networked & Distributed Systems

TCP vs UDP Relative merits TCP

Reliable High network overheads Complex and large software

UDP Unreliable (may not be a problem) Low network overheads Simple and small software

Page 7: Networked & Distributed Systems

When to use UDP

Use TCP unless there is a reason for UDP

Possible reasons to use UDP When the network efficiency is needed

(SNMP) When the sw simplicity is needed

(Bootstrap loading) When the reliability of TCP is counter-

productive (Stream audio/video)

Page 8: Networked & Distributed Systems

User Datagram Protocol (UDP)

UDP and the TCP/IP layered model UDP message format UDP and encapsulation UDP checksum

Page 9: Networked & Distributed Systems

UDP And The TCP/IP Layered Model

Network Interface

Internet

Transport

Application

Conceptual Layer

HardwareNetwork-Specific Frames

IP Datagrams

Transport Protocol Packets

Messages or Streams

Objects PassedBetween Layers

UDP belongshere

Page 10: Networked & Distributed Systems

Multiplexing and Demultiplexing –1

IP Module

UDP TCP Other Protocols

Interface 1 Interface 2 Interface 3

Transport

Network Interface

Page 11: Networked & Distributed Systems

Multiplexing and Demultiplexing –2

Demultiplexing based onPort Number

Port #1 Port #2 Port #65535

UDP DatagramArrives

......

Page 12: Networked & Distributed Systems

How Do We Allocate Port Numbers?

Well known port numbers Dynamic binding

Page 13: Networked & Distributed Systems

Port numbers

0 to 255 public port numbers 256 to 1023 assigned to

companies for their own marketable

apps 1024+ unregulated

Page 14: Networked & Distributed Systems

Examples of public ports

Page 15: Networked & Distributed Systems

UDP Message Format

UDPHeader

UDPData Area

UDP Source Port UDP Destination Port

UDP Message Length UDP Checksum

Page 16: Networked & Distributed Systems

UDP and Encapsulation

IPHeader

IPData Area

FrameHeader

FrameData Area

UDPHeader

UDPData Area

Page 17: Networked & Distributed Systems

UDP Checksum Optional checksum calculated on

UDP datagram UDP pseudo-header

Does this violate layering?

Source IP Address

Destination IP Address

Zero UDP Length Protocol

Page 18: Networked & Distributed Systems

UDP Checksum

Sent as IP Data

Compute Checksum on all this

Pseudo Header UDP DataUDP Header

Not Sent

Page 19: Networked & Distributed Systems

Differences between TCP & UDP

Feature UDP TCP

Analogy Letter Post Phone Call

Connection Phase None Yes

Messages Individual, unrelated

Sequence

Lost Message User has to deal with loss

Protocol tries to recover

Message Order Maintained?

No Yes

Disconnection Phase

No Yes

Duplicate Messages Maybe No

Complexity Low High

Page 20: Networked & Distributed Systems

Properties of a Reliable Delivery Service

Stream Orientation – Application just transfers a stream of bytes

Virtual Circuit Connection – Is TCP VC? Buffered Transfer – TCP decides what size

TCP messages are, not user Unstructured Stream – There is no

structure in the stream of bytes as far as TCP is concerned

Full Duplex Connection – Can transfer data in both directions simultaneously and independently

Page 21: Networked & Distributed Systems

Positive Acknowledgement A Simple Example

A BPacket (1)

ACK(1) Process Packet (1)

Packet (2)

ACK(2) Process Packet (2)

Page 22: Networked & Distributed Systems

Positive Acknowledgement Packet Doesn’t Arrive

A BPacket (1)

Packet (1)

ACK(1) Process Packet (1)

Timer Expires

Stop Timer

Start Timer

Start Timer

Page 23: Networked & Distributed Systems

Positive Acknowledgement ACK Doesn’t Arrive

A BPacket (1)

Packet (1)

ACK(1)

Process Packet (1)

Timer Expires

Stop Timer

Start Timer

Start Timer

Discard Packet (1)

ACK(1)

Page 24: Networked & Distributed Systems

Round Trip Time (RTT)

A B

Packet(1)

Process Packet(1) Round Trip Time ACK(1)

Page 25: Networked & Distributed Systems

Round Trip Time (RTT)Estimate too low

A B Packet(1)

Process Packet(1)

Estimated Round Trip Time

ACK(1) Packet(1)

Page 26: Networked & Distributed Systems

Round Trip Time (RTT)Estimate too high

A B Packet(1)

Estimated Round Trip Time

Packet(1)

Page 27: Networked & Distributed Systems

Sending Multiple Packets Receiver may not be able to process

packets as fast as they arrive In fact ACK’s serve at least 3 different

purposes Recovery from lost packets Limit the rate at which sender can send packets Control congestion in the network

Compromise solution is required: The Sliding Window

Page 28: Networked & Distributed Systems

Sliding Windows – Example

Given a window size = 6 packets A has sent packets 1 to 7 A has received ACK’s 1 to 4

1

Window Size = 6

2 3 4 5

6 7 8 9 10 11 12 13 ...

Sent & Acked

Sent not Acked

Could be sent

Can not be sent yet

Page 29: Networked & Distributed Systems

Sliding Windows ACK Received

A receives ACK 5 and the window slides to the right

1

Window Size = 6

2 3 4 5 6 7 8 9 10 11 12 13 ...

Sent & Acked

Sent not

Acked

Could be sent

Can not be sent

Page 30: Networked & Distributed Systems

Sliding Windows Packet 8 sent

A sends Packet 8 and the window remain unchanged

1

Window Size = 6

2 3 4 5 6 7 8 9 10 11 12 13 ...

Sent & Acked

Sent not

Acked Could be

sent Can not be sent

Page 31: Networked & Distributed Systems

Sliding Windows Packet 9 sent

A sends Packet 9 and the window remain unchanged

1

Window Size = 6

2 3 4 5 6 7 8 9 10 11 12 13 ...

Sent & Acked

Sent not

Acked

Could be sent

Can not be sent

Page 32: Networked & Distributed Systems

Sliding Windows Packet 6 ACK-ed

A receives ACK for Packet 6 and the window slides to the right

Window Size = 6

3

4 5 6 7 8 9 10 11 12 13 14 ...

Sent & Acked

Sent not

Acked Could be

sent Can not be sent

Page 33: Networked & Distributed Systems

Sliding Windows Packet 6 ACK-ed

A sends packets 10, 11, and 12. No ACK received no more packets can be sent.

Window Size = 6

3

4 5 6 7 8 9 10 11 12 13 14 ...

Sent & Acked

Sent not Acked Can not be sent

Page 34: Networked & Distributed Systems

Sliding WindowsWindow size?

Different protocols fix the window size in different ways Fixed by protocol specification Agreed when connection established Adjusted whilst connection in

progress(Demo is given later)

Page 35: Networked & Distributed Systems

Sliding Windows Missing ACK’s ?

With just one outstanding ACK it was easy. If A doesn’t get an ACK it sends the packet again

With several ACK’s outstanding it gets much more complicated

What does A do when it detects a missing ACK?

What does B do when it detects a missing packet?

Different protocols use different solutions

Page 36: Networked & Distributed Systems

Sliding Windows Missing ACK’s ?

There are two “extreme” positions When something goes missing A resends

every packet starting with the first unacknowledged packet.

This is called Go-Back-N.

When something goes missing A & B co-operate to just resend those packets B hasn’t received.

This is called Selective Retransmission.

Page 37: Networked & Distributed Systems

TCP Encapsulation

IP Header

IP Data Area

TCP Header

TCP Data Area

Page 38: Networked & Distributed Systems

TCP Header

Page 39: Networked & Distributed Systems

TCP Header Fields Source Port : Port number of sender of

segment Destination Port : Port number of intended

recipient Sequence Number : TCP uses byte numbers not

packet numbers Acknowledgement Number : Number of the byte the

sender of this segment expects next Window : The size of the sliding window in bytes Checksum : Just like the UDP checksum Control bits : Special purpose bits Data : User data

Page 40: Networked & Distributed Systems

Usage of SEQ-ACK-WIN Fields Example

Page 41: Networked & Distributed Systems

TCP is Complicated

RFC 793 is over 90 pages long – but doesn’t cover everything

There are a number of additional RFC’s covering various aspects of TCP

There are a number of “reference implementations” which have performance enhancing features

There is no single TCP specification

Page 42: Networked & Distributed Systems

Next : TCP continues

Establishing A TCP Connection Timeouts and Retransmission Congestion Push Silly Window Syndrome Closing A TCP Connection