Program 3, Sending Photos to a Concurrent Photo Server, for WPI CS 3516 B01.
By Ben McMorran and Gordon Gao
This program simulates the application, network, datalink and physical layers.
Each layer lives in its own file: client/server.c, network.c, data_link.c, and physical.c respectively.
The network layer proceeds to send a request to the datalink and then physical layer to establish a TCP connection with the server. The physical layer is simulated using a TCP connection. An initial packet is sent to establish this connection containing the client id and number of photos.
The client parses through the photo jpg files to send 200 bytes of data to the network layer. The network layer encapsulates this payload in a packet, including packet type, length, and end of photo fields and then sends it to the datalink layer. The datalink encapsulates it with sequence number, end of packet, length, and error detection fields. It sends it to the physical layer which sends it to the server physical layer. It then proceeds back up the stack on ther server.
The server sends a ACK frame at the datalink layer and then a network ack at the network layer, which itself is encapsulated inside a data frame. It stores the payload of the image data packet into the correct file based on client id.
SELECT is used in this program to properly implement timeouts. See physical.c line 137. It waits after sending a frame and resends if an ACK is not received within an appropriate timeout interval.
Duplicate frames are handled by this program. See data_link.c line 193. Duplicate frames are ACKed, but dropped.
Sequence numbers are only increased after sucessfully receving a new ACK or data frame.
While this code has error handling functions, including timeouts and duplicate frame handling, there are still subtle issues with our handling of corrupted frames. Because of this, corruption is turned off by default in our application to ensure successful photo transfer. However, corruption functions are present and error detection works correctly, including XOR folding and verification.