Browsing CODE [Attribute]

5 downloads 1604 Views 167KB Size Report
Create a Node. Ptr n= CreateObject;. When reference count falls to zero the object is deleted. NS3 provides a smart pointer class Ptr that provide ...
Browsing CODE [Attribute]

09-10/12/2014

NS3 Workshop:RIET College, Jaipur

1

RoadMap ●

Object Model



Attributes



Tracing



Gnuplot

09-10/12/2014

NS3 Workshop:RIET College, Jaipur

2

Object Model Classes Derived from following classes:Class Object

Properties : - Type & Attribute System - Object Aggregation - Smart-pointer

09-10/12/2014

Class ObjectBase

Properties : - Type & Attribute System - Object Aggregation - Smart-pointer

NS3 Workshop:RIET College, Jaipur

Class SimpleRefCount

Properties : - Type & Attribute System - Object Aggregation - Smart-pointer

3

Memory Management Maintain an internal reference count to determine when an object can safely deleted: - Ref() - increment the count of the object instance - UnRef() - decrement the count of the object instance

When reference count falls to zero the object is deleted NS3 provides a smart pointer Ref() and UnRef() method.

class Ptr that provide a pair of

Reference counted object are usually allocated using a templated Create or CreateObject methods

Example : Create a Node Ptr n= CreateObject; 09-10/12/2014

NS3 Workshop:RIET College, Jaipur

4

Object Aggregation ●



Object can be aggregated to access each other , and for the user to easily access individual object in an aggregation. Avoid encompassing all possible functionality Node

Mobility

Retrieving an object Ptr mob= node1->GetObject(); Aggregate an object 09-10/12/2014

NS3 Workshop:RIET College, Jaipur node2->AggregateObject(mob)

5

Example ●

Node –

Aggregate point to point netdeivce to node

Sample Code

Ptr n = CreateObject(); Ptr p2p = CreateObject(); p2p->SetNode(n); n->AggregateObject(p2p);

09-10/12/2014

NS3 Workshop:RIET College, Jaipur

6

Typeid ●



This class provide a unique identified for an interface This is a class that records a lot of metainformation about the subclass of Object classes –

the base class of the subclass



the set of accessible constructor in the subclass



the set of attributes accessible in the subclass



Tracing mechanism

09-10/12/2014

NS3 Workshop:RIET College, Jaipur

7

TypeId GetTypeId(void) ●





Return TypeId-object to identify and characterize object. Contain object type , constructor and parent object Define the object attribute and trace source

09-10/12/2014

NS3 Workshop:RIET College, Jaipur

8

Typeid Object

Node

NetDevice

Typeid



09-10/12/2014

NS3 Workshop:RIET College, Jaipur

9

Attributes ●





Goal of Attribute system is to organize the access of internal members objects of a simulation. Most often user is interested in studying or tracing particular internal variables. Example: –

What is network performance if we change the packet size?



How transmission time varies with data rate?

09-10/12/2014

NS3 Workshop:RIET College, Jaipur

10

Attribute ●





Set a default value of member variable Set or Get the values of an already instantiated queue Example: –

Modify the no of Route Request Retry attribute and check the result in AODV Classes like Node

Classes like Node

GetAttribute()

SetAttribute() Typeid

AddAttribute() 09-10/12/2014

NS3 Workshop:RIET College, Jaipur

11

Attribute ●

How to add attribute? –

Typeid AddAttribute(...)



Sample Code

Brief Description

Name of attribute Type of value Accessing variable

09-10/12/2014

NS3 Workshop:RIET College, Jaipur

12

AODV ●

List of Attributes: –

Hello Interval



RreqRetries



NetDiameter



PathDiscoveryTime



MaxQueueLen



MaxQueueTime



Gratuitous Reply



and few more

09-10/12/2014

NS3 Workshop:RIET College, Jaipur

13

Example ●



Example code –

ns3.21/src/aodv/aodv.cc



copy in scratch/

Modify the code and create 10 nodes with RandomWalk2dMobilityModel and show the output in NetAnim Modified Topology

Current Topology

3

5 1

2

3

4

NS3 Workshop:RIET College, Jaipur

7

2

4 1

09-10/12/2014

9

6

8

10 14

Adding New Typid ●

Example -1 –

Add new attribute in AODV Routing Protocol of boolean type.



Attribute Detail ● ●

09-10/12/2014

Name -SampleAttribute Type - Boolean

NS3 Workshop:RIET College, Jaipur

15

To be Continued ...

09-10/12/2014

NS3 Workshop:RIET College, Jaipur

16