/// <summary>
        /// Constructor: Creates a new instance with the given retransmit command
        /// </summary>
        /// <param name="sender">The sender associated with this instance</param>
        /// <param name="cmd">The command used to retransmit a missing message</param>
        /// <param name="start_seqno">The first sequence number to be received</param>
        /// <param name="sched">The external scheduler to use for retransmission</param>
        public NakReceiverWindow(Address sender, Retransmitter.RetransmitCommand cmd,
			long start_seqno, TimeScheduler sched)
        {
            this.sender = sender;
            this.cmd    = cmd;
            head        = start_seqno;
            tail        = head;

            if (cmd != null)
                retransmitter = sched==null ?
                                 new Retransmitter(sender, cmd):
                                 new Retransmitter(sender, cmd, sched);
        }
示例#2
0
 /// <summary>
 /// Sets the TimeScheduler to the instance in the ProtocolSinkStack and
 /// initialises the GMS implementation if possible.
 /// </summary>
 public override void init()
 {
     timer=stack != null? stack.timer : null;
     if(timer == null)
         throw new Exception("GMS.init(): timer is null");
     if(impl != null)
         impl.init();
 }
示例#3
0
        /// <remarks>
        /// The reason for waiting a random amount of time is that, in the worst case, all members receive a
        /// STABLE_GOSSIP message from the last outstanding member at the same time and would therefore mcast the
        /// STABILITY message at the same time too. To avoid this, each member waits random N msecs. If, before N
        /// elapses, some other member sent the STABILITY message, we just cancel our own message. If, during
        /// waiting for N msecs to send STABILITY message S1, another STABILITY message S2 is to be sent, we just 
        /// discard S2.
        /// </remarks>
        /// <summary>
        /// Schedules a stability message to be mcast after a random number of milliseconds.
        /// </summary>
        /// <param name="tmp">Stable Digest</param>
        private void sendStabilityMessage(Digest tmp)
        {
            long         delay;

            if(timer == null)
            {
                if(Trace.trace)
                    Trace.error("STABLE.sendStabilityMessage()", "timer is null, cannot schedule " + "stability message to be sent");
                timer=stack != null ? stack.timer : null;
                return;
            }

            // give other members a chance to mcast STABILITY message. if we receive STABILITY by the end of
            // our random sleep, we will not send the STABILITY msg. this prevents that all mbrs mcast a
            // STABILITY msg at the same time
            delay=random.Next((int)stability_delay);
            if(Trace.trace)
                Trace.info("STABLE.sendStabilityMessage()", "stability_task=" + stability_task + ", delay is " + delay);
            lock(stability_mutex)
            {
                if(stability_task != null && !stability_task.cancelled())  // schedule only if not yet running
                    return;
                stability_task =new StabilitySendTask(this, tmp, delay);
                timer.add(stability_task, true); // run it 1x after delay msecs. use fixed-rate scheduling
            }
        }
示例#4
0
 /// <summary>
 /// Sets the Scheduler to the Scheduler present in the ProtocolSinkStack
 /// </summary>
 public override void start()
 {
     if(stack != null && stack.timer != null)
         timer = stack.timer;
     else
         throw new Exception("STABLE.up(): timer cannot be retrieved from protocol stack");
 }
示例#5
0
 /// <summary>
 /// Uses TimeScheduler from ProtocolSinkStack.
 /// </summary>
 public override void start()
 {
     timer=stack != null ? stack.timer : null;
     if(timer == null)
         throw new Exception("NAKACK.up(): timer is null");
 }
示例#6
0
 /// <summary>
 /// Sets the Scheduler to the Scheduler present in the ProtocolSinkStack
 /// </summary>
 public override void start()
 {
     timer=stack != null ? stack.timer : null;
     if(timer == null)
         if(Trace.trace)
             Trace.error("UNICAST.up()", "[START] timer is null");
 }
示例#7
0
 /// <summary>
 /// Constructor: Create a new Retransmitter associated with the given sender address
 /// </summary>
 /// <param name="sender">The address from which retransmissions are expected or to which retransmissions are sent</param>
 /// <param name="cmd">The retransmission callback reference</param>
 /// <param name="sched">The retransmissions scheduler</param>
 public Retransmitter(Address sender, RetransmitCommand cmd, TimeScheduler sched)
 {
     init(sender, cmd, sched, false);
 }
示例#8
0
 /* ------------------------------- Private Methods -------------------------------------- */
 /// <summary>
 /// Initialises this object
 /// </summary>
 /// <param name="sender">The address from which retransmissions are expected</param>
 /// <param name="cmd">The retransmission callback reference</param>
 /// <param name="sched">Schedular for retransmit tasks</param>
 /// <param name="sched_owned">sched_owned whether the scheduler parameter is owned by this object or is externally provided</param>
 private void init(Address sender, RetransmitCommand cmd, TimeScheduler sched, bool sched_owned)
 {
     this.sender         = sender;
     this.cmd            = cmd;
     retransmitter_owned = sched_owned;
     retransmitter       = sched;
 }
示例#9
0
 /// <summary>
 /// Sets the <c>TimeScheduler</c> to be used to the one present in the <c>ProtocolSinkStack</c>
 /// </summary>
 public override void init()
 {
     if(stack != null && stack.timer != null)
         timer=stack.timer;
     else
         if(Trace.trace)
         Trace.error("FD.up()", "[START]: timer cannot be retrieved from protocol stack");
 }