90 likes | 381 Views
IP. TCP. Higher-level protocol. Socket. Application 1. Application 1. Network. Application 2. Application 2. Application 3. IP protocol is routes the data packet through the network. Application 3. 10. UDP/TCP. WWW page: http:/www.dcs.napier.ac.uk/~bill/cnds/index.html
E N D
IP TCP Higher-level protocol Socket Application 1 Application 1 Network Application 2 Application 2 Application 3 IP protocol is routes the data packet through the network Application 3 10. UDP/TCP WWW page: http:/www.dcs.napier.ac.uk/~bill/cnds/index.html Text book: Mastering Networks (Chapter 10)
10.1 TCP (Transmission Control Protocol) • Data Transfer. Data is transmitted between two applications by packaging the data within TCP packets. This data is buffered and forwarded whenever necessary. A push function can be used when the data is required to be sent immediately. • Reliability. TCP uses sequence numbers and positive acknowledgements (ACK) to keep track of transmitted packets. Thus, it can recover from data that is damaged, lost, duplicated, or delivered out of order, such as: • Time-outs. The transmitter waits for a given time (the timeout interval), and if it does not receive an ACK, the data is retransmitted. • Sequence numbers. The sequence numbers are used at the receiver to correctly order the packets and to delete duplicates. • Error detection and recovery. Each packet has a checksum, which is checked by the receiver. If it is incorrect the receiver discards it, and can use the acknowledgements to indicate the retransmission of the packets. Flow Control. TCP returns a window with every ACK. This window indicates a range of acceptable sequence numbers beyond the last segment successfully received. This window also indicates the number of bytes that the sender can transmit before receiving further acknowledgements. Multiplexing. To support multiple connections to a single host, TCP provides a set of ports within each host. This, along with the IP addresses of the source and destination, makes a socket. Each connection is uniquely identified by a pair of sockets. Ports are normally associated with various services and allow service programs to listen for defined port numbers. Connections. A connection is defined by the sockets, sequence numbers and window sizes. Each host must maintain this information for the length of the connection. When the connection is closed, all associated resources are freed. As TCP connections can be made with unreliable hosts and over unreliable communication channels, TCP uses a handshake mechanism with clock-based sequence numbers to avoid inaccurate connection initialisation. Precedence and Security. TCP allows for different security and precedence levels. Transport TCP IP TCP Higher-level protocol Network IP
10.2 TCP operation Operation When a host wishes to make a connection, TCP sends out a request message to the destination machine that contains unique numbers called a socket number, and a port number. The port number has a value which is associated with the application (for example a TELNET connection has the port number 23 and an FTP connection has the port number 21). The message is then passed to the IP layer, which assembles a datagram for transmission to the destination. When the destination host receives the connection request, it returns a message containing its own unique socket number and a port number. The socket number and port number thus identify the virtual connection between the two hosts. After the connection has been made the data can flow between the two hosts (called a data stream). Sending Port Number (such as 21 for FTP) Unique Sending Socket Number Receiving Port Number (typically the same as sender’s) Unique Receiving Socket Number Data transfer using ports and sockets (data stream)
10.3 TCP and IP IP TCP Higher-level protocol Socket Application 1 Application 1 Network Application 2 Application 2 Application 3 IP protocol routes the data packets through the network Application 3 TCP protocol is responsible for a data stream between application programs
10.4 TCP header contents Main fields Source and destination port number – which are 16-bit values that identify the local port number (source number and destination port number or destination port). Sequence number – which identifies the current sequence number of the data segment. This allows the receiver to keep track of the data segments received. Any segments that are missing can be easily identified. The sequence number of the first data byte in this segment (except when SYN is present). If SYN is present the sequence number is the initial sequence number (ISN) and the first data octet is ISN+1. Acknowledgement number – when the ACK bit is set, it contains the value of the next sequence number the sender of the packet is expecting to receive. This is always set after the connection is made. Data offset – which is a 32-bit value that identifies the start of the data. It is defined as the number of 32-bit words in the header (as the TCP header always has a multiple number of 32-bit words). Flags – the flag field is defined as UAPRSF, where U is the urgent flag (URG), A the acknowledgement flag (ACK), P the push function (PSH), R the reset flag (RST), S the sequence synchronise flag (SYN) and F the end-of-transmission flag (FIN). Window – which is a 16-bit value and gives the number of data bytes that the receiving host can accept at a time, beginning with the one indicated in the acknowledgement field of this segment. Checksum – which is a 16-bit checksum for the data and header. It is the 1’s complement of the 1’s complement sum of all the 16-bit words in the TCP header and text. The checksum is assumed to be a zero when calculating the checksum. IP TCP Higher-level protocol
10.5 UDP 32 bits Source IP address Destination IP address IP header Protocol= Zero UDP length 17 Source port UDP header Destination port Length Checksum DATA IP UDP Higher-level protocol Source port. This is an optional field and is set to a zero if not used. It identifies the local port number which should be used when the destination host requires to contact the originator. Destination. Port to connect to on the destination. Length. Number of bytes in the datagram, including the UDP header and the data. Checksum. The 16-bit 1’s complement of the 1’s complement sum of the IP header, the UDP header, the data (which, if necessary, is padded with zero bytes at the end, to make an even number of bytes). Connection and ACK’s UDP sends data packets that are not acknowledged. It is thus unreliable, as the sender cannot tell if the data has been received and the receiver does not know if there has been a loss of packets. There is also no connection, so the sender does even know if the receive is even receiving data Data stream TCP sends back acknowledgements to accept data that has been sent. The receiver can also tell if there are any lost packets, or if the remote computer has crashed, and has been restarted.
10.6 Server applications listening for TCP ports TELNET server listens for port 23 FTP server listens for port 21 Input TCP packets with port number HTTP server listens for port 80 Server SMTP server listens for port 161
10.7 Standard TCP ports Port Service Comment Port Service Comment 1 TCPmux 7 echo 9 discard Null 11 systat Users 13 daytime 15 netstat 17 qotd Quote 18 msp Message send protocol 19 chargen ttytst source 21 ftp 23 telnet25 smtp Mail 37 time Timserver 39 rlp Resource location 42 nameserver IEN 11643 whois Nicname 53 domain DNS 57 mtp Deprecated 67 bootps BOOTP server 67 bootps 68 bootpc BOOTP client 69 tftp 70gopher Internet Gopher 77 rje Netrjs 79 finger80 www WWW HTTP 87 link Ttylink 88 kerberos Kerberos v5 95 supdup 101 hostnames 102 iso-tsap ISODE 105 csnet-ns CSO name server 107 rtelnet Remote Telnet 109 pop2 POP version 2 110pop3 POP version 3 111 sunrpc 113 auth Rap ID 115 sftp 117 uucp-path 119 nntp USENET 123 ntp Network Timel 137 netbios-ns NETBIOS Name Service 138 netbios-dgm NETBIOS 139 netbios-ssn NETBIOS session 143 imap2 161 snmp SNMP 162 snmp-trap SNMP trap 163 cmip-man ISO management over IP 164 cmip-agent 177 xdmcp X Display Manager 178 nextstep NeXTStep 179 bgp BGP 191 prospero 194 irc Internet Relay Chat 199 smux SNMP Multiplexer 201 at-rtmp AppleTalk routing