The second issue is in regards of error control.
As UDP doesn’t implement any error control the file could potentially be corrupted when it arrives and be accepted, or just discarded. Using stop and wait, if the packet is discarded, it could be resubmitted by the server when it times out causing an issue similar to the one noted above. However, as the data isn’t sequenced, if it is accepted, this could potentially cause unintended results in the file being read correctly. This sequencing issue could also be an issue if there are multiple “sets” of packets arriving at intermittent intervals. Some sort of protocol would need to be used to either correctly sequence packets as they leave and arrive and handle any errors correctly.
It would seem like the ideal thing to do for a file transfer would be to instead use TCP to remove several of the issues that you’re trying to compensate for by using the stop and wait with
UDP.