Commit 4611c703 authored by Paul Fiterau's avatar Paul Fiterau
Browse files

Fixed and beautified server

parent 093e6f5e
......@@ -22,7 +22,7 @@ public class Packet implements TCPMessage {
}
public int payload() {
return (flags.has(Flag.FIN)? 0 : 1) + (flags.has(Flag.SYN)? 0 : 1);
return (flags.has(Flag.FIN)? 1 : 0) + (flags.has(Flag.SYN)? 1 : 0);
}
public String toString() {
......
......@@ -46,7 +46,6 @@ public class TCPMapper {
public TCPMapper() {
this( new FunctionalInitOracle());
//this( new CachedInitOracle(new InitCacheManager("/home/student/GitHub/tcp-learner/output/1421437324088/cache.txt")));
}
public TCPMapper(InitOracle oracle) {
......@@ -197,11 +196,7 @@ public class TCPMapper {
if (this.isInit == true) {
nextAck = Calculator.newValue();
} else {
if (this.lastPacketReceived != null) {
nextAck = Calculator.nth(this.serverSeq, this.lastPacketReceived.payload());
} else {
nextAck = this.serverSeq;
}
nextAck = Calculator.next(this.serverSeq);
}
return nextAck;
}
......@@ -221,10 +216,10 @@ public class TCPMapper {
Symbol abstractAck = getAbstract(concreteAck);
/* do updates on output */
if (abstractAck == Symbol.SNCLIENTP1 || abstractAck == Symbol.SNCLIENTPD) {
if (isInit || this.lastPacketSent.payload() + this.clientSeq == concreteAck) {
this.clientSeq = concreteAck;
}
if (abstractSeq == Symbol.FRESH || abstractSeq == Symbol.SNSERVERP1) {
if (isInit || (this.lastPacketReceived != null && this.lastPacketReceived.payload() + this.serverSeq == concreteSeq )) {
this.serverSeq = concreteSeq;
}
......@@ -320,14 +315,6 @@ public class TCPMapper {
String abstractOutput = processIncomingResponse(flags, seq, ack);
return abstractOutput;
}
/*public static void main(String[] args) {
TCPMapper mapper = new TCPMapper(null);
for (int i = 0; i < 1000; i++) {
System.out.println(mapper.newInvalidOutsideWindow(10000));
System.out.println(mapper.newInvalidWithinWindow(10000));
}
}*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
......@@ -354,4 +341,5 @@ public class TCPMapper {
*/
return sb.toString();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment