Scheduling algorithms in C++Algorithm scheduling is the process of determining which algorithm or line of code will be executed in the Central Processing Unit (CPU) and which one will be put on hold awaiting processing. In C + + programming, scheduling ensures that there is always an algorithm avail...
Transfer of Data Between Client and Server
Design Document
The idea of the project is to allow data transfer between server and client. A client can either upload a file or download a file from or to the server. Upload means data transfer is done from the client going to the server and download means data transfer is done from server to client. The protocol being used is UDP in which data are being sent in packets. It means that when we want to transfer a file, we have to break it down into packets and send them. It is not possible to send one big file as is to the network. UDP is a connectionless protocol. It means that there is no guarantee that all packets will be received by the receiver. In other words, file transfer can be faulty and unreliable. When packets get lost, the upload/download of the file is incomplete and the ending result is a corrupted file.
Server Class
The server class opens a port where to listen for incoming packets. When a packet arrives, it will be rebuilt as a “Message” object. The object contains details about the received data that came from a client. If the received message is for upload, the server will simply extract the file data and write it to a file. If the received message is for download, the server will check how far the client has already downloaded a file and then gets the next chunk of data and sends it back to the client.
Client Class
The client class gives the option to the user whether to upload or download a file. If the user wants to download a file, they have to enter a filename of a file that exists on the server. The client will keep track of how much data has already been collected. It will keep on sending the server these data as a "Message" object. The server will receive it and then knows the next chunk of data to give back to the client. The process repeats until the client receives all data that is needed and writes them to file. If the user wants to upload a file, the program will break down the file into chunks and then puts each chunk as a “Message” object. For every message, it sends it to the server to receive. The server will collect and get all these chunks of data and write it to a file.
Message Class
An object that contains details of a packet being transferred between client and server. These details include:
- Filename: Name of a file being uploaded or downloaded.
- File data: Partial bytes of data of a file that is currently being uploaded or downloaded.
- File data size: The size of the bytes of data being uploaded or downloaded.
- Expected File Size: This is only useful when performing a download. This information will let the downloader know how much data needs to be transferred.
- Downloaded File Size: This is only used when performing a download. This information will let the server know how much data has already been downloaded by the client.
- Type: Defines the type of message whether the data it contains is for “Upload” or “Download”.