ccnet-lec-13-tcp-udp
TRANSCRIPT
-
8/6/2019 ccnet-lec-13-TCP-UDP
1/29
Lecture
13Data Communication & Networks
Transport Layer
(TCP/UDP)
Muhammad Yousaf
-
8/6/2019 ccnet-lec-13-TCP-UDP
2/29
Where we are in protocol stack:
todays topic
application
end-to-end
physical
IP
data link }Until now
we have been discussing
the issues related to
lower three layer
}
-
8/6/2019 ccnet-lec-13-TCP-UDP
3/29
Users Perspective:
Users demand connectivity, reliability, functionalityThey dont concern of underlying technology
Our IP network is an unreliable network
IP provides the Best Effort Service
Packets may be discarded, duplicated, receive with error,etc.
Users want the reliable communication between
end applicationsConnectivity between end host applications iscalled End-to-End connectivity
-
8/6/2019 ccnet-lec-13-TCP-UDP
4/29
Scope of different layer:
Data Link Layer:Communicate between directly-connected nodesWithin a single network only
IP Layer:
Communicate between hosts residing anywhere in the world
Across multiple networks
Take end host as a single entity
Transport Layer:
We possess multi-tasking computers
For users, each application is different entity
Communicate among different applications on individual hosts acrossmultiple networks
-
8/6/2019 ccnet-lec-13-TCP-UDP
5/29
Transport Layer:
For communication among applications:we need another level of addressing
that uniquely distinguish different applications on host
Port numbers are used to achieve this level of
addressingThese are logical port numbers, in contrast to physicalports
Port number is a 16-bit positive integer value
Theoretically it means, a computer can supportthousands of simultaneous connections! Enough
Transport layer protocols e.g. TCP & UDP provide portnumbers
-
8/6/2019 ccnet-lec-13-TCP-UDP
6/29
Port Numbers:
Well-Known Ports:Permanently assigned to servers listening for requestsAssigned by IANA
Ranging from 0 to 1023
Registered Ports:Not permanently assigned
But registered with IANA
e.g. WINS uses port-1512
Ephemeral Ports:Temporarily assigned to clients
Can change for client applications in each session
Can range from 1024 to 65536
-
8/6/2019 ccnet-lec-13-TCP-UDP
7/29
Well-Known Ports:
For TCP:Port-21 = FTP (File Transfer Protocol)
Port-25 = SMTP (Simple Mail Transfer Protocol)
Port-53 = DNS (Domain Name System)
Port-80 = HTTP (Hyper Text Transfer Protocol), [www]
For UDP:
Port-69 = TFTP (Trivial FTP)
Port-123 = NTP (Network Time Protocol)Port-161 = SNMP (Simple Network Management Protocol)
Port-520 = RIP (Routing Information Protocol)
-
8/6/2019 ccnet-lec-13-TCP-UDP
8/29
Transport Layer Services:
Other than application multiplexing, there are twoother types of end-to-end services at transportlayer:
Connectionless Service
Connection-Oriented Service
-
8/6/2019 ccnet-lec-13-TCP-UDP
9/29
Connectionless Service:
Connectionless:Unreliable
No Acknowledgments
No Control over out-of-order delivery
No Flow ControlNo Congestion Control
Protocol = UDP
Helpful for applications that dont need guaranteed
delivery
e.g. multimedia, delay-sensitive applications
-
8/6/2019 ccnet-lec-13-TCP-UDP
10/29
-
8/6/2019 ccnet-lec-13-TCP-UDP
11/29
Transport Layer Protocols:
Many transport layer protocols are supported byInternet
User Datagram Protocol (UDP)
Transmission Control Protocol (TCP)
Stream Control Transmission Protocol (SCTP)Datagram Congestion Control Protocol (DCCP)
-
8/6/2019 ccnet-lec-13-TCP-UDP
12/29
UDP:
UDP = User Datagram ProtocolDefined in RFC-768
There is no notion of connection
You have the data, you send it without checkingwhether destination is alive or not
Also, there is no acknowledgment of sent data
In case of error there is no retransmissions
-
8/6/2019 ccnet-lec-13-TCP-UDP
13/29
-
8/6/2019 ccnet-lec-13-TCP-UDP
14/29
UDP header fields:
Source Port:Port number of sending application
Destination Port:
Port number of receiving application
Length:
Length of entire UDP packet including header & data
Checksum:
Optional, if not used then set equal to zero
-
8/6/2019 ccnet-lec-13-TCP-UDP
15/29
TCP:
Transmission Control ProtocolDefined in RFC-793
For sending data:
First establishes connection
Then transfer data
In the end, terminates connection
Provides reliable byte-stream for end-users
-
8/6/2019 ccnet-lec-13-TCP-UDP
16/29
TCP header:
-
8/6/2019 ccnet-lec-13-TCP-UDP
17/29
TCP header fields:
Source Port:Port number of sending application
Destination Port:
Port number of receiving application
Sequence Number:
Sequence number (byte count) of first byte of TCPsegment
Used for in-order delivery
Acknowledgment Number:
Sequence number of next byte expected by the receiver
Used for reliability & flow control
-
8/6/2019 ccnet-lec-13-TCP-UDP
18/29
TCP header fields: cont
Data Offset:
Number of 32-bit words in the header (header length)
Reserved:
Reserved for future use
TCP Header Flags:
CWR: Congestion Window Reduced indication (*RFC-3168)
ECE: ECN (Explicit Congestion Notification) indication
URG: urgent pointer field is significant
ACK: Acknowledgment field is significant
PSH: Push data from TCP send buffer
RST: Reset connection
SYN: Synchronize, set in connection-request message
FIN: Finish, set in connection close message
-
8/6/2019 ccnet-lec-13-TCP-UDP
19/29
TCP header fields: cont
Window:Indicate number of bytes that receiver can receive
Used for flow control
Checksum:
Same as IP & UDP checksum
Urgent Pointer:
Indicate to receiver that some urgent data is coming
Options + Padding:Optional information if any
e.g. negotiation of maximum segment size
-
8/6/2019 ccnet-lec-13-TCP-UDP
20/29
TCP connection:
Two applications talking to each other over TCPestablish a TCP-connection between each other
For this connection, TCP at each host reservessome resources for this connection
This is an agreement between end hosts only
Network is unaware of any such connection
Network doesnt know any thing above IP layer
This is in contrast to Circuit-Switched connectionWhere network reserves resources for end nodes
-
8/6/2019 ccnet-lec-13-TCP-UDP
21/29
TCP connection: cont
Over Internet each application is identified through2-parameters
Port Number of application & IP Address over which thatapplication is being executed
(port number, IP address)And each TCP connection between twoapplications is identified through 4-parameters
Two from source application, two from destination
application
(source port, source IP, destination port, destination IP)
-
8/6/2019 ccnet-lec-13-TCP-UDP
22/29
TCP connection setup:
A single TCP connection is full-duplexBoth client & server can send/receive simultaneously
Connection is established through a three stepprocess
3-way handshake
Client sends request (syn segment)
Server acknowledges it and also send its own synsegment
Client acknowledges servers syn
Recall the flags in TCP headerSYN, FIN, RESET, PUSH, URG,ACK
-
8/6/2019 ccnet-lec-13-TCP-UDP
23/29
TCP connection setup: cont
3-way HandshakeJ and K are (different) sequence numbers for messages
Sequence numbers need not start at zero
Active
participant
(client)
Passive
participant
(server)
SYN J
SYN K
ACK J+1
ACK K+1
-
8/6/2019 ccnet-lec-13-TCP-UDP
24/29
Data transfer over TCP:
After establishment of connection, in terms ofcommunication there is no discrimination betweenclient & server
They both are now sender & receiver
(NOTE: we are talking in terms of communication, not interms of services)
Sender sends with byte sequence number
Receiver replies with acknowledgment number &advertised window size
-
8/6/2019 ccnet-lec-13-TCP-UDP
25/29
Data transfer over TCP: cont
Reliability & Flow controlSequenceNum, ACK, AdvertisedWindow
Sender
Data(SequenceNum)
Acknowledgment +AdvertisedWindow
Receiver
-
8/6/2019 ccnet-lec-13-TCP-UDP
26/29
TCP connection termination:
Either client or server can initiate connection terminationTCP connection teardown in 4 steps
client server
FIN J
FIN K
ACK K+1
ACK J+1
active close
passive close
closes connection
-
8/6/2019 ccnet-lec-13-TCP-UDP
27/29
TCP connection: (concept)
client server
my-machinemail.yahoo.com
I am
mail.yahoo.com,
port b
I accept
connections
I will talk to
my-machine,
port a
Talk to
mail.yahoo.com,
port b
Resulting TCP connection identified by
(my-machine:a, mail.yahoo.com:b)
-
8/6/2019 ccnet-lec-13-TCP-UDP
28/29
TCP connection: (implementation)
I am
mail.yahoo.com,
port b
I accept
connections
I will talk to
my-machine,
port a
Talk to
mail.yahoo.com,
port b1. socket()
2. bind()
3. listen()
4. socket()
5. connect()
6. accept()
7. send() / sendto()
8. recv() / recvfrom()
9. close() / shutdown()
client server
my-machinemail.yahoo.com
-
8/6/2019 ccnet-lec-13-TCP-UDP
29/29
myousaf@ymail com 29
To be continued