500 likes | 716 Views
Transmission Control Protocol (TCP). BSAD 141 Dave Novak Sources : Network + Guide to Networks, Dean 2013. Outline. Discuss role of layer 4 transport protocols from perspective of OSI model services Process-level communication TCP How different from IP Connection-based service
E N D
Transmission Control Protocol (TCP) BSAD 141 Dave Novak Sources: Network+ Guide to Networks, Dean 2013
Outline • Discuss role of layer 4 transport protocols from perspective of OSI model services • Process-level communication • TCP • How different from IP • Connection-based service • Reliability aspects • UDP
Transport protocols • From OSI model perspective IP is a network layer protocol • Has its own layer (internetworking layer) in the TCP/IP model • IP provides a universal routable address format and offers: • Connectionless, best-effort service • Unreliable service
Transport protocols • Layer 4 transport layer protocols work with layer 3 network layer protocols to provide additional services: • Process-to-process communication • End-to-end error control
Transport protocols • IP focuses on host-to-host communication, not process-to-process communication • What is process-to-process communication? • Individual hosts run multiple processes at one time • Multiple applications, utilities, etc. • Must be some protocol to manage multiple processes between hosts
Transport protocols • Layer 4 transport layer protocols are responsible for managing process-to-process communication • 2 transport layer protocols in TCP/IP protocol suite • 1) • 2)
TCP Introduction • It can be desirable to have a transport protocol that not only manages processes, but provides reliable service
Internet Protocol (IP) • IP is connectionless • Provides a generic, universal address format that is understood by all devices on the internet • Independent of specific data link technologies • Routes all IP datagrams independently • No guarantee that packets will travel on same route to destination
Internet Protocol (IP) • Allows for fragmentation and reassembly of datagrams • Can subdivide datagrams to fit in any frame payload
Transmission Control Protocol (TCP) • Connection-oriented service • Establishes virtual connection between 2 hosts • Provides reliableservice • Guaranteed delivery of data with acknowledgement from the receiver
Transmission Control Protocol (TCP) • Point-to-point • Establishes connections between two specific endpoints – single process running on sending host to single process running on receiving host
Transmission Control Protocol (TCP) • Manage process-to-process communication • Address out of order delivery • Address packet loss • Adjust routing based on network conditions (congestion control) • Adjust how many packets are sent in a given time period (flow control) • Establish an explicit “connection” between sender and receiver • Address corrupt data
TCP Segments • TCP uses same format for all messages (the segment “looks” the same regardless of the type of message) • Data transmission • ACK (acknowledgement) • 3-way handshake (connection establishment and tear-down) • All TCP messages called segments • Segments encapsulated in IP datagram payload
TCP Encapsulation Layer 4 (TCP segment) IP datagram payload – TCP segment header becomes part of IP payload IP datagram header Layer 3 (IP datagram) Frame payload – IP header placed in frame payload Frame header Layer 2 (Frame)
TCP – Ports • Transport layer protocol (TCP or UDP) identify the protocol or process that generated data • Often map this to a specific port number • 1) On a computer, a place to be physically connected to another device (example, serial port, parallel port) • 2) Using TCP/IP, a logical connection (a client application specifies an application on a remote computer (SOFTWARE) • 3) In programming, to move an application for the development environment to be run in another environment
TCP – Ports • Common internet applications are assigned specific, well-known port numbers • TCP and UDP maintain their own separate lists of well-known ports
TCP – Examples of Common Ports You can visit http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers To view a list of well-known TCP and UDP port numbers
Sockets • TCP/IP system addresses traffic to another system using combination of: • 1) IP address • 2) Port number • This combination of IP address and port number is called a socket • Sending socket – 137.99.101.55:4532 • Receiving socket – 185.100.32.56:80
TCP – Sockets • Don’t specify port number when typing URL because applications assume you are connecting to well known port numbers • Your Web browser generally addresses all URLs to TCP port 80 – default HTTP port • You could configure a Web server to operate on an alternate port – any users connecting to your Web server would need to know the port number and specify it • http://www.privateserver.com:81
TCP • Mapping the OSI and TCP/IP models FTP, HTTP, DHCP Application layer 7 Application layer Binary, ASCII Presentation layer 6 Session layer 5 TCP Transport layer Transport layer 4 IP Network layer Internet layer 3 2 Data Link layer LAN technology, cabling Network Interface layer 1 Physical layer
TCP Services • Major features of TCP • Connection oriented • Point-to-point communication • Complete reliability • Full duplex communication • Connection startup and shutdown
Reliable service – what does this mean? • Many types of problems can arise on a communications network • Duplicate messages • Out-of-order delivery • Delayed messages • Lost messages • TCP employs a number of techniques to address these issues and provide “reliable” service
Achieving Reliability • 4 components to TCP reliable service • 1) • 2) • 3) • 4)
1) Connection Establishment • Before two systems exchange application layer data, a virtual connection between 2 processes on 2 hosts explicitly established • Ensures both sender and receiver are: • 1) Present (actually exist and are accessible) • 2) Operating properly • 3) Ready to receive data
1) Connection Establishment • Connection implemented through software and remains alive during data exchange • Then the connection terminated in an orderly, systematic fashion • Usually a single file exchange
1) Connection Establishment • Three-way handshake algorithm • Systematic connection establishment and tear down requires an exchange of three messages • SYN segment – synchronization segment for establishment • FIN segment – for termination
1) Connection Establishment • Three-way handshake algorithm • Each system (sender on one end, receiver on the other) establishes separate connections running in opposite directions • Full duplex protocol • Each terminates separately
3-Way Handshake (initialization) Client initiates Server 1) Client sends session Initialization request to server. Includes “plan” for transmission 1) SYN 2) Server sends back its starting sequence number and an acknowledgement 2) ACK + SYN 3) Client acknowledges receipt of server’s sequence number 3) ACK
Terminating Both Connections (tear down) Client initiates Server 1) Client sends termination request to server 1) Client FIN 2) Server acknowledges that it has received client’s request 3) Server generates its own FIN message 2) ACK 3) Server FIN 4) Client acknowledges receipt of server’s FIN FIN and ACK cannot piggy back Server cannot include its FIN in the ACK sent to client 4) ACK
End-to-End Service • Direct connection from process on one host to process on another host • Set up connection • Socket • Exchange data • Receiver knows exactly how much data to expect • Close connection
2) Retransmission • If data are lost, or there are problems, TCP can retransmit messages • TCP allows multiple applications to communicate with multiple destinations at same time • TCP must handle variety of delay scenarios and times that can change • A timer is set to decide when to retransmit • The retransmission timer can differ by application
2) Retransmission • Timer for retransmission depends on: • Network congestion • Distance to destination • Bandwidth of link • TCP can adapt to network conditions and to the needs of individual applications
Adaptive Retransmission • TCP uses adaptive retransmission • Monitors delay on each retransmission and adapts to accommodate changing conditions • TCP estimates round trip time (RTT) for each active connection
Adaptive Retransmission • Adapts by subtracting time message is sent from time ack is received • Ack received 8:03:45:07 • Message sent 8:03:45:02 • 8:03:45:07 - 8:03:45:02 = 0:0:0:05 • Uses weighted moving average of RTT • Weights most recent activity most heavily • Adjusts to conditions on network
Adaptive Retransmission • Fixed timeouts specifying retransmission times do not work well on a large internetwork • Why would this be the case?
3) Flow Control • Managing the flowof data between two processes • Why would this be important? • What would happen if the sending computer is much faster and has a larger buffer than the receiving computer?
3) Flow Control • TCP utilizes the sliding windowscheme for flow control • Connection established • Each host allocates buffer to hold incoming data until it can be processed • Size of buffer sent to other computer • Remaining buffer size specified in ack when each transmission is received • Sending computer adjusts amount of data it sends based on size of remaining buffer size • If zero buffer remains, sending computer must stop transmitting until space is available
3) Flow Control • Offered window – # bytes receiving system has authorized transmitting system to send As receiver acknowledges bytes, left side of window moves to the right As receiver passes acknowledged bits up to application layer, right side of window moves to the right
4) Congestion Control • Managing amount of data being injected onto the network by specific host • Why would this be important? • What happens if switches and/or links become overloaded?
4) Congestion Control • Packet loss and delay most often caused by congestion, not hardware failure • TCP can exacerbate congestion problem through retransmission • How (what happens if you add cars to an already congested freeway)?
4) Congestion Control • Congestion collapse • TCP uses packet loss as a measure of congestion measurement • TCP determines how busy the network is by the number and frequency of lost packets
4) Congestion Control • Simplified algorithm for congestion control • When packet loss occurs, TCP immediately reduces number of packets sent to one (regardless of the maximum number it can send) • If ack for single packet received, send 2 packets • Receiver acknowledges successful receipt of data • If ack for both packets received, send 4 packets • Exponential increase, until half Send Window Size (max amount that can be sent) achieved • Than cut back to a less aggressive increase
User Datagram Protocol (UDP) • While TCP captures most of our attention, UDP is also widely used transport protocol in TCP/IP stack • Process-to-process communication • Connectionless datagram service • Provides NO reliability • Very little overhead
User Datagram Protocol (UDP) • Communication consists of 2 messages • Request and reply – there is no connection establishment
UDP • If TCP provides reliability and UDP does not, why would UDP be used at all?
Summary • Process-to-process communication • TCP • How different from IP • Four reliability components • UDP