hw2: preparing for submission

This commit is contained in:
Claudio Maggioni (maggicl) 2020-05-08 14:29:08 +02:00
parent 059c627b29
commit 822f17e264
2 changed files with 21 additions and 3 deletions

View file

@ -1,3 +1,14 @@
/*
* GBNTReceiver - Claudio Maggioni (2020)
* NTW2020 HW2
*
* No external source was used to create this file, other than regular course material.
*
* Note on implementation: change value of constant RECEIVER_TIMEOUT_MS to change the
* value of the receiver disconnection timeout.
*/
package impl; package impl;
import transport.Receiver; import transport.Receiver;
@ -47,7 +58,6 @@ public class GBNTReceiver extends Receiver implements TimeoutAction {
@Override @Override
protected void unreliableReceive(byte[] bytes, int offset, int length) { protected void unreliableReceive(byte[] bytes, int offset, int length) {
if (state == State.CLOSED) return; if (state == State.CLOSED) return;
//System.out.println("State: " + state + " receiving: " + length);
cancelTimeout(this); cancelTimeout(this);
setTimeout(RECEIVER_TIMEOUT_MS, this); setTimeout(RECEIVER_TIMEOUT_MS, this);
switch(this.state) { switch(this.state) {

View file

@ -1,3 +1,13 @@
/*
* GBNTSender - Claudio Maggioni (2020)
* NTW2020 HW2
*
* No external source was used to create this file, other than regular course material.
*
* Note on implementation: change value of constant W to change the size of the otherwise
* fixed window.
*/
package impl; package impl;
import transport.TimeoutAction; import transport.TimeoutAction;
@ -27,8 +37,6 @@ public class GBNTSender extends transport.Sender implements TimeoutAction {
private final Map<Character, Packet> packetMap = new HashMap<>(); private final Map<Character, Packet> packetMap = new HashMap<>();
private Semaphore s = new Semaphore(0); private Semaphore s = new Semaphore(0);
private static final int MAX_PACKET_SIZE = 128;
private class Packet { private class Packet {
private final byte[] contents; private final byte[] contents;
private final char sequence; private final char sequence;