/// <remarks> /// Finds the corresponding NakReceiverWindow and adds the message to it (according to seqno). Then removes /// as many messages as possible from the NRW and passes them up the stack. Discards messages from non-members. /// </remarks> /// <summary> /// Results in all possible messages from sender being delivered up the stacks /// </summary> /// <param name="msg"></param> /// <param name="hdr"></param> void handleMessage(Message msg, NakAckHeader hdr) { NakReceiverWindow win = null; Message msg_to_deliver; Address sender; if (msg == null || hdr == null) { if (Trace.trace) { Trace.error("NAKACK.handleMessage()", "msg or header is null"); } return; } sender = msg.Source; if (sender == null) { if (Trace.trace) { Trace.error("NAKACK.handleMessage()", "sender of message is null"); } return; } if (Trace.trace) { Trace.info("NAKACK.handleMessage()", "[" + local_addr + "] received <" + sender + "#" + hdr.seqno + ">"); } // msg is potentially re-sent later as result of XMIT_REQ reception; that's why hdr is added ! msg.putHeader(getName(), hdr); win = (NakReceiverWindow)received_msgs[sender]; if (win == null) { // discard message if there is no entry for sender if (leaving) { return; } if (Trace.trace) { Trace.warn("NAKACK.handleMessage()", "[" + local_addr + "] discarded message from non-member " + sender); } return; } win.add(hdr.seqno, msg); // add in order, then remove and pass up as many msgs as possible while ((msg_to_deliver = win.remove()) != null) { msg_to_deliver.removeHeader(getName()); passUp(new Event(Event.MSG, msg_to_deliver)); } }
/* ---------------------- Interface Retransmitter.RetransmitCommand ---------------------- */ /// <summary> /// Implementation of Retransmitter.RetransmitCommand, sends XMIT_REQ to originator of message /// </summary> /// <param name="first_seqno">First sequence number missing</param> /// <param name="last_seqno">Last sequence number missing</param> /// <param name="sender">Origin of the message</param> public void retransmit(long first_seqno, long last_seqno, Address sender) { lock (this) { NakAckHeader hdr; Message retransmit_msg = new Message(sender, null, null); if (Trace.trace) { Trace.info("NAKACK.retransmit()", "sending XMIT_REQ ([" + first_seqno + ", " + last_seqno + "]) to " + sender); } hdr = new NakAckHeader(NakAckHeader.XMIT_REQ, first_seqno, last_seqno); retransmit_msg.putHeader(getName(), hdr); passDown(new Event(Event.MSG, retransmit_msg)); } }
/// <remarks> /// Finds the corresponding NakReceiverWindow and adds the message to it (according to seqno). Then removes /// as many messages as possible from the NRW and passes them up the stack. Discards messages from non-members. /// </remarks> /// <summary> /// Results in all possible messages from sender being delivered up the stacks /// </summary> /// <param name="msg"></param> /// <param name="hdr"></param> void handleMessage(Message msg, NakAckHeader hdr) { NakReceiverWindow win=null; Message msg_to_deliver; Address sender; if(msg == null || hdr == null) { if(Trace.trace) Trace.error("NAKACK.handleMessage()", "msg or header is null"); return; } sender=msg.Source; if(sender == null) { if(Trace.trace) Trace.error("NAKACK.handleMessage()", "sender of message is null"); return; } if(Trace.trace) Trace.info("NAKACK.handleMessage()", "[" + local_addr + "] received <" + sender + "#" + hdr.seqno + ">"); // msg is potentially re-sent later as result of XMIT_REQ reception; that's why hdr is added ! msg.putHeader(getName(), hdr); win=(NakReceiverWindow)received_msgs[sender]; if(win == null) { // discard message if there is no entry for sender if(leaving) return; if(Trace.trace) Trace.warn("NAKACK.handleMessage()", "[" + local_addr + "] discarded message from non-member " + sender); return; } win.add(hdr.seqno, msg); // add in order, then remove and pass up as many msgs as possible while((msg_to_deliver=win.remove()) != null) { msg_to_deliver.removeHeader(getName()); passUp(new Event(Event.MSG, msg_to_deliver)); } }
/* ---------------------- Interface Retransmitter.RetransmitCommand ---------------------- */ /// <summary> /// Implementation of Retransmitter.RetransmitCommand, sends XMIT_REQ to originator of message /// </summary> /// <param name="first_seqno">First sequence number missing</param> /// <param name="last_seqno">Last sequence number missing</param> /// <param name="sender">Origin of the message</param> public void retransmit(long first_seqno, long last_seqno, Address sender) { lock(this) { NakAckHeader hdr; Message retransmit_msg = new Message(sender, null, null); if(Trace.trace) Trace.info("NAKACK.retransmit()", "sending XMIT_REQ ([" + first_seqno + ", " + last_seqno + "]) to " + sender); hdr=new NakAckHeader(NakAckHeader.XMIT_REQ, first_seqno, last_seqno); retransmit_msg.putHeader(getName(), hdr); passDown(new Event(Event.MSG, retransmit_msg)); } }