// Place global declarations here.
const int HOSTS = 2;
// TIMEOUT Bounds
const int UBOUND = 600;
const int LBOUND = 10;
// sequence bounds
const int MAX_SEQ = 3;
chan Packet[HOSTS+1];
int target_address; //Global variable to pass the target address to the network
typedef struct {
int syn;
int ack;
} TCP_packet;
void initialize(TCP_packet& p)
{
p.syn := 0;
p.ack := 0;
}
TCP_packet packet;Networkconst int networkint target; // the target for the current network packet
TCP_packet transfer;
void set_target() {
target = target_address;
}
void receive_packet(){
transfer := packet;
}
void send_packet(){
packet := transfer;
}
PacketLostPacketInTransitReadyToReceiveHost_Handshakeconst int local, const int remote, const int networkclock c;
int last_syn = 0;
int last_ack = 0;
TCP_packet received;
void set_target(int syn, int ack) {
target_address = remote;
packet.syn = syn;
packet.ack = ack;
}
void receive_packet(){
received = packet;
}
int update_syn(){
last_syn = (last_syn % MAX_SEQ) +1;
return last_syn;
}
int update_ack(){
last_ack = received.syn;
return last_ack;
}
void initialize()
{
last_syn := 0;
last_ack := 0;
}EstablishedSynRcvdSynSentListenClosedNetwork1 = Network(0);
Network2 = Network(0);
Network3 = Network(0);
Network4 = Network(0);
Host1Handshake = Host_Handshake(1,2,0);
Host2Handshake = Host_Handshake(2,1,0);
system Network1, Network2 ,Host1Handshake,Host2Handshake;