6-tcp-udp
TRANSCRIPT
-
7/21/2019 6-TCP-UDP
1/3
2/6/20
TCP/UDP
Need of TCP and UDP ?
ntro uct on
UDP Header
Introduction TCP
TCP Header
Comparison between TCP and UDP
1OPM
TCP-UDP
Allow multiple application programs/processes execution on a host
device (having operating system) to transmit and receive datagram
independently.
Port numbers are used to distinguish different application data
.
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 respectively2OPM
TCP/UDP layering
A connection need:
IP
Port1
TCP UDP
Port2 Port1 Port2
DemuxonIP
protocol
Demuxon
Portnumber
Network
Transport
App.
3
Source: (IP address, port No.) and Destination: (IP address, port No.)
Require one port (PHY connection) on host to allow multipleconnections, since each connection will have different (host, port) at otherend.
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
IP: Internet Protocol
Unreliable connectionless datagram delivery service
Responsible for routing of data through intermediate networks and
computers
11 1111 1111 2222 2222 2233
4
IPheader:
1 :ICMP
6 :TCP
17:UDP
89 01 2 345 67 89 01 23 4 56 7 8 9010 12 3 4 56 7
OPM
UDP (User Datagram Protocol)
Each UDP message contains source and destination port number,delivers message to correct recipients.
Less reliable (No ACK), delay prone, connectionless datagram
delivery.
Doesnt include acknowledge, order of messages, feedback tocontrol the rate of information flow between machines.
UDP message may be lost, duplicate or arrive out of order.
Packet can arrive faster than the recipient can process them.
5OPM
UDP Datagram format
Sourceport Destinationport
UDPmessagelen Checksum(optional)
0 8 16 3124
Data
6
ource est nat on port:port num ers ent y sen ng rece v ng processes(programs or applications)
Port number & IP address allow any application in any computer on Internet to be uniquelyidentified
Used to multiplex and demultiplex datagrams to processes at a host device.
Ports can be static or dynamic
Static (< 1024 and some additional blocks, and registered port no.) assigned centrally, known as wellknown ports
Dynamic (private port no., un registered, In range from 49152 to 65535)
UDP Message length: in bytes includes the UDP header and data
Checksum: of UDP header and Data (this field is optional)OPM
-
7/21/2019 6-TCP-UDP
2/3
2/6/20
Datagram Transport
User Datagram Protocol (UDP)
A best-effort delivery, no guarantee, no ACK
Smaller overhead than TCP
Good for best-effort traffic likeperiodic updates
No long lived connection overhead on the endpoints
SNMP and DNS protocols use UDP
Data channels of some multimedia protocols, e.g., H.323 alsouses UDP due to low header processing delay
7OPM
TCP : Transmission Control Protocol
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.)
8
Data is guaranteed to arrive, and in the correct order without
duplications
Otherwise the connection will be dropped
Imposes significant overheads
OPM
TCP Header (followed by data/ payload)
SourcePort(16) DestinationPort(16)
SequenceNumber(32)
Acknowledgementnumber(32)
HDR
Len(4)
U
R
G
A
C
K
P
S
H
R
S
T
S
Y
N
F
I
N
WindowSize
(16)
Checksum (16) UrgentPointer(16)
Options(0ormorewords)
9
Reserved(6)
OPM
TCP Header (cont.)
Source/destination port:port numbers identify sending & receivingprocesses (programs or applications)
Sequence Number: identifies position of packets/ segments in bit stream
Acknowledgement (piggyback) : identifies the sequence number of
10
packet the sender of this packet/segment expects to receive next, refersstream flowing opposite direction
Header length (Hlen): specifies the length of the segment header in 32bit blocks/multiples. If there are no options, the Hlen = 5 (20 bytes)
Reserved for future use, set to 0
OPM
TCP header (cont.)
Code (flags): used to determine purpose contents in header
URG: Urgent pointer field is valid
ACK: Acknowledge field is valid
PSH: This segment requests a push
RST: Reset the connection
SYN: Synchronize sequence Number
FIN: Sender has reached end of its bit/byte stream (Finish)
11OPM
TCP Header (Cont.)
Window: Advertises how much data this station is willing to
accept. It may depend on remaining buffer space also.
Checksum: Verifies the integrity of the TCP header and data. It is
mandatory.
12
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
-
7/21/2019 6-TCP-UDP
3/3
2/6/20
Reliable Streams
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
Most Internet protocols use TCP, e.g. HTTP, FTP, H.323
control channels
13OPM
Providing Reliability (TCP)
Using Acknowledgements (Ack), sender waits for positive Ack of packet sent.
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
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.
14OPM
TCP : Data transfer
HostClient
Send Packet 1Start Timer Packet should arrive
ACK should be sentACK would normallyArrive at this time
Packet LostTimer
Retransmit Packet1Start Timer Receive Packet 1
Send AXK 1
Receive ACK 1Cancel Timer
Timer
15OPM
TCP flow control
Windows vary over 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
16
Used to match buffer memory requirements of receiver
Also used to address congestion control (e.g. in intermediate
routers)
OPM
Transport Protocols in the Internet
UDPUDPUserDatagramProtocolUserDatagramProtocol
datagramoriented
unreliable,connectionless
TCPTransmissionControlProtocol
streamoriented
reliable,connectionoriented
17
unicast andmulticast
usefulonlyforfewapplications,e.g.,
multimediaapplications
usedalotforservices
networkmanagement (SNMP),
routing(RIP),naming(DNS),etc.
onlyunicast
usedformostInternetapplications:
web(http),email(smtp),file
transfer(ftp),terminal(telnet),
etc.
OPM