Updated sequence number stuff
This commit is contained in:
parent
cedf077c34
commit
eeffc10d9e
@ -50,40 +50,43 @@ receive_packet(),
|
|||||||
c:=0</label><nail x="-5440" y="-1408"/><nail x="-5440" y="-1664"/></transition></template><template><name>Host_Handshake</name><parameter>const int local, const int remote, const int network</parameter><declaration>clock c;
|
c:=0</label><nail x="-5440" y="-1408"/><nail x="-5440" y="-1664"/></transition></template><template><name>Host_Handshake</name><parameter>const int local, const int remote, const int network</parameter><declaration>clock c;
|
||||||
meta int snd_una = 0;
|
meta int snd_una = 0;
|
||||||
meta int snd_nxt = 0;
|
meta int snd_nxt = 0;
|
||||||
meta int seg_ack = 0;
|
meta int snd_ack = 0;
|
||||||
meta int seg_len = 0;
|
|
||||||
meta int rcv_nxt = 0;
|
meta int rcv_nxt = 0;
|
||||||
|
const int seg_len = 0;
|
||||||
|
const int window = 1;
|
||||||
meta TCP_segment retrans;
|
meta TCP_segment retrans;
|
||||||
meta TCP_segment received;
|
meta TCP_segment received;
|
||||||
|
|
||||||
bool receive_packet(){
|
bool receive_packet(){
|
||||||
|
if (from_network.syn) {
|
||||||
|
rcv_nxt = from_network.seqNr;
|
||||||
|
}
|
||||||
|
if (rcv_nxt == from_network.seqNr) {
|
||||||
|
if (received.ack && snd_una < from_network.ackNr) {
|
||||||
|
snd_una = from_network.ackNr;
|
||||||
|
}
|
||||||
|
else if (received.ack) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
received := from_network;
|
received := from_network;
|
||||||
snd_nxt = received.ackNr;
|
snd_nxt = received.ackNr + 1;
|
||||||
seg_ack = (received.seqNr + 1 + len)%MAX_SEQ;
|
snd_ack = (received.seqNr + 1 + seg_len)%MAX_SEQ;
|
||||||
|
|
||||||
initialize(from_network);
|
initialize(from_network);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
int update_win(){
|
return false;
|
||||||
//TODO: do something usefull.
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset()
|
|
||||||
{
|
|
||||||
last_seq := 0;
|
|
||||||
last_ack := 0;
|
|
||||||
initialize(retrans);
|
|
||||||
initialize(received);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void send(bool syn, bool ack) {
|
void send(bool syn, bool ack) {
|
||||||
|
if (syn) {
|
||||||
|
snd_una := snd_nxt;
|
||||||
|
}
|
||||||
target_address = remote;
|
target_address = remote;
|
||||||
retrans.syn := syn;
|
retrans.syn := syn;
|
||||||
retrans.ack := ack;
|
retrans.ack := ack;
|
||||||
retrans.seqNr := snd_nxt;
|
retrans.seqNr := snd_nxt;
|
||||||
retrans.ackNr := seq_ack;
|
retrans.ackNr := snd_ack;
|
||||||
retrans.win := update_win();
|
retrans.win := window;
|
||||||
to_network := retrans;
|
to_network := retrans;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user