Difference between revisions of "HOWTO determine the path of an attribute or trace source"
Nicolabaldo (Talk | contribs) (New page: ==Aggregated Objects== $-prefixed items in a path are used to perform an aggregation lookup using the TypeId of the Object you are looking for. Since almost all TypeIds have a ns3:: prefix...) |
(Added hint on logging Config-related messages) |
||
Line 24: | Line 24: | ||
− | == | + | ==Hints== |
− | A nice way to figure out a path is to [[HOWTO use the ConfigStore | use the ConfigStore]]: if you use it | + | * A nice way to figure out a path is to [[HOWTO use the ConfigStore | use the ConfigStore]]: if you use it to dump all attributes in a text file, you can see a valid path for each attribute (this, arguably, does not work for trace sources). |
− | to dump all attributes in a text file, you can see a valid path for each | + | * Also, note that there is a 'Config' LogComponent: just activate it by stating <code>LogComponentEnable ("Config", LOG_LEVEL_ALL);</code> somewhere in your simulation script. |
− | attribute (this, arguably, does not work for trace sources). | + | |
==References== | ==References== | ||
− | http://groups.google.com/group/ns-3-users/browse_thread/thread/c162f5a8d13fe9d1/67b21278f7abf925?lnk=gst&q=config#67b21278f7abf925 | + | *http://groups.google.com/group/ns-3-users/browse_thread/thread/c162f5a8d13fe9d1/67b21278f7abf925?lnk=gst&q=config#67b21278f7abf925 |
− | http://mailman.isi.edu/pipermail/ns-developers/2009-August/006350.html | + | *http://mailman.isi.edu/pipermail/ns-developers/2009-August/006350.html |
Revision as of 16:11, 8 June 2010
Contents
Aggregated Objects
$-prefixed items in a path are used to perform an aggregation lookup using the TypeId of the Object you are looking for. Since almost all TypeIds have a ns3:: prefix, you will usually see the compound prefix $ns3::
Example:
/NodeList/*/$ns3::TcpL4Protocol
the above path works because ns3::TcpL4Protocol instances are aggregated to the node in which they exist. On the other hand see this one:
/NodeList/0/DeviceList/0/$ns3::WifiRemoteStationManager
the above path is getting device 0 in node 0, and, then, doing GetObject<WifiRemoteStationManager> on it but it gets null because the remote station manager is not aggregated to the device.
Objects referenced by attributes of other Objects
2) non-$ prefixed non-terminating items in a path are used to perform an attribute lookup on an attribute of type Pointer. This is often used as an alternative to object aggregation.
As an example, when using a wifi device:
/NodeList/0/DeviceList/0/RemoteStationManager/MacTxDataFailed
the above path works, because devices with TypeId ns3::WifiNetDevice have a RemoteStationManager attribute which is of type Ptr<WifiRemoteStationManager>. On the other hand, see this one:
/NodeList/0/TcpL4Protocolthe above path doesn't work,
/NodeList/0gets you to a Node Object, and there is no Attribute named TcpL4Protocol. All this in spite of the fact that TcpL4Protocol is aggregated with Node -- remember that for querying aggregated objects you need the $ prefix.
Hints
- A nice way to figure out a path is to use the ConfigStore: if you use it to dump all attributes in a text file, you can see a valid path for each attribute (this, arguably, does not work for trace sources).
- Also, note that there is a 'Config' LogComponent: just activate it by stating
LogComponentEnable ("Config", LOG_LEVEL_ALL);
somewhere in your simulation script.