/// <summary>Constructor for a TunnelEdge, RemoteID == -1 for out bound.</summary> public TunnelEdge(IEdgeSendHandler send_handler, TunnelTransportAddress local_ta, TunnelTransportAddress remote_ta, IForwarderSelector ias, List <Connection> overlap, int remote_id) : base(send_handler, remote_id != -1) { _remote_id = remote_id; lock (_rand) { LocalID = _rand.Next(); } byte[] bid = new byte[8]; NumberSerializer.WriteInt(LocalID, bid, 0); NumberSerializer.WriteInt(_remote_id, bid, 4); _mid = MemBlock.Reference(bid); _local_ta = local_ta; _remote_ta = remote_ta; _tunnels = new List <Connection>(overlap); _ias = ias; _ias.Update(_tunnels); AHHeader ahh = new AHHeader(1, 20, local_ta.Target, remote_ta.Target, AHHeader.Options.Exact); ICopyable header = new CopyList(PType.Protocol.AH, ahh, PType.Protocol.Tunneling); Header = MemBlock.Copy(header); }
/// <summary>Sends a packet from A to B returning the delay and hop count.</summary> public List <SendPacketResult> SendPacket(AHAddress from, AHAddress to, ushort option) { AHHeader ah = new AHHeader(0, 100, from, to, option); GraphNode cnode = _addr_to_node[from]; Edge cedge = null; AHAddress last_addr = from; Pair <Connection, bool> next = new Pair <Connection, bool>(null, false); int delay = 0; int hops = 0; var results = new List <SendPacketResult>(); while (true) { next = cnode.NextConnection(cedge, ah); if (next.Second) { results.Add(new SendPacketResult(last_addr, delay, hops)); } if (next.First == null) { break; } AHAddress caddress = next.First.Address as AHAddress; cnode = _addr_to_node[caddress]; cedge = cnode.ConnectionTable.GetConnection(next.First.MainType, last_addr).Edge; last_addr = caddress; delay += (cedge as GraphEdge).Delay; hops++; } return(results); }
public Pair<Connection, bool> NextConnection(Edge edge, AHHeader header) { Pair<Connection, bool> result = null; //Check to see if we can use a Leaf connection: int dest_idx = _ahstate.Leafs.IndexOf(header.Destination); if( dest_idx >= 0 ) { result = new Pair<Connection, bool>(_ahstate.Leafs[dest_idx], false); } else { var alg = _ahstate.GetRoutingAlgo(header); result = alg.NextConnection(edge, header); } return result; }
public Pair <Connection, bool> NextConnection(Edge edge, AHHeader header) { Pair <Connection, bool> result = null; //Check to see if we can use a Leaf connection: int dest_idx = _ahstate.Leafs.IndexOf(header.Destination); if (dest_idx >= 0) { result = new Pair <Connection, bool>(_ahstate.Leafs[dest_idx], false); } else { var alg = _ahstate.GetRoutingAlgo(header); result = alg.NextConnection(edge, header); } return(result); }
/// <summary>Sends a packet from A to B returning the delay and hop count.</summary> public List<SendPacketResult> SendPacket(AHAddress from, AHAddress to, ushort option) { AHHeader ah = new AHHeader(0, 100, from, to, option); GraphNode cnode = _addr_to_node[from]; Edge cedge = null; AHAddress last_addr = from; Pair<Connection, bool> next = new Pair<Connection, bool>(null, false); int delay = 0; int hops = 0; var results = new List<SendPacketResult>(); while(true) { next = cnode.NextConnection(cedge, ah); if(next.Second) { results.Add(new SendPacketResult(last_addr, delay, hops)); } if(next.First == null) { break; } AHAddress caddress = next.First.Address as AHAddress; cnode = _addr_to_node[caddress]; cedge = cnode.ConnectionTable.GetConnection(next.First.MainType, last_addr).Edge; last_addr = caddress; delay += (cedge as GraphEdge).Delay; hops++; } return results; }
/// <summary>Constructor for a TunnelEdge, RemoteID == -1 for out bound.</summary> public TunnelEdge(IEdgeSendHandler send_handler, TunnelTransportAddress local_ta, TunnelTransportAddress remote_ta, IForwarderSelector ias, List<Connection> overlap, int remote_id) : base(send_handler, remote_id != -1) { _remote_id = remote_id; lock(_rand) { LocalID = _rand.Next(); } byte[] bid = new byte[8]; NumberSerializer.WriteInt(LocalID, bid, 0); NumberSerializer.WriteInt(_remote_id, bid, 4); _mid = MemBlock.Reference(bid); _local_ta = local_ta; _remote_ta = remote_ta; _tunnels = new List<Connection>(overlap); _ias = ias; _ias.Update(_tunnels); AHHeader ahh = new AHHeader(1, 20, local_ta.Target, remote_ta.Target, AHHeader.Options.Exact); ICopyable header = new CopyList(PType.Protocol.AH, ahh, PType.Protocol.Tunneling); Header = MemBlock.Copy(header); }