You are on page 1of 3

2/6/2015

TCP-UDP

TCP/UDP

Allow multiple application programs/processes execution on a host


device (having operating system) to transmit and receive datagram
independently.

Need of TCP and UDP ?


I t d ti UDP
Introduction
UDP Header
Introduction TCP
TCP Header
Comparison between TCP and UDP

Port numbers are used to distinguish different application data


streams of a host device.
device
Port number is a decimal equivalent of 16-bits
Static port number (Registered with IANA)
Dynamic port number (private or unregistered)

Using port numbers different data streams can be multiplexed and


de-multiplexed at transmitter and receiver sides respectively
OPM

OPM

TCP/UDP layering
Port1

App.
Transport

Port2

Port1
UDP

TCP

Demuxon
Portnumber
DemuxonIP
protocol

IP

Network

IP: Internet Protocol

Port2

A co
connection
ect o need:
eed:
Source: (IP address, port No.) and Destination: (IP address, port No.)
Require one port (PHY connection) on host to allow multiple
connections, since each connection will have different (host, port) at other
end.

Active open: application program requests OS to connect to an


(host, port).
Passive open : application program contacts OS & indicates that
it will accept incoming connection, OS assigns port and listens.
OPM

Unreliable connectionless datagram delivery service


Responsible for routing of data through intermediate networks and
computers

IP h d
IPheader:

0123

11
8901

4567

1111
2345

1111
6789

2222
0123

2222
4567

2233
8901

1:ICMP
6:TCP
17:UDP

OPM

UDP Datagram format


UDP (User Datagram Protocol)

16

Sourceport

Each UDP message contains source and destination port number,


delivers message to correct recipients.

31

UDPmessagelen

Checksum(optional)
Data

Less reliable (No ACK), delay prone, connectionless datagram


y
delivery.

S
Source/destination
/d ti ti port:
t portt numbers
b identify
id tif sending
di & receiving
i i processes
(programs or applications)
Port number & IP address allow any application in any computer on Internet to be uniquely
identified
Used to multiplex and demultiplex datagrams to processes at a host device.
Ports can be static or dynamic

Doesnt include acknowledge, order of messages, feedback to


control the rate of information flow between machines.

Static (< 1024 and some additional blocks, and registered port no.) assigned centrally, known as well
known ports
Dynamic (private port no., un registered, In range from 49152 to 65535)

UDP message may be lost, duplicate or arrive out of order.

UDP Message length: in bytes includes the UDP header and data
Checksum: of UDP header and Data (this field is optional)

Packet can arrive faster than the recipient can process them.
OPM

24
Destinationport

OPM

2/6/2015

TCP : Transmission Control Protocol

Datagram Transport

User Datagram Protocol (UDP)

Connection-Oriented, Reliable, Bit Stream Service

Three steps to set up TCP connection between source and destination devices
1. Set up connection (Application program to program negotiation: virtual
connection setup)
2. Transfer data
3. Close connection (removing virtual connection, releasing port No.)

A best-effort delivery, no guarantee, no ACK


Smaller overhead than TCP
Good for best-effort traffic like periodic updates
No long lived connection overhead on the endpoints

SNMP and DNS protocols use UDP


Data is guaranteed to arrive, and in the correct order without
duplications

Data channels of some multimedia protocols, e.g., H.323 also


uses UDP due to low header processing delay

Otherwise the connection will be dropped

Imposes significant overheads


OPM

OPM

TCP Header (cont.)

TCP Header (followed by data/ payload)

Source/destination port: port numbers identify sending & receiving


processes (programs or applications)
DestinationPort(16)

SourcePort(16)

Sequence Number: identifies position of packets/ segments in bit stream


SequenceNumber(32)

Acknowledgement (piggyback) : identifies the sequence number of


packet the sender of this packet/segment expects to receive next, refers
stream flowing opposite direction

Acknowledgementnumber(32)
Reserved(6)

HDR
Len(4)

U A
R C
G K

P
S
H

R S F
S Y I
T N N

WindowSize
(16)

Header length (Hlen): specifies the length of the segment header in 32


bit blocks/multiples. If there are no options, the Hlen = 5 (20 bytes)

UrgentPointer(16)

Checksum(16)

Reserved for future use, set to 0

Options(0ormorewords)
OPM

10

TCP Header (Cont.)

TCP header (cont.)


Code (flags): used to determine purpose contents in header

OPM

Window: Advertises how much data this station is willing to


accept. It may depend on remaining buffer space also.

URG: Urgent pointer field is valid


ACK: Acknowledge field is valid
PSH: This segment requests a push
RST: Reset the connection
SYN: Synchronize
y
sequence
q
Number
FIN: Sender has reached end of its bit/byte stream (Finish)

Checksum: Verifies the integrity of the TCP header and data. It is


mandatory.
Urgent pointer: used with the URG flag to indicate where the
urgent data starts in the data stream. Typically used with a file
transfer abort during FTP or when pressing an interrupt key in
telnet.
Options: used for window scaling, SACK, timestamps, maximum
segment size etc.

OPM

11

OPM

12

2/6/2015

Reliable Streams

Providing Reliability (TCP)


Using Acknowledgements (Ack), sender waits for positive Ack of packet sent.

Transmission Control Protocol (TCP)


Guarantees reliable, ordered stream of traffic
Such guarantees impose additional overhead
A fair amount of state is required on both ends

In case of TIME OUT or negative Ack retransmission occurs


Flow control using WINDOW size
As per network/ channel condition Window size can be varied as per feedback from receiver

Most Internet protocols use TCP, e.g. HTTP, FTP, H.323


control channels

Retransmission in case of Window Transmission


Go back to N retransmission
Selective retransmission

New technique of Ack to send next expected packet instead of sending Ack of
each received packet.
OPM

13

TCP : Data transfer


Client

Timer

Send Packet 1
Start Timer

14

TCP flow control


Host

Windows vary over time


Packet Lost

ACK would normally


Arrive at this time

Receiver advertises (in ACKs) how many it can receive


Based on buffers etc. available
Sender adjusts its window to match advertisement
If receiver buffers fill,, it sends smaller adverts

Packet should arrive


ACK should be sent

Time Expires

Timer

OPM

Retransmit Packet1
Start Timer

Receive Packet 1
Send AXK 1

Used to match buffer memory requirements of receiver

Receive ACK 1
Cancel Timer

Also used to address congestion control (e.g. in intermediate


routers)

OPM

15

OPM

16

Transport Protocols in the Internet

UDP UserDatagramProtocol
UDP
datagramoriented
unreliable,connectionless
simple
unicast andmulticast
usefulonlyforfewapplications,e.g.,
multimediaapplications
usedalotforservices
networkmanagement(SNMP),
routing(RIP),naming(DNS),etc.

TCP TransmissionControlProtocol
streamoriented
reliable,connectionoriented
complex
onlyunicast
usedformostInternetapplications:
web(http),email(smtp),file
transfer(ftp),terminal(telnet),
etc.

OPM
17

You might also like