Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/prempreetbrar/udpfiletransferrer
A stop-and-wait reliable data transfer FTP client based on UDP.
https://github.com/prempreetbrar/udpfiletransferrer
ack demultiplexing ftp-client handshake java network-programming reliable-data-transfer retransmission sequence-number socket-programming stop-and-wait tcp timer udp
Last synced: 2 days ago
JSON representation
A stop-and-wait reliable data transfer FTP client based on UDP.
- Host: GitHub
- URL: https://github.com/prempreetbrar/udpfiletransferrer
- Owner: prempreetbrar
- Created: 2024-04-06T03:46:47.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-04-27T00:17:17.000Z (6 months ago)
- Last Synced: 2024-04-27T02:33:40.515Z (6 months ago)
- Topics: ack, demultiplexing, ftp-client, handshake, java, network-programming, reliable-data-transfer, retransmission, sequence-number, socket-programming, stop-and-wait, tcp, timer, udp
- Language: Java
- Homepage:
- Size: 26.7 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# UDP File Transferrer
A program that implements a simplified FTP client based on UDP; since UDP does not provide reliability, the
program implements its own reliability mechanism based on the stop-and-wait protocol. See a GIF of me using it below!![client](https://github.com/prempreetbrar/UDPFileTransferrer/assets/89614923/4b1e1710-01d0-44fd-a2a3-2cc7f1d48fde)
## Features
- Supports _sending_ a file to the server over UDP; before transmission, the client and server go through an initial handshake process
to exchange control information about the file transfer. The handshake takes place over TCP, while the actual file transfer is carried out
over UDP. See the following figure:
![image](https://github.com/prempreetbrar/UDPFileTransferrer/assets/89614923/8a966698-f6b0-4b0f-9171-c7733a819621)
- The TCP `Socket` is used to exchange information about the file name to be sent, its length, the initial sequence number, as well as the UDP port
number from the server.
- The provided file is read chunk-by-chunk; each chunk becomes the payload of an `FtpSegment` for transmission to the server; the `FtpSegment` itself is
encapsulated in a UDP `DatagramPacket` and then written to the UDP socket.
- The sequence number for segments starts at the _initial sequence number_ received from the server during the handshake process and is incremented per every
_segment_ transmitted (not byte, unlike TCP). The "ACK" packets received from the server as `DatagramPacket`'s carry the sequence number of the _next expected
segment_ at the server. The ACK `DatagramPacket`'s are de-encapsulated to `FtpSegment`'s in order to obtain the acknowledgment number.
- As soon as a segment is transmitted, the client starts a retransmission timer (as is typical of a stop-and-wait protocol). If the correct ACK arrives, the timer is
stopped. If the timer expires, the segment is retransmitted and the timer is restarted.
- The server terminates a file transfer session if it does not receive any UDP packets from the client during a certain amount of time; to prevent the client program
from waiting indefinitely for an ACK, the client aborts the file transfer if it does not receive an ACK within a _connection timeout_ period.## Usage/Limitations
### When Running the Client:
- `-i ` specifies the name of the file to be sent to the server; **REQUIRED**
- `-s ` specifies the hostname of the server (ex. cslinux.ucalgary.ca); defaults to `localhost`
- `-p ` specifies the port number of the server; note that this is the port number at which the server is running. This is DIFFERENT from the port number
used for the server's UDP socket. See the image below:
![image](https://github.com/prempreetbrar/UDPFileTransferrer/assets/89614923/ff566ec4-baa4-4919-983b-c3481a4d4061)
In the above image, you see a server process `P1` open a `DatagramSocket` with port number `6428`. Similarly, our server will open a `DatagramSocket` **at its own
chosen port number. The server's UDP Socket port number is DIFFERENT from the server's port number itself.**
- `-t ` specifies the time in milliseconds after which a segment is retransmitted if an ACK is not received; defaults to 1000 milliseconds (1 second).
### When Running the Server:
- `-p ` specifies the port number of the server; **the `-p` flags should match when running both the client and server. Otherwise the client will be unable
to connect.** Defaults to `2025`.
- `-i ` specifies the initial sequence number to be used by the server. This is communicated to the client during the TCP handshake process.
Defaults to `1`.
- `-d ` specifies the average amount of time the server will wait before sending each ACK; specified in milli-seconds. Default is `1`.
- `-l ` specifies the probability that the server will drop an arriving segment (to simulate packet loss which is typical in UDP-based transport). Default is `0.010` (1%).
- `-x ` specifies the sequence number of the segment to be dropped by the server; this is useful when debugging as you can force the server
to always drop a specific segment. Defaults to `-1` (no segment is forcefully dropped).
- `-t ` specifies the time in milliseconds after which the server will shutdown if it does not receive a `DatagramPacket` from the client. Default is `5000`.
- `-r ` specifies the seed for the random number generator; use the same seed every time to produce the same drop and delay results. Defaults to `13579`.## If you want to start up the project on your local machine:
1. Download the code as a ZIP:
![download](https://github.com/prempreetbrar/UDPFileTransferrer/assets/89614923/a801f9fd-6845-4cf5-925d-184af22a2357)
2. Unzip the code:
![unzip](https://github.com/prempreetbrar/UDPFileTransferrer/assets/89614923/4bda1763-0643-4a89-ae95-27ed07695752)
3. Open the folder in an IDE, such as VSCode:
![open](https://github.com/prempreetbrar/UDPFileTransferrer/assets/89614923/f93da787-8f29-41fd-b63a-d037249fe76d)
4. Start the server by running:
```
java -jar server/ftpserver.jar
[-p ]
[-i ]
[-d ]
[-l ]
[-x ]
[-t ]
[-r ]
```
![server](https://github.com/prempreetbrar/UDPFileTransferrer/assets/89614923/ee58b56e-0264-4ea6-a54c-cf956ce859b0)
5. Start the client by opening up a new terminal and running:
```
cd client
javac *.java
java StopWaitDriver -i client_files/
[-s ]
[-p ]
[-t ]
```
![client](https://github.com/prempreetbrar/UDPFileTransferrer/assets/89614923/571528aa-598d-4ff0-953f-9f891efa90d2)
6. The transmitted file will be saved in the parent directory of the server; feel free to interact with it:
![file](https://github.com/prempreetbrar/UDPFileTransferrer/assets/89614923/ed683b1f-e750-4a2c-ac41-fcd5a954d575)