320 likes | 606 Views
The transport layer in the TCP/IP - OSI models. Laurent Babout. Introduction. In this lecture, you will learn: The purpose of the transport layer Its functionality How the protocol adapts to the application data. Roles of the transport layer. Purpose
E N D
The transport layer in the TCP/IP - OSI models Laurent Babout
Introduction • In this lecture, you will learn: • The purpose of the transport layer • Its functionality • How the protocol adapts to the application data
Roles of the transport layer • Purpose • Tracking individual conversation (controlling conversation) • Identifying the Applications • Segmenting Data / Reassembling segments • Adapt to data requirements Source: cisco CCNA Exploration 4.0
Roles of the transport layer (ct’d) • Example: a PC is connected to the network that is simultaneously dealing with a variety of applications, e.g. sending and receiving emails, browsing the web, conducting VoIP phone calls. • Each app. has its own requirements: • Data have to be redirected to the right application • Email and web contents must be complete, but delays are acceptable • Live calls are requested (limited delays), but missing parts can be acceptable • Simultaneous and concurrent applications • To ensure simultaneous applications, dividing data into small parts (pieces or conversations) is foreseen (in accordance with Transport layer protocols) • Need also a way to reassemble the conversations The solution: adding headers to the conversations. This header contains fields of bits. The values enable the Transport layer protocols to perform different functions.
Role #1:Controlling the conversations • 4 main principles of the protocol (more details later on) • Establish session between end devices • Communication between applications • Reliable delivery • Retransmission of corrupted or lost data to the destination • Same order delivery • Numbering and sequencing the segments for reassembling in proper order • Flow control • Regulation of the amount of data transmitted to avoid overflow, loss of segments and the need for retransmission
Role #1:Controlling the conversations (ct’d) • Reliable communication • Tracking transmitted data • Acknowledge received data • retransmitting any unacknowledged data • However, the degree of reliability depends on the application/data • Trade-off between reliability and network capacity • Different required protocols properties Source: cisco CCNA Exploration 4.0
Role #1:Controlling the conversations (ct’d) • Adapt protocol to the conversation • Two “most popular” protocols with different properties • TCP: Transmission Control Protocol • UDP: User Datagram Protocol • TCP • Connection-oriented protocol • 20 bytes of overhead • Main functions: same order delivery,reliable delivery, flow control • Main applications: • Web browsers • E-mail • File transfers • UDP • Simple, connectionless protocol • 8 bytes of overhead • Datagram sent as “Best effort” • Main applications: • Domain Name System (DNS) • Video streaming • Voice over IP (VoIP)
Role #1:Controlling the conversations (ct’d) TCP protocol 20 bytes UDP protocol 8 bytes See more details later on…
Role #2: Identifying the application - port addressing • TCP/UDP keep track of communicating apps • In segment/datagram header, 1st 4 bytes refer to source and destination ports • Client/server are sequentially associated to source/destination protocols during communication • Port values have different meaning, correspond to different types of conversations • Assignment differ for client and server • client: random port number, usually above 1023 • server: static assignment (port daemon service) • port 80 http • Port 110 POP3 • Port 21 telnet • …
Role #2: Identifying the application - port addressing (ct’d) • 3 different domains for port addressing • 0 to 1023: well-known (contact) ports • 1024 to 49151: registered ports / dynamic ports • 49152 to ?????: private and/or dynamic ports • Client ports dynamically assigned from 2nd and 3rd domain (depend on operating system) • Well-known services and apps in 1st domain • User processes and apps. in 2nd domain • Exhaustive list of well-known / registered ports: http://www.iana.org/assignments/port-numbers. 65535
Source port Destination port Connection state Protocol used Protocol used 8 bytes (Hex) Source port (2 bytes) d774 ≡ 55156 Role #2: port addressing (ct’d) • Check active connection and port used • Netstat: simplistic description • WireShark: advanced network protocol analyser C:\>netstat Active Connections Proto Local Address Foreign Address State TCP img2008:3848 zly.kis.p.lodz.pl:22 ESTABLISHED TCP img2008:3894 fra07s07-in-f104.1e100.net:http ESTABLISHED TCP img2008:4310 symbianversion.mobilevoip.com:httpESTABLISHED
Role #3: Segmenting and Reassembling the data - divide and conquer • Why segmenting large data? • Impractical to send data in 1 piece (network blocked during transmission) • Error handling (everything is lost) • Problem with Network memory buffer • Data transfer overflow • Dividing data into pieces ensures • Data transmitted within limits of media • Data multiplexing • TCP and UDP handles differently segmentation
Role #3: divide and conquer (ct’d) The transport layer divides the data into pieces and adds a header for delivery over the network • UDP: • Faster transfer than TCP • No control of data order: reassembling may be in different order than segmenting • TCP: • Sequence number, reassemble segments • in same order as transmitted • Slower transfer than UDP • UDP Header contains: • Source port • Destination port • Sequencing for same order delivery • Acknowledgement of received segments • Flow control and congestion management • UDP Header contains: • Source port • Destination port Source: cisco CCNA Exploration 4.0
Last octet of sequence Next octet expected by receiver Value of dynamic window – how many octet can be sent before waiting for acknowledgement Used in session management and in the treatment of segments Used for errors – check the header and data A closer look to TCP
TCP – making conversations reliable • Connection-orientated session • Before data are sent, Transport layer creates connection • After session established, destination sends acknowledgment to the source for the received segments • If source receives ack., OK. Otherwise, data resent • Connection terminated
Connection – the 3-way-handshake • 1st step: client sends server a segment with SYN (synchronization) flag • Sequence value set to 0 (default)
Connection – the 3-way-handshake (ct’d) • 2nd step: server acknowledges reception (ACK flag) and send request (SYN flag) to client • ACKse=SEQcl+1, SEQse=0
Connection – the 3-way-handshake (ct’d) • 3rd step: client responds with acknowledgment flag • ACKcl=SEQse+1
Connection – the 3-way handshake (ct’d) • To conclude, we can compare the 3-way handshake to a phone conversation • Hi, do you hear me (SYN 1) • Yes, I hear you. (ACK1) • And you, do you hear me (SYN 2) • Yes. I hear you too (ACK 2) • (conversation starts)
Send FIN 1 FIN received Send ACK 2 Send FIN 3 ACK received FIN received 4 Send ACK ACK received Termination: the 4-way handshake A B Two 2-way handshakes. Can be initiated by any 2 hosts (i.e. client or server). Why? The operation is complete: the server terminates the conversation. OR, the client cancel the operation: the client terminates the conversation.
TCP - segment reassembly • When service sends data using TCP, segments may arrive to destination out of order • Sequence number from the header used for that • Session starts, an initial sequence number (ISN) is set • This number is incremented by the number of bytes being transferred in a segment • So, each segment is unique. Missing segments can be identified as well • How does it work to reassemble? • TCP places segments in buffer • Reordered in the proper sequence number order • Passed to the application layer • Segments held if arrived with noncontiguous sequence numbers
TCP - segment reassembly (ct’d) • Schematic representation Source: cisco CCNA Exploration 4.0
TCP – confirming segments receipt • One of TCP’s function: make sure that segments reach destination • Sequence and acknowledgment numbers used for that • Sender ack. number: fixed number (e.g. 1) • Receiver seq. number = Sender ack. Number • Receiver ack. Number=Sender seq. number+length(segment) Source: cisco CCNA Exploration 4.0
TCP – confirming segments receipt(ct’d) Segment sent by server • Wireshark view Fixed ack. number during segment transmission Acknowledgment of reception by client Next starting octet expected
TCP – congestion control • Flow control • Window size in TCP header determines the number of bites sent before an ack. is expected • The ack. Number is the number of the next expected byte Source: cisco CCNA Exploration 4.0
TCP – congestion control (ct’d) • Reducing window size • If congestion at the destination occurs because size of segment too large, window size is reduced • Size typically reduced by 2 • New size send as part of an acknowledgment Source: cisco CCNA Exploration 4.0
A closer look at UDP • Simple transport protocol providing basic layer functions • Connection-less, no data retransmission, no sequencing, no flow control as TCP • Simpler does not mean unreliable. Just need reajustment elsewhere than in the transport layer if required • Examples of Application layer protocols which use UDP • Domain Name System (DNS) • Simple Network Management Protocol (SNMP) • Dynamic Host Configuration Protocol (DHCP) • Routing Information Protocol (RIP) • Online games (can accept loss of data)
UDP – datagram reassembly • Connection-less: No session established, no acknowledgement • The data is reassembled in the order it arrives at destination Source: cisco CCNA Exploration 4.0
UDP – processes and request • Server process • Like TCP-based apps, UDP-based server apps are assigned Well-known or Registered port • Client process • Like TCP-based apps, UDP-based client apps are assigned randomly • Use as source port for the conversation • During conversation, both ports are interchanged in the source/destination fields of the header