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
        protected long sendAcknowledgment(long ackNumber)
        {
            try
            {
                Acknowledgement acknowledgmentPkt = buildLightAcknowledgement(ackNumber);
                //set the estimate link capacity
                estimateLinkCapacity = packetPairWindow.getEstimatedLinkCapacity();
                acknowledgmentPkt.setEstimatedLinkCapacity(estimateLinkCapacity);
                //set the packet arrival rate
                packetArrivalSpeed = packetHistoryWindow.getPacketArrivalSpeed();
                acknowledgmentPkt.setPacketReceiveRate(packetArrivalSpeed);

                endpoint.doSend(acknowledgmentPkt);

                statistics.incNumberOfACKSent();
                statistics.setPacketArrivalRate(packetArrivalSpeed, estimateLinkCapacity);
                return(acknowledgmentPkt.getAckSequenceNumber());
            }
            catch (Exception exc)
            {
                Log.Write(this.ToString(), exc);
                return(0);
            }
        }