public UDTSession(string description, Destination destination) { statistics = new UDTStatistics(description); mySocketID = Interlocked.Increment(ref nextSocketID); this.destination = destination; this.dgPacket = new UDPUserToken(destination.EndPoint); //String clazzP = System.getProperty(CC_CLASS, UDTCongestionControl.class.getName()); Object ccObject = null; ccObject = new UDTCongestionControl(this); //try{ // Class<?>clazz=Class.forName(clazzP); // ccObject=clazz.getDeclaredConstructor(UDTSession.class).newInstance(this); //}catch(Exception e){ // logger.log(Level.WARNING,"Can't setup congestion control class <"+clazzP+">, using default.",e); // ccObject=new UDTCongestionControl(this); //} cc = (ICongestionControl)ccObject; //logger.info("Using "+cc.getClass().getName()); }
protected void OnAcknowledge(Acknowledgement acknowledgement) { waitForAckLatch.Signal(); waitForSeqAckLatch.Signal(); //cd long ackNumber = acknowledgement.AckNumber; // cd if (this.session is ClientSession) { //cd if (this.isModify) { //已经发送过10000包,不用再修正,认为接收方已经关闭 if (bufferNum < 10000) { if (ackNumber / 100000 != this.session.InitialSequenceNumber / 100000) { //认为不同段的seqNo,则不是通信的接收方session statistics.incNumberOfACKReceived(); if (storeStatistics) { statistics.StoreParameters(); } return; } } else { this.isModify = false; //不用再修正 } } } ICongestionControl cc = session.CongestionControl; long rtt = acknowledgement.RoundTripTime; if (rtt > 0) { long rttVar = acknowledgement.RoundTripTimeVar; cc.SetRTT(rtt, rttVar); statistics.setRTT(rtt, rttVar); } long rate = acknowledgement.PacketReceiveRate; if (rate > 0) { long linkCapacity = acknowledgement.EstimatedLinkCapacity; cc.UpdatePacketArrivalRate(rate, linkCapacity); statistics.setPacketArrivalRate(cc.GetPacketArrivalRate(), cc.GetEstimatedLinkCapacity()); } cc.OnACK(ackNumber); statistics.CongestionWindowSize = ((long)cc.GetCongestionWindowSize()); //need to remove all sequence numbers up the ack number from the sendBuffer bool removed = false; DataPacket packet = null; for (long s = lastAckSequenceNumber; s < ackNumber; s++) { lock (sendLock) { removed = sendBuffer.TryRemove(s, out packet); } if (removed) { Interlocked.Decrement(ref unacknowledged); bufferNum++; //cd } } lastAckSequenceNumber = Math.Max(lastAckSequenceNumber, ackNumber); //send ACK2 packet to the receiver SendAck2(ackNumber); // statistics.incNumberOfACKReceived(); if (storeStatistics) { statistics.StoreParameters(); } }