TCP

TCP - Programmer Sheet

Phase 1: 3-way handshake is completed & trust relationship is built b/w Sender/Rec

Phase 2: The connection is opened and the participant devices start sending data using the agreed sequence and acknowledge numbers that have been agreed in phase

Phase 3: connection is terminated with FIN flags once all Data transfer is completed

TCP States
State Description
CLOSED In-active or Initial state where not TCP activity has begun yet
LISTEN The device is waiting for contact request
SYN-SENT The device waits to receive an ACK to the SYN it has sent to the other side
SYN+ACK SENT The device sends an ACK that it has received the SYN. Also, it sends its own SYN request & waits to receive an ACK from the other SENT side
SYN RCVD The device has received the SYN for the ACK it sent previously
ESTABLISHED Handshake has been Completed Established & the device is ready for data transfer now
TCP Message Types
Message Description
SYN (synchronize message) Used to initiate and establish a connection. It is used to synchronize sequence numbers between devices.
SYN bit =1 in the TCP Header
ACK (Acknowledgement message) Used to confirm to the other side that it has received the SYN
ACK bit =1 in the TCP Header
SYN-ACK (Synchronize & Ack message) SYN message from local device & ACK of the previous packet.
SYN bit =1, ACK bit=1 in the TCP Header
FIN (Finish) Used to terminate a connection. FIN bit =1 in the TCP Header

TCP Calls

Active OPEN A device using TCP takes the active role and initiates the connection by sending a TCP SYN message to start the connection. The Device in Active OPEN state is called Client

Passive OPEN Device is waiting for an active OPEN from other. It does not generate any TCP message segment. The Device in Passive OPEN state is called Server

Transport Layer Ports
Category Range Comments
Well known ports 0-1023 Used by system processes e,g FTP(21)
Registered Ports 1024-49151 For special services e,g Port 8080
Private Ports 49152-65535 For Private Purposes
Important TCP/UDP Ports
Port Number Protocol Application
20 TCP FTP data
21 TCP FTP Control
22 TCP SSH
23 TCP Telnet
25 TCP SMTP
53 UDP, TCP DNS
67,68 UDP DHCP
69 UDP TFTP
80 TCP HTTP (WWW)
110 TCP POP3
161 UDP SNMP
443 TCP SSL