Brunet.Symphony.AHHeader.IncrementHops C# (CSharp) Method

IncrementHops() public method

public IncrementHops ( ) : AHHeader
return AHHeader
  public AHHeader IncrementHops() {
    short new_hops = (short)(Hops + 1);
    return new AHHeader(new_hops, this);
  }

Usage Example

Example #1
0
        /**
         * Here we handle routing AHPackets
         */
        public void HandleData(MemBlock data, ISender ret_path, object st)
        {
            AHState state   = _state; //Read the state, it can't change after the read
            var     header  = new AHHeader(data);
            var     payload = data.Slice(header.Length);

            Connection next_con;
            //Check to see if we can use a Leaf connection:
            int dest_idx = state.Leafs.IndexOf(header.Destination);

            if (dest_idx >= 0)
            {
                next_con = state.Leafs[dest_idx];
            }
            else
            {
                var alg = state.GetRoutingAlgo(header);
                Pair <Connection, bool> result = alg.NextConnection(ret_path as Edge, header);
                if (result.Second)
                {
                    //Send a response exactly back to the node that sent to us
                    var resp_send = new AHSender(_n, ret_path, header.Source,
                                                 AHSender.DefaultTTLFor(_n.NetworkSize),
                                                 AHHeader.Options.Exact);
                    _n.HandleData(payload, resp_send, this);
                }
                next_con = result.First;
            }
            //Send it on:
            if (next_con != null)
            {
                //Now we do the sending:
                var new_packet = new CopyList(PType.Protocol.AH,
                                              header.IncrementHops(),
                                              payload);
                try {
                    next_con.Edge.Send(new_packet);
                }
                catch (EdgeException) {
                    //Just drop the packet...
                }
            }
        }
All Usage Examples Of Brunet.Symphony.AHHeader::IncrementHops