diff --git a/Protocol.cpp b/Protocol.cpp index 321b3c40e49e231c0a263af53751503dc17dfc5b..1cec1b89241eaa7b4b6179e5e6974f5530239fc8 100644 --- a/Protocol.cpp +++ b/Protocol.cpp @@ -154,7 +154,13 @@ void Protocol::transmit(int sockt, int window){ printf("astoi %i\n", response.getMessages().back().getDataAsString()[0]); int ackIndex = response.getMessages().back().getDataAsString()[0]; for(int j=0; j < frame.size();) { - if(frame[j].index <= ackIndex) { + cout << "ackIndex: " << ackIndex << "frame[j].index: " << frame[j].index << endl; + if(ackIndex == 0) { + if((frame[j].index % (MAXSIZE+1)) == 62 || (frame[j].index % (MAXSIZE+1)) == 63 || (frame[j].index % (MAXSIZE+1)) == 0) { + frame.erase(frame.begin() + j); + --messagesLeft; + } else ++j; + } else if((frame[j].index % (MAXSIZE+1)) <= ackIndex) { frame.erase(frame.begin() + j); --messagesLeft; } else ++j; diff --git a/test.sh b/test.sh index 710caf57de84d744cd4841144b90339e6e04b72f..7364b6d98efda0d483d79604dd54b26c2136459c 100755 --- a/test.sh +++ b/test.sh @@ -1,5 +1,7 @@ #!/bin/bash +rm 10.txt 100.txt 1000.txt + for i in {1..10} do echo -e "$i\n">>10.txt