public void init()
 {
     nak = new NakReceiverWindow(remoteAddr,this,0);
     nak.setRetransmitTimeouts(retransmit_timeout);
 }
Example #2
0
        /// <remarks>
        /// For all members of the digest, adjust the NakReceiverWindows in the received_msgs hashtable.
        /// If the member already exists, sets its seqno to be the max of the seqno and the seqno of the member
        /// in the digest. If no entry exists, create one with the initial seqno set to the seqno of the
        /// member in the digest.
        /// </remarks>
        /// <summary>
        /// Merges two digests together
        /// </summary>
        /// <param name="d">Digest to merge</param>
        void mergeDigest(Digest d)
        {
            Address            sender;
            NakReceiverWindow  win;
            long               initial_seqno;

            if(d == null || d.senders == null)
            {
                if(Trace.trace)
                    Trace.error("NAKACK.mergeDigest()", "digest or digest.senders is null");
                return;
            }
            for(int i=0; i < d.size(); i++)
            {
                sender=d.senderAt(i);
                if(sender == null)
                {
                    if(Trace.trace)
                        Trace.error("NAKACK.mergeDigest()", "sender at index " + i + " in digest is null");
                    continue;
                }
                initial_seqno=d.highSeqnoAt(i);
                win=(NakReceiverWindow)received_msgs[sender];
                if(win == null)
                {
                    win=new NakReceiverWindow(sender, this, initial_seqno, timer);
                    win.setRetransmitTimeouts(retransmit_timeout);
                    received_msgs.Add(sender, win);
                }
                else
                {
                    if(win.getHighestReceived() < initial_seqno)
                    {
                        win.reset();
                        received_msgs.Remove(sender);
                        win=new NakReceiverWindow(sender, this, initial_seqno, timer);
                        win.setRetransmitTimeouts(retransmit_timeout);
                        received_msgs.Add(sender, win);
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Installs new NakReceiverWindows with the values specified in the Digest.
        /// </summary>
        /// <param name="d"></param>
        void setDigest(Digest d)
        {
            Address            sender;
            NakReceiverWindow  win;
            long               initial_seqno;

            clear();
            if(d == null || d.senders == null)
            {
                if(Trace.trace)
                    Trace.error("NAKACK.setDigest()", "digest or digest.senders is null");
                return;
            }
            for(int i=0; i < d.size(); i++)
            {
                sender=d.senderAt(i);
                if(sender == null)
                {
                    if(Trace.trace)
                        Trace.error("NAKACK.setDigest()", "sender at index " + i + " in digest is null");
                    continue;
                }
                initial_seqno=d.highSeqnoAt(i);
                win=new NakReceiverWindow(sender, this, initial_seqno, timer);
                win.setRetransmitTimeouts(retransmit_timeout);
                received_msgs.Add(sender, win);
            }
        }
Example #4
0
        /// <summary>
        /// Removes all old members and creates NakReceiverWindows for all new members
        /// </summary>
        void adjustReceivers()
        {
            Address				newSender;
            NakReceiverWindow	win;
            Hashtable			oldSenders = new Hashtable();

            // 1. Remove all senders in received_msgs that are not members anymore
            foreach(Address sender in received_msgs.Keys)
            {
                if(!members.Contains(sender))
                {
                    oldSenders.Add(sender, received_msgs[sender]);
                }
            }

            foreach(Address sender in oldSenders.Keys)
            {
                win=(NakReceiverWindow)received_msgs[sender];
                win.reset();
                if(Trace.trace)
                    Trace.info("NAKACK.adjustReceivers()", "removing " + sender +
                        " from received_msgs (not member anymore)");
                received_msgs.Remove(sender);
            }

            // 2. Add newly joined members to received_msgs (starting seqno=0)
            for(int i=0; i < members.Count; i++)
            {
                newSender=(Address)members[i];
                if(!received_msgs.ContainsKey(newSender))
                {
                    win = new NakReceiverWindow(newSender, this, 0, timer);
                    win.setRetransmitTimeouts(retransmit_timeout);
                    received_msgs.Add(newSender, win);
                }
            }
        }