[ndnSIM] Changing topology parameter in real-time
Alex Afanasyev
alexander.afanasyev at ucla.edu
Wed Mar 27 10:28:00 PDT 2013
Hi Mohammad,
You don't need to remove topology reader, as it just creates a topology, and you are free to modify anything that has been created (doesn't matter which way) by directly accessing links and devices.
In a simple topology (I would not recommend this in very large topologies, since it may introduce significant overhead), to figure out the right NetDevice, you can do a trick similar to one used in a variant of ndn::StackHelper::AddRoute (https://github.com/NDN-Routing/ndnSIM/blob/master/helper/ndn-stack-helper.cc#L396):
input: otherNode -> node on the other side of the link
for (uint32_t deviceId = 0; deviceId < node->GetNDevices (); deviceId ++)
{
Ptr<PointToPointNetDevice> netDevice = DynamicCast<PointToPointNetDevice> (node->GetDevice (deviceId));
if (netDevice == 0)
continue;
Ptr<Channel> channel = netDevice->GetChannel ();
if (channel == 0)
continue;
if (channel->GetDevice (0)->GetNode () == otherNode ||
channel->GetDevice (1)->GetNode () == otherNode)
{
// netDevice - is the device you're looking for
}
}
Without tricks, you can just manually (if it is feasible) figure out or pre-calculate which deviceId corresponds to the link you want to modify. This would work more efficiently in large topologies, as will not need a linear search.
With AnnotatedTopologyReader, deviceId are assigned in order of links defined in the "links" section of the topology file. For example, if you have something like this:
dev1 dev2 ...
dev1 dev3 ...
dev5 dev1 ...
The first line will create netdevice 0 on dev1 and netdevice 0 on dev2, the second will create netdevice 1 on dev1 and netdevice 0 on dev3. The third will create netdevice 0 on dev5 and netdevice 2 on dev1.
---
Alex
On Mar 27, 2013, at 6:31 AM, Hovaidi Ardestani Mohammad <mohammad.hovaidi.ardestani at aalto.fi> wrote:
> Hi Alex,
> Thank you for your answer.
> Now, my questions are:
> 1.Do I need to remove AnnotatedTopolgyReader part and place these lines instead?
> 1-a.If I remove topology reader part then how I can define my network?(For instance using NodeContainer andPointToPointHelper).
> 1-b.If there is no need to remove topology then there will be conflict between those attributes set in topology and those in code.
> 2.In my simple code I have
> Ptr<Node> consumer1 = Names::Find<Node> ("Src1");
> and according to
> Ptr< NetDevice > ns3::Node::GetDevice ( uint32_t index ) const
> what should I put as an index in following line.
> Ptr<Channel> channel = node->GetDevice (?)->netDevice->GetChannel ();
> -Mohammad
>
>
>
> From: Alexander Afanasyev [mailto:cawka1 at gmail.com] On Behalf Of Alex Afanasyev
> Sent: Tuesday, March 26, 2013 8:57 PM
> To: Hovaidi Ardestani Mohammad
> Cc: ndnsim at lists.cs.ucla.edu
> Subject: Re: [ndnSIM] Changing topology parameter in real-time
>
> Hi Mohammad,
>
> Topology (.txt) is designed to work only once before the simulation begins. At any particular point of simulation, you have a full control of what kind of parameters links have, but you need to manually get hold of the specific transmission queues and channels and manually updated their attributes.
>
> You can try to do something like the following:
>
> Ptr<Node> node = ?;
> Ptr<Channel> channel = node->GetDevice (?)->netDevice->GetChannel ();
>
> // set channel delay
> channel->SetAttribute ("Delay", TimeValue (Seconds (0.01));
>
> Ptr<NetDevice> toDev = channel->GetDevice (1);
> Ptr<NetDevice> fromDev = channel->GetDevice (0);
>
> // set data rates
> toDev->SetAttribute ("DataRate", StringValue ("10Mbps"));
> fromDev->SetAttribute ("DataRate", StringValue ("10Mbps"));
>
> // set queue sizes
> PointerValue txQueue;
>
> toDev->GetAttribute ("TxQueue", txQueue);
> txQueue.Get<DropTailQueue> ()->SetAttribute ("MaxPackets", StringValue ("1000"));
>
> fromDev->GetAttribute ("TxQueue", txQueue);
> txQueue.Get<DropTailQueue> ()->SetAttribute ("MaxPackets", StringValue ("1000"));
>
> ---
> Alex
>
>
> On Mar 26, 2013, at 5:11 AM, Hovaidi Ardestani Mohammad <mohammad.hovaidi.ardestani at aalto.fi> wrote:
>
>
> Hello,
> I am wondering how I can change the topology parameters, such as Delay, Capacity and Queue length in real time. It seems to me that we can have those parameters fixed as input in *.txt file.
> Can anybody guide me?
> I really appreciate your help in advance.
> -Mohammad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20130327/ec699cf4/attachment.html>
More information about the ndnSIM
mailing list