您的位置:首页 > 理论基础 > 计算机网络

TCP vs UDP

2014-04-26 22:25 246 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: