TCP:Transmission Control Protocol
TCP is a network transport Internet Protocol typically used for its bidirectional communications reliability.
TCP is a protocol which first establishes a connection and then transmits data over that connection. Replies of acknowledgement are sent to each end of the connection to communicate the fact that the transmitted data was valid to determine if the data should be re-sent.
The TCP header is 24 bytes of information including the source and destination port, the packet sequence information, checksum and various flags indicating the purpose of the packet.
TCP is a streaming protocol where a numbered set of packets are sent over the network and available to the system in-order.
This makes TCP appropriate for file transfer and web content delivery.
UDP:User Datagram Protocol
UDP is a protocol which supports a single packet of data with no response, verification or acknowledgement.
A checksum is included in the UDP packet header but the protocol does not arrange for retransmission upon error.
It is a faster communications method as it does not require the overhead of a connection, reliability or packet order.
Each packet is independent of the other and typically used for data no larger than the maximum UDP packet size of 64 Kb (65507 bytes) for the 8 byte header and data, but typically much smaller.
IPv4 Packet Headers:
TCP:
-
Flags:Source Port
16 bits
(0 - 65535)Destination Port
16 bits
(0 - 65535)Sequence Number
32 bits
(0 - 4294967295) Increments from 1, zero to clear.Acknowledgement Number
32 bits
(0 - 4294967295)Data
OffsetRes N
S
C
W
RE
C
EU
R
GA
C
KP
S
HR
S
TS
Y
NF
I
NWindow
16 bitsChecksum
16 bitsUrgent Pointer
(If URG is set)
16 bitsOptions Padding - SYN: signifies first packet sent when opening a connection
- ACK: After SYN packet is sent, ACK is set to 1
- RST: Request to reset the connection
- FIN: Last packet - transmission done
UDP:
-
Source Port
16 bits
(0 - 65535)Destination Port
16 bits
(0 - 65535)Length
(entire datagram: header and data)
16 bits
(8 - 65535)Checksum
(If not used - all zeros)
16 bits