[ndnSIM] Changing the BW on Link during sim

Alex Afanasyev aa at CS.UCLA.EDU
Fri Apr 15 13:58:08 PDT 2016


> On Apr 5, 2016, at 4:04 AM, Ahmed Sadek <don1559 at gmail.com> wrote:
> 
> Dear All,
> 
> I wanted to change the BW on link during sim, I found this method in a previous email Here <http://www.lists.cs.ucla.edu/pipermail/ndnsim/2013-March/000297.html>
> 
> so now I have this method:
> 
> // Set the Data Rate of a given Device.
> void setDataRate(Ptr<NetDevice > nd, std::string DR)
> {
>   Ptr < Channel > channel = nd->GetChannel();
>   Ptr<NetDevice> toDev = channel->GetDevice (1);
>   Ptr<NetDevice> fromDev = channel->GetDevice (0);
> 
>   toDev->SetAttribute ("DataRate", StringValue (DR));
>   fromDev->SetAttribute ("DataRate", StringValue (DR));
> }
> 
> And was wondering, is there a simpler method to take advantage of point to point device method Here <https://www.nsnam.org/doxygen/classns3_1_1_point_to_point_net_device.html#adc4e5973337c576a2352e261cd844686> (
> pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
> ), can't we cast netDevice to PointToPointNetDevice or something similar ?

You can.  It is just "SetAttribute" method takes care of the fact that a specific NetDevice may not be PointToPointNetDevice and also not requires you to include point-to-point-net-device.h header file.   But again, you absolutely can do the dynamic cast, just make sure that the return value is not null (e.g., it is indeed PointToPointNetDevice-derived class).

---
Alex

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20160415/d87a0d3b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20160415/d87a0d3b/attachment.bin>


More information about the ndnSIM mailing list