📄 tcpandudp.txt
字号:
F:\SSD8\exercise3>java DatagramClient localhost
The average round trip time is 0.078
The number of lost packets is: 0
F:\SSD8\exercise3>java TCPClient localhost
The average round trip time is 1.688
The number of lost packets is: 0
F:\SSD8\exercise3>java TCPClient I3
The average round trip time is 2.047
The number of lost packets is: 0
F:\SSD8\exercise3>java DatagramClient I3
The average round trip time is 0.172
The number of lost packets is: 0
F:\SSD8\exercise3>ping 192.168.0.3
Pinging 192.168.0.3 with 32 bytes of data:
Reply from 192.168.0.3: bytes=32 time<1ms TTL=64
Reply from 192.168.0.3: bytes=32 time<1ms TTL=64
Reply from 192.168.0.3: bytes=32 time<1ms TTL=64
Reply from 192.168.0.3: bytes=32 time<1ms TTL=64
Ping statistics for 192.168.0.3:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
When I run the datagramClient on my machine and datagramServer on a friend's machine whose name is I3 and IP address is 193.168.0.3, the round trip time 0.172s.
However, using TCP, the round trip time is 2.047s.
And then, when I use ping to execute the command "ping 192.168.0.3", the round trip time is 0ms.
It should take one packet to send one byte over UDP.
It should take three packets to establish a TCP connection because of the three-way handshake.
It should take two packets to send one byte.
It should take two packets to close the connection.
The results of my tests are under my expect.
When I run the datagramClient and datagramServer on my machine, the round trip time is 0.078.
However, using TCP, the round trip time is 1.688s.
Using UDP, the round trip time is about half of the round trip time between two computers.
Using TCP, the round trip time is about the same to the round trip time between two computers.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -