UHACC Presentation: The TCP Protocol (Presentation discussion points) by Chuck Geigner, 13 Oct 2005 ## The TCP protocol is written up in RFC's 793 (http://www.rfc-editor.org/rfc/rfc792.txt)and 1122 It defines the rules for sturdy, synchronous data communications between two hosts (on top of IP). TCP + guarantees packets are reassembled in the correct order at the terminus + detects and retransmits lost packets + performs error checking on packets ## Sockets (sys/socket.h) outgoing: use connect() incoming: bind() to a local address and port #, and listen() for incoming connection, and accept() incoming connection requests 2 types: stream (SOCK_STREAM, TCP) datagram (SOCK_DGRAM, UDP - doesn't connect() topic for another day :)) C sockets programming HOWTO http://beej.us/guide/bgnet/output/htmlsingle/bgnet.html ## TCP flags and how the connection is established/torn down: Handshake: SYN - request for new connection, initial sequence number, maximum segment size in bytes and receive buffer size, also in bytes SYN/ACK - acknowledgement + suggested TCP sequence number ACK - TCP sequence number(+1) acknowledgement (acknowledge data) Data transfer: PSH - push data URG - urgent datagram (see below) Terminate: FIN - final, close connection RST - reset connection ##Features: + Time to Live (TTL): There is a TTL field in each packet which is decremented at each hop until the packet reaches its destination or the count reaches zero, whichever occurs first. Once the TTL reaches zero, it will notify the source host via the Time Exceeded Message (0 - TTL exceeded in transit; 1 - fragment reassembly time exceeded). + Header Checksum : The checksum is used to determine the integrity of the sent packet. According to the RFC, the method is: "The 16 bit one's complement of the one's complement sum of all 16 bit words in the header. For computing the checksum, the checksum field should be zero." + Parameter Problem Message: If a gateway or destination host detects a problem with a parameter in a datagram header that causes it to reject it, it can return a pointer to the errored header portion. + Source Quench: Source quench requests will be sent from gateways that run out of buffer space and discard packtes before they can send them on to the next hop. The origin will reduce the outgoing packet rate until it receives no more source quench messages. Once the origin ceases to receive source quench messages, it will then automatically increase the rate gradually until it begins to receive them again. This mechanism allows a live transmission to automatically adapt to changing network conditions and achieve maximum transfer rate between endpoints. + TCP supports urgent data. Flag for this is MSG_OOB Urgent data is used to signal the receiver that some important message is part of the data stream and that it should be processed as soon as possible. EOF