Write C++ code that will convert files into a queue of packets and reassemble a queue of packets back into the original file. Both of these functions will be used in homework 8 where we will simulate sending files through a network as packets and reassembling them at their destinations.
File to Packets (1 point)
Implement this function in fileToPackets.cpp which takes a file and max payload and returns a queue of packets containing all the data of the file with no packet containing more than maxPayloadSize number of bytes in its payload which is stored as a vector of chars. Each packet will also store the original filename as well as a sequence number which maintains the order in which the packets will be reassembled.
File to Packets Program (1 point)
Write a main function in FileToPackets.cpp that will be used with these command line parameters and will save a queue of packets generated from the input file and save it as the output file. To accomplish this you should call the fileToPackets function from the previous part to convert the file to packets, then call the savePackets functions provided in the Packet.cpp/h files which saves the queue to disk.
This part will be checked by running the a.out generated by the following compiler call:
Packets to File (1 point)
Implement packetsToFile to reassemble a file from a queue of packets. This is effectively the reverse operation as fileToPackets. You can assume that the packets are all given in sequence and you should combine the payload of each packet into a vector of chars with all the contents of the original file.
Packets to File Program (1 point)
Write a main function in PacketsToFile.cpp that will be used with these command line parameters and will read the input file as a queue of packet using the provided loadPackets functions and reassembles the original file by calling packetsToFile. The reassembled file will be saved as the output file.
This part will be checked by running the a.out generated by the following compiler call: