Esempio n. 1
0
        protected void onAcknowledge(Acknowledgement acknowledgement)
        {
            try
            {
                waitForAckLatch.Get().CountDown();
                waitForSeqAckLatch.Get().CountDown();

                CongestionControl cc = session.getCongestionControl();
                long rtt             = acknowledgement.getRoundTripTime();
                if (rtt > 0)
                {
                    long rttVar = acknowledgement.getRoundTripTimeVar();
                    cc.setRTT(rtt, rttVar);
                    statistics.setRTT(rtt, rttVar);
                }
                long rate = acknowledgement.getPacketReceiveRate();
                if (rate > 0)
                {
                    long linkCapacity = acknowledgement.getEstimatedLinkCapacity();
                    cc.updatePacketArrivalRate(rate, linkCapacity);
                    statistics.setPacketArrivalRate(cc.getPacketArrivalRate(), cc.getEstimatedLinkCapacity());
                }

                long ackNumber = acknowledgement.getAckNumber();
                cc.onACK(ackNumber);
                statistics.setCongestionWindowSize((long)cc.getCongestionWindowSize());
                //need to remove all sequence numbers up the ack number from the sendBuffer
                bool removed = false;
                for (long s = lastAckSequenceNumber; s < ackNumber; s++)
                {
                    lock (sendLock)
                    {
                        removed = sendBuffer.Remove(s);
                    }
                    if (removed)
                    {
                        unacknowledged.DecrementAndGet();
                    }
                }
                lastAckSequenceNumber = (int)Math.Max(lastAckSequenceNumber, ackNumber);
                //send ACK2 packet to the receiver
                sendAck2(ackNumber);
                statistics.incNumberOfACKReceived();
                if (storeStatistics)
                {
                    statistics.storeParameters();
                }
            }
            catch (Exception ex)
            {
                Log.Write(this.ToString(), ex);
            }
        }
Esempio n. 2
0
 private void startThread()
 {
     try
     {
         nextACK     = Util.getCurrentTime() + ackTimerInterval;
         nextNAK     = (long)(Util.getCurrentTime() + 1.5 * nakTimerInterval);
         nextEXP     = Util.getCurrentTime() + 2 * expTimerInterval;
         ackInterval = (int)session.getCongestionControl().getAckInterval();
         while (!stopped)
         {
             receiverAlgorithm();
         }
     }
     catch (Exception ex)
     {
         Log.Write(this.ToString(), "SEVERE", ex);
     }
     Log.Write(this.ToString(), "STOPPING RECEIVER for " + session);;
 }