Menu

change resend ack work

Developers
Olen
2009-12-02
2013-09-20
  • Olen

    Olen - 2009-12-02

    editing  to "TFTPServerProcess.cs"

    finished.

        private int ImTimeCount = 0; //if send data successfully & this is add to line 864
            /// <summary>
            /// Check the state of the current TFTP session
            /// </summary>
            public void CheckStates()
            {
                //System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace(2, true);
                //System.Diagnostics.StackFrame sf = st.GetFrame(0);
                //AddMsg(Level.Debug, ident.ToString() + ": Process CheckStates" + sf.ToString());

                AddMsg(Level.Debug, ident.ToString() + ": " + DateTime.Now.ToString() + "Process CheckStates timer callback started.");
                lock (CurrStatesLock)
                {
                    if (State != null)
                    {
                        if (State.TransferState.Closed)
                        {
                            AddMsg(Level.Verbose, ident.ToString() + ": " + DateTime.Now.ToString() + " CheckStates timer calling stoplistener because the state is closed.");
                            StopListener();
                        }
                        else
                        {
    if ((DateTime.Now.Ticks - State.Timestamp) > 0 && (((DateTime.Now.Ticks - State.Timestamp) / 10000000) > State.TimeoutSeconds))
                            {
                                switch (State.OriginalOpcode)
    {
    case 1: //RRQ
    ImTimeCount++;
    break;
        case 2://WRQ
    ImTimeCount++;
    //If we didn't get another DATA packet since our last ACK resend
    AddMsg(Level.Info, "Resending ACK to " + State.RemoteIPAddress.ToString() + ":" + State.RemotePortNumber.ToString());
    IPEndPoint RemoteEndPoint = new IPEndPoint(IPAddress.Parse(State.RemoteIPAddress), State.RemotePortNumber);
    Send(RemoteEndPoint, new byte { 0, 4, State.BlockIDByte1, State.BlockIDByte2 });
    break;
    //case 3: //DATA
    // ImTimeCount++;
    // break;
    //case 4: //ACK
    // ImTimeCount++;
    // break;
    //case 5: //ERROR
    // ImTimeCount++;
    // break;
    //case 6: //OACK
    // ImTimeCount++;
    // break;
    default:
    ImTimeCount++;
    //If a state has had no activity for the specified interval remove it
    AddMsg(Level.Info, "Timeout for " + State.TransferType + " request of file " + State.Filename + " connection " + State.RemoteIPAddress.ToString() + ":" + State.RemotePortNumber.ToString());
    AddMsg(Level.Verbose, "Timeout was " + ((DateTime.Now.Ticks - State.Timestamp) / 10000000).ToString() + " seconds");
    State.ErrorOccurred = true;
    State.ErrorMsg = "Timeout occured for " + State.TransferType + " request of file " + State.Filename + " from " + State.RemoteIPAddress.ToString();
    State.Close();
    }
    if (ImTimeCount > Timeout)
    {
    ImTimeCount++;
    //If a state has had no activity for the specified interval remove it
    AddMsg(Level.Info, "Timeout for " + State.TransferType + " request of file " + State.Filename + " connection " + State.RemoteIPAddress.ToString() + ":" + State.RemotePortNumber.ToString());
    AddMsg(Level.Verbose, "Timeout was " + ((DateTime.Now.Ticks - State.Timestamp) / 10000000).ToString() + " seconds");
    State.ErrorOccurred = true;
    State.ErrorMsg = "Timeout occured for " + State.TransferType + " request of file " + State.Filename + " from " + State.RemoteIPAddress.ToString();
    State.Close();
    }
    /*
    if (((DateTime.Now.Ticks - State.Timestamp) / 10000000) > State.TimeoutSeconds)
                                {
                                    //If a state has had no activity for the specified interval remove it
                                    AddMsg(Level.Info, "Timeout for " + State.TransferType + " request of file " + State.Filename + " connection " + State.RemoteIPAddress.ToString() + ":" + State.RemotePortNumber.ToString());
                                    AddMsg(Level.Verbose, "Timeout was " + ((DateTime.Now.Ticks - State.Timestamp) / 10000000).ToString() + " seconds");
                                    State.ErrorOccurred = true;
                                    State.ErrorMsg = "Timeout occured for " + State.TransferType + " request of file " + State.Filename + " from " + State.RemoteIPAddress.ToString();
                                    State.Close();
                                }
                                else if ((((DateTime.Now.Ticks - State.Timestamp) / 10000000) > State.TimeoutSeconds) && (State.OriginalOpcode == 2))
                                {
                                    //If we didn't get another DATA packet since our last ACK resend
                                    AddMsg(Level.Info, "Resending ACK to " + State.RemoteIPAddress.ToString() + ":" + State.RemotePortNumber.ToString());
                                    IPEndPoint RemoteEndPoint = new IPEndPoint(IPAddress.Parse(State.RemoteIPAddress), State.RemotePortNumber);
                                    Send(RemoteEndPoint, new byte { 0, 4, State.BlockIDByte1, State.BlockIDByte2 });
                                }
    */
                            }
                        }
                    }
                    else if (TimeoutCounter > Timeout)
                    {
                        AddMsg(Level.Verbose, ident.ToString() + ": Stopping listener because no active sessions for timeout peroid.");
                        this.StopListener();
                    }
                    else
                    {
                        //The listener should not be running if there is not an active session
                        ++TimeoutCounter;
                    }
                }
                AddMsg(Level.Debug, ident.ToString() + ": " + "Process CheckStates timer callback finished " + DateTime.Now.ToString());
            }

    and edit … private void SendNextDataDatagram(…)

        private void SendNextDataDatagram(byte ReceivedBytes, IPEndPoint RemoteEndPoint, string EndPointString)
            {
                try
                {
                    ImTimeCount = 0; //if send data successfully
    byte ………
                }…………..

     
    • Tom Kuhn

      Tom Kuhn - 2013-09-20

      Are any of these changes in the trunk or branches? Are they in the latest binaries?

       

Log in to post a comment.