TCP vs UDP

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:

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
Offset
ResN
S
 
C
W
R
E
C
E
U
R
G
A
C
K
P
S
H
R
S
T
S
Y
N
F
I
N
Window
16 bits
Checksum
16 bits
Urgent Pointer
(If URG is set)
16 bits
OptionsPadding

Flags:
  • 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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值