[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Identifying packet incoming link



> After a node receives a multicast packet, is there a way to
> determine the link the packet came from, given the interface
> label carried in the packet header?

yes... you can actually get the (actual) previous node that forwarded the 
packet from the interface label using the ifaceGetNode proc in ns-mcast.tcl:

Node instproc ifaceGetNode { iface } {
        $self instvar ns_ id_ neighbor_
        foreach node $neighbor_ {
                set link [$ns_ set link_([$node id]:$id_)]
            if {[[$link set ifaceout_] id] == $iface} {
                return $node
            }
        }
        return -1
}

if you want the link you can extract the code that does that above and do 
your own little proc, or you can simply use the above function to get the 
(actual) next hop node that forwarded the packet, and use the link_ array 
to get the link.. 
The link you get may be a DummyLink if it is one type of lan (see 
lan/ns-mlink.tcl)

[here, however, we assume there can only be one link between 2 pairs of 
nodes; so the current ns scheme falls short from modeling something like:
 ------
 |    |
|A|  |B|
 |    |
 ------
]

> In other words, does ns store an interface-to-link mapping
> anywhere? A quick glance at the code did not reveal anything.
yes... see above!

> (Do interfaces have addresses in ns? It appears that they don't.)

no,... interfaces do not have addresses in ns... only nodes have 
addresses (that are routable),... interfaces (for the multiLink class) have 
labels ... 
[there are data link interfaces in ns-lan, that have to do with the mac 
layer,... but I am assuming you are talking about the multiLink stuff 
since you're talking about mutlicast]

> 
> One possible way, might be to do a routing table lookup from the
> current node back to the source of the packet to get the next hop node.
> Then do another ns lookup (in array links_) to get the appropriate
> link. 

no... this may lead to errors... if you are looking for the `actual` prev 
node that forwarded the packet.
If you do the route lookup, you will be assuming that only your next hop 
nbr (accdg to unicast) can forward multicast packets to you (as a node), 
and this may not be true... [this situation may arise in PIM-DM,
PIM-SM, cbt..]

> However, I hope there is an easier way.
> 
> Also, if I know link_($n1:$n2) is there away to find link_($n2:$n1)
> (as created by duplex-link) if I don't know n1 and n2 (or if I only
> know either n1 or n2)?

the Link class (in lib/ns-link.tcl) has a 'fromNode_' and a `toNode_` 
instance variables... so if you have a link object you can know its n1 
and n2 and you can get the link for the other direction (given you have 
created a duplex-link (i.e. 2 link objects) between n1 and n2) using the 
link_ array,

Regards,
-A

> 
> Thanks,
> 
> Christos.
>