/// <summary>Convenience function to instantiate a link-state advertisement packet.</summary> /// <remarks>The new packet is meant to share a newly-calculated link cost. It is assumed the link cost has just been (re)calculated.</remarks> /// <param name='src'>The node that is reporting link state.</param> /// <param name='link'> /// The link that the new packet will describe. Destination and current link cost will be read from the link. /// </param> /// <param name='seq_num'> /// The new packet will represent the link's status for the <paramref name="seq_num"/>th routing calculation. /// </param> public static Packet CreateLinkStateAdvertisement(int seq_num, Node src, Link link, double current_time) { return new Packet{ payload_size=Packet.LINK_STATE_ADVERTISEMENT_SIZE, src=src.ip, link_dest=link.dest.ip, link_cost=link.cost, type=PacketType.LINK_STATE_ADVERTISEMENT, seq_num=seq_num, timestamp=current_time }; }
public Link(EventQueueProcessor eqp, string name, Node src, Node dest, double rate, double prop_delay, Int64 buffer_size) { this.eqp = eqp; this.src = src; this.dest = dest; this.rate = rate; this.name = name; this.prop_delay = prop_delay; this.buffer_size = buffer_size; this.lStatus = new LinkStatus(); this.lStatus.link = this; this.lStatus.dropped_packets = 0; this.lStatus.delivered_packets = 0; this.is_transmitting = false; this.buffer = new Queue<Packet>(); }
/// <returns> /// The first hop on the shortest path from <paramref name="this"/> to <paramref name="dest"/> in the <paramref name="shortest_paths_tree"/> /// </returns> private Node FirstHopOnShortestPath(Node dest, IDictionary<Node, Node> shortest_paths_tree) { if(dest == this) // shouldn't call this throw new ArgumentException("There is no next hop for a packet destined for this router.", "this"); Node predecessor = shortest_paths_tree[dest]; return predecessor == this ? dest : FirstHopOnShortestPath(predecessor, shortest_paths_tree); }