Beispiel #1
0
        /// <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;
        }
Beispiel #2
0
 static void canPutExit(int len)
 {
     if (len < 516)
     {
         state = TFTPClient.FSM_Modes.EXIT;
     }
 }
Beispiel #3
0
        /// <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;
        }
Beispiel #4
0
        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");
            }
        }
Beispiel #5
0
        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");
            }
        }
Beispiel #6
0
 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;
 }
Beispiel #7
0
        /// <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;
        }
Beispiel #8
0
 static void ReceiveACK()
 {
     Condition.IsTrue(mode == TFTPClient.FSM_Modes.WRQ_SENT || mode == TFTPClient.FSM_Modes.DATA_SENT);
     mode = TFTPClient.FSM_Modes.ACK_RECEIVED;
 }
Beispiel #9
0
 static void Initialize()
 {
     mode = TFTPClient.FSM_Modes.INIT;
 }
Beispiel #10
0
        /// <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;
        }
Beispiel #11
0
        /// <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;
        }
Beispiel #12
0
        /// <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;
        }
Beispiel #13
0
 static void SendWriteRequest()
 {
     Condition.IsTrue(mode == TFTPClient.FSM_Modes.INIT);
     mode = TFTPClient.FSM_Modes.WRQ_SENT;
 }
Beispiel #14
0
 static void receiveACK()
 {
     Condition.IsTrue(state == TFTPClient.FSM_Modes.WRQ_SENT ||
                      state == TFTPClient.FSM_Modes.DATA_SENT);
     state = TFTPClient.FSM_Modes.ACK_RECEIVED;
 }
Beispiel #15
0
 static void sendACK()
 {
     Condition.IsTrue(state == TFTPClient.FSM_Modes.DATA_RECEIVED);
     state = TFTPClient.FSM_Modes.ACK_SENT;
 }
Beispiel #16
0
 static void initialize()
 {
     state = TFTPClient.FSM_Modes.INIT;
 }
Beispiel #17
0
        /// <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;
        }
Beispiel #18
0
        /// <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;
        }
Beispiel #19
0
 static void sendReadRequest()
 {
     Condition.IsTrue(state == TFTPClient.FSM_Modes.INIT);
     state = TFTPClient.FSM_Modes.RRQ_SENT;
 }
Beispiel #20
0
 static void ReceiveDataBlock()
 {
     Condition.IsTrue(mode == TFTPClient.FSM_Modes.RRQ_SENT || mode == TFTPClient.FSM_Modes.ACK_SENT);
     mode = TFTPClient.FSM_Modes.DATA_RECEIVED;
 }
Beispiel #21
0
        /// <summary>
        /// Initialze the TFTP client. Set the state to be INIT
        /// </summary>
        public static void initialize()
        {
            client.initialize();

            state = client.tftpClientMode;
        }
Beispiel #22
0
 static void SendDataBlock()
 {
     Condition.IsTrue(mode == TFTPClient.FSM_Modes.ACK_RECEIVED);
     mode = TFTPClient.FSM_Modes.DATA_SENT;
 }
Beispiel #23
0
 static void initialize()
 {
     state = TFTPClient.FSM_Modes.INIT;
 }
Beispiel #24
0
        /// <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;
        }
Beispiel #25
0
 static void sendDataBlock()
 {
     Condition.IsTrue(state == TFTPClient.FSM_Modes.ACK_RECEIVED);
     state = TFTPClient.FSM_Modes.DATA_SENT;
 }
Beispiel #26
0
        /// <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;
        }
Beispiel #27
0
 static void checker(TFTPClient.FSM_Modes tftpMode)
 {
     Condition.IsTrue(state == tftpMode);
 }
Beispiel #28
0
 static void sendWriteRequest()
 {
     Condition.IsTrue(state == TFTPClient.FSM_Modes.INIT);
     state = TFTPClient.FSM_Modes.WRQ_SENT;
 }
Beispiel #29
0
        /// <summary>
        /// Initialze the TFTP client. Set the state to be INIT
        /// </summary>
        public static void initialize()
        {
            client.initialize();

            state = client.tftpClientMode;
        }
Beispiel #30
0
 static void receiveDataBlock()
 {
     Condition.IsTrue(state == TFTPClient.FSM_Modes.RRQ_SENT ||
                      state == TFTPClient.FSM_Modes.ACK_SENT);
     state = TFTPClient.FSM_Modes.DATA_RECEIVED;
 }
Beispiel #31
0
 static void canPutExit(int len)
 {
     if (len < 516)
         state = TFTPClient.FSM_Modes.EXIT;
 }