Skip to content

โครงงานเขียนโปรแกรม Reliable File Transfer over UDP

kheetapatt/socket-programming-file-transfer-udp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Socket Programming: Reliabel File Transfer over UDP


วิธีการ Compile

  1. compile server ด้วย command line:
javac Server.java
  1. compile client ด้วย command line:
javac Client.java

หมายเหตุ: Compile Server กับ Client บน Terminal ที่แยกกัน


วิธีการ Run

  1. บน Terminal ของ Server
    Run server ด้วย command line:
java Server <port>
  1. บน Terminal ของ Client
    Run client ด้วย command line:
javac Client <server_ip> <port> <filename>

วิธีการ Test

  1. Server จะมี file ให้ทดสอบได้แก่ file1.txt, file2.txt, file3.txt ให้ทำการ run เพื่อให้ client request file ด้วย filename ดังกล่าว
  2. เมื่อ client ส่ง request แล้ว server จะรับ request และส่ง packet ของ file ให้\
  • กรณีไม่มี packet loss.

Terminal ของ server จะแสดงผลดังนี้

Client requested: file1.txt
Send packet: 0
Got ack: 0
Send packet: 1
Got ack: 1
Send packet: 2
Got ack: 2
Send packet: 3
Got ack: 3
Send packet: 4
Got ack: 4
Send packet: 5
Got ack: 5
Send packet: 6
Got ack: 6
Send packet: 7
Got ack: 7
Send packet: 8
Got ack: 8
Send packet: 9
Got ack: 9
Send packet: 10
Got ack: 10
Complete sending file

Terminal ของ client จะแสดงผลดังนี้

send ack: 0
send ack: 1
send ack: 2
send ack: 3
send ack: 4
send ack: 5
send ack: 6
send ack: 7
send ack: 8
send ack: 9
send ack: 10
Complete receiving file
  1. ใน folder ชื่อ client-folder จากเดิมที่เป็น folder เปล่า เมื่อได้รับ packet แล้วจะปรากฏ file ที่มีข้อมูลที่ถูกส่งมาจาก server

การจำลอง packet loss

สามารถจำลองโดยการระบุ loss rate ได้

  1. บน Terminal ของ Server
    Run server ด้วย command line:
java Server <port> <loss_rate>

เข่น

java Server 1234 0.2
  • หมายถึงให้จำลอง packet loss โดยสุ่ม drop packet ที่ drop rate เท่ากับ 0.2 (หากส่ง 10 packets จะถูก drop 2 packets)
  1. บน Terminal ของ Client ทำการ run ด้วย command line แบบเดิม

Terminal ของ server จะแสดงผลดังนี้ (ขึ้นอยู่กับ sequence number ของ packet ที่ loss)

Client requested: file1.txt
Send packet: 0
Got ack: 0
Send packet: 1
Got ack: 1
Send packet: 2
Got ack: 2
Simulated loss of packet seq 3
Timeout, resending seq 3
Simulated loss of packet seq 3
Timeout, resending seq 3
Send packet: 3
Got ack: 3
Send packet: 4
Got ack: 4
Simulated loss of packet seq 5
Timeout, resending seq 5
Send packet: 5
Got ack: 5
Send packet: 6
Got ack: 6
Send packet: 7
Got ack: 7
Send packet: 8
Got ack: 8
Send packet: 9
Got ack: 9
Send packet: 10
Got ack: 10
Complete sending file

Terminal ของ client จะแสดงผลดังนี้

send ack: 0
send ack: 1
send ack: 2
send ack: 3
send ack: 4
send ack: 5
send ack: 6
send ack: 7
send ack: 8
send ack: 9
send ack: 10
Complete receiving file
  1. ใน folder ชื่อ client-folder จะปรากฏ file ที่มีข้อมูลที่ถูกส่งมาจาก server

About

โครงงานเขียนโปรแกรม Reliable File Transfer over UDP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages