/// <summary> /// Receive Data Block from the TFTP server. RRQ_SENT or ACK_SENT --> DATA_RECEIVED. /// </summary> /// <param name="rcvBuffer">the receiving buffer for return.</param> /// <returns> /// A int variable that tell the length of the receiving buffer. /// </returns> public static void receiveDataBlock() { byte[] rcvBuffer; client.receiveDataBlock(out rcvBuffer); state = client.tftpClientMode; }
static void canPutExit(int len) { if (len < 516) { state = TFTPClient.FSM_Modes.EXIT; } }
/// <summary> /// Receive ACK from the server. WRQ_SENT or DATA_SENT --> ACK_RECEIVED /// </summary> /// <param name="rcvBuffer">The receiving buffer.</param> /// <returns> /// A int variable that tell the length of the receiving buffer. /// </returns> public static void receiveACK() { byte[] rcvBuffer; client.receiveACK(out rcvBuffer); state = client.tftpClientMode; }
public static void checker(TFTPClient.FSM_Modes tftpMode) { if (tftpMode != state) { TFTPClient.FSM_Modes stateCopy = state; state = TFTPClient.FSM_Modes.INIT; Assert.AreEqual(tftpMode, stateCopy, "State mismatch: Model vs Implementation"); } }
public static void checker(TFTPClient.FSM_Modes tftpMode) { if (tftpMode != state) { TFTPClient.FSM_Modes stateCopy = state; state = TFTPClient.FSM_Modes.INIT; Assert.AreEqual(tftpMode, stateCopy, "State mismatch: Model vs Implementation"); } }
static bool CanPutExit(int len) { Condition.IsTrue(mode == TFTPClient.FSM_Modes.DATA_SENT); if (len < 516) { mode = TFTPClient.FSM_Modes.EXIT; return true; } return false; }
/// <summary> /// Send Write Request. Create the WRQ packet, send it to the server. INIT --> WRQ_SENT. /// </summary> /// <param name="remoteFile">The remote file.</param> /// <param name="localFile">The local file.</param> /// <param name="tftpMode">The TFTP mode.</param> /// <param name="sndBuffer">The returned sending buffer.</param> public static void sendWriteRequest() { string localFile = "C:\\Users\\Matt McCormick\\Documents\\Schoolwork\\cs490st\\project01\\SpecExplorer2\\local.txt"; BinaryReader fileStream = new BinaryReader(new FileStream(localFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)); byte[] sndBuffer; client.sendWriteRequest("remote.txt", "local.txt", TFTPClient.Modes.NetAscii, out sndBuffer); state = client.tftpClientMode; }
static void ReceiveACK() { Condition.IsTrue(mode == TFTPClient.FSM_Modes.WRQ_SENT || mode == TFTPClient.FSM_Modes.DATA_SENT); mode = TFTPClient.FSM_Modes.ACK_RECEIVED; }
static void Initialize() { mode = TFTPClient.FSM_Modes.INIT; }
/// <summary> /// Send Read Request. It creates the TFTP read request packet, send the packet. INIT --> RRQ_SENT. /// </summary> /// <param name="remoteFile">The remote file.</param> /// <param name="localFile">The local file.</param> /// <param name="tftpMode">The TFTP mode, NetAscii, Octet, Mail.</param> public static void sendReadRequest() { client.sendReadRequest("remote.txt", "local.txt", TFTPClient.Modes.NetAscii); state = client.tftpClientMode; }
/// <summary> /// check whether it is time to successfully exit. If yes, current state --> EXIT; otherwise, keep the current state unchanged. /// </summary> /// <param name="len">The length of the sending buffer.</param> /// <returns> /// A bool variable indicating whether it is time to successfully exit. It is TRUE for successfully exit, FALSE for staying in the loop and continuing the file transfer. /// </returns> public static void canPutExit(int len) { client.canPutExit(len); state = client.tftpClientMode; }
/// <summary> /// Send Read Request. It creates the TFTP read request packet, send the packet. INIT --> RRQ_SENT. /// </summary> /// <param name="remoteFile">The remote file.</param> /// <param name="localFile">The local file.</param> /// <param name="tftpMode">The TFTP mode, NetAscii, Octet, Mail.</param> public static void sendReadRequest() { client.sendReadRequest("remote.txt", "local.txt", TFTPClient.Modes.NetAscii); state = client.tftpClientMode; }
static void SendWriteRequest() { Condition.IsTrue(mode == TFTPClient.FSM_Modes.INIT); mode = TFTPClient.FSM_Modes.WRQ_SENT; }
static void receiveACK() { Condition.IsTrue(state == TFTPClient.FSM_Modes.WRQ_SENT || state == TFTPClient.FSM_Modes.DATA_SENT); state = TFTPClient.FSM_Modes.ACK_RECEIVED; }
static void sendACK() { Condition.IsTrue(state == TFTPClient.FSM_Modes.DATA_RECEIVED); state = TFTPClient.FSM_Modes.ACK_SENT; }
static void initialize() { state = TFTPClient.FSM_Modes.INIT; }
/// <summary> /// check whether it is time to successfully exit. If yes, current state --> EXIT; otherwise, keep the current state. /// </summary> /// <param name="len">The length of receving buffer.</param> /// <returns> /// A bool variable indicating whether it is time to successfully exit. It is TRUE for successfully exit, FALSE for staying in the loop and continuing the file transfer. /// </returns> public static void canGetExit(int len) { client.canGetExit(len); state = client.tftpClientMode; }
/// <summary> /// Send ACK packet to the TFTP server, after successfully receive the data block from the TFTP server. DATA_RECEIVED --> ACK_SENT. /// </summary> public static void sendACK() { client.sendACK(); state = client.tftpClientMode; }
static void sendReadRequest() { Condition.IsTrue(state == TFTPClient.FSM_Modes.INIT); state = TFTPClient.FSM_Modes.RRQ_SENT; }
static void ReceiveDataBlock() { Condition.IsTrue(mode == TFTPClient.FSM_Modes.RRQ_SENT || mode == TFTPClient.FSM_Modes.ACK_SENT); mode = TFTPClient.FSM_Modes.DATA_RECEIVED; }
/// <summary> /// Initialze the TFTP client. Set the state to be INIT /// </summary> public static void initialize() { client.initialize(); state = client.tftpClientMode; }
static void SendDataBlock() { Condition.IsTrue(mode == TFTPClient.FSM_Modes.ACK_RECEIVED); mode = TFTPClient.FSM_Modes.DATA_SENT; }
static void initialize() { state = TFTPClient.FSM_Modes.INIT; }
/// <summary> /// Send ACK packet to the TFTP server, after successfully receive the data block from the TFTP server. DATA_RECEIVED --> ACK_SENT. /// </summary> public static void sendACK() { client.sendACK(); state = client.tftpClientMode; }
static void sendDataBlock() { Condition.IsTrue(state == TFTPClient.FSM_Modes.ACK_RECEIVED); state = TFTPClient.FSM_Modes.DATA_SENT; }
/// <summary> /// Send Write Request. Create the WRQ packet, send it to the server. INIT --> WRQ_SENT. /// </summary> /// <param name="remoteFile">The remote file.</param> /// <param name="localFile">The local file.</param> /// <param name="tftpMode">The TFTP mode.</param> /// <param name="sndBuffer">The returned sending buffer.</param> public static void sendWriteRequest() { string localFile = "C:\\Users\\Matt McCormick\\Documents\\Schoolwork\\cs490st\\project01\\SpecExplorer2\\local.txt"; BinaryReader fileStream = new BinaryReader(new FileStream(localFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)); byte[] sndBuffer; client.sendWriteRequest("remote.txt", "local.txt", TFTPClient.Modes.NetAscii, out sndBuffer); state = client.tftpClientMode; }
static void checker(TFTPClient.FSM_Modes tftpMode) { Condition.IsTrue(state == tftpMode); }
static void sendWriteRequest() { Condition.IsTrue(state == TFTPClient.FSM_Modes.INIT); state = TFTPClient.FSM_Modes.WRQ_SENT; }
/// <summary> /// Initialze the TFTP client. Set the state to be INIT /// </summary> public static void initialize() { client.initialize(); state = client.tftpClientMode; }
static void receiveDataBlock() { Condition.IsTrue(state == TFTPClient.FSM_Modes.RRQ_SENT || state == TFTPClient.FSM_Modes.ACK_SENT); state = TFTPClient.FSM_Modes.DATA_RECEIVED; }
static void canPutExit(int len) { if (len < 516) state = TFTPClient.FSM_Modes.EXIT; }