diff -r 682eb88ed29e src/helper/csma-helper.cc --- a/src/helper/csma-helper.cc Tue Jan 27 12:39:43 2009 -0800 +++ b/src/helper/csma-helper.cc Thu Jan 29 22:18:50 2009 -0800 @@ -31,7 +31,8 @@ namespace ns3 { -CsmaHelper::CsmaHelper () +CsmaHelper::CsmaHelper () : + m_defaultDeviceNamePrefix ("eth") { m_queueFactory.SetTypeId ("ns3::DropTailQueue"); m_deviceFactory.SetTypeId ("ns3::CsmaNetDevice"); diff -r 682eb88ed29e src/helper/csma-helper.h --- a/src/helper/csma-helper.h Tue Jan 27 12:39:43 2009 -0800 +++ b/src/helper/csma-helper.h Thu Jan 29 22:18:50 2009 -0800 @@ -82,6 +82,31 @@ public: void SetDeviceParameter (std::string n1, const AttributeValue &v1) NS_DEPRECATED; void SetChannelParameter (std::string n1, const AttributeValue &v1) NS_DEPRECATED; + + /** + * \param prefix a string prefix corresponding to a device name; e.g. "en" + * + * This method will auto-name any subsequently created CsmaNetDevice + * according to the following convention: + * 1) the device name will be the concatenation of the prefix parameter and + * an unsigned integer starting at index 0 + * 2) the integer assigned will be the first unassigned integer for this + * device type greater than or equal to zero + * 3) to add this name to the Names namespace, a node name must be present + * on this node. If the node has a name already, that name is used. + * If there is no name, a new node name will generated as the + * concatenation of the character "n" and the integer index in the + * global nodelist. + * + * As an example, for a node with three Csma NetDevices, if this + * method is called with the "fxp" prefix for each device, and the + * node has a name in the name list such as "/Names/client", then + * the three Csma devices will have names "/Names/client/fxp0", + * "/Names/client/fxp1", and "/Names/client/fxp2", respectively. + * If it didn't already have the name "client" and it was node number + * 3, for instance, the devices would get names "/Names/n3/fxp0", etc. + * + * If the global value g_autoNameDevices was previously set to true, + * this prefix will override the default prefix that would have been used + */ + void SetDeviceNamePrefix (std::string prefix); /** * \param filename filename prefix to use for pcap files. @@ -340,6 +365,8 @@ private: ObjectFactory m_queueFactory; ObjectFactory m_deviceFactory; ObjectFactory m_channelFactory; + + std::string m_defaultDeviceNamePrefix; }; } // namespace ns3 diff -r 682eb88ed29e src/helper/names-helper.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/helper/names-helper.cc Thu Jan 29 22:18:50 2009 -0800 @@ -0,0 +1,10 @@ +#include "ns3/global-value.h" + +namespace ns3 { + +// Automatically name devices according to the default prefix string +// configured in their device helpers +static GlobalValue g_autoNameDevices ("Auto-name devices", + BooleanValue (false), + MakeBooleanChecker ()); +}