Adding ACKs to Simplex-Talk
This project is for those with undergraduate registration; that is, those
who are registered for Comp 343.
I have modified stalkc.java and stalks.java to support message
numbers: a 16-bit field at the start of each packet. The format
of each message packet is now as follows:
+-------------+-----------------------+
|16 bit msg_id| string |
+-------------+-----------------------+
The format of the ACK packet is this (there is no other "header"):
+-------------+
|16 bit msg_id|
+-------------+
The new files are here:
You are to implement acknowledgements. The server should send a packet
consisting of just the 16-bit message_id. The client should not send a new
message until the server has acknowledged the previous one. The client
should time out and retransmit the previous message if it has not received
an acknowledgement within 2.0 seconds.
The server should, in principle, be able to handle two clients
simultaneously, sending appropriate ACKs to each.
The files above provide getmsgnum(byte
[]) and setmsgnum(byte[],
short). These assume that the architecture uses little-endian byte
order. That includes Intel; if anyone is working on anything else, let me
know.
For testing, you will probably want to run both the client and the server on
the same machine. To this end, the default destination for the client is localhost.
In a separate file, answer these questions:
- If a client stops and is restarted, it will resume with message_id =
1. Can this be a problem?
- Any packet coming back from the server can be assumed to be an
acknowledgement. Are there any potential problems with this assumption?
- Will this acknowledgement version of the protocol work through a NAT
firewall?