Is there an easy way to calculate Link Utilization?

2,815 views
Skip to first unread message

Syd

unread,
Jan 24, 2012, 11:05:26 PM1/24/12
to ns-3-users
Hi Everyone,
I am using the flow monitor to capture network
statistics such as RTT, packet loss ratio etc. Is there some way I can
use it or calculate link utilization (for every link in the network)?
If not, is there some other means I can use to extract this info?
Thanks.

Cheers!
Syd

posco

unread,
Jan 26, 2012, 12:17:23 PM1/26/12
to ns-3-users
link utilisation = (flow on the link/capacity of the link) in specific
time window.

Syd

unread,
Jan 26, 2012, 12:41:58 PM1/26/12
to ns-3-users
True. But let me rephrase the question:

How would I determine the flow on a link? Flow monitor provides the
flow on a route. However, this route could contain multiple links.

If this were a smaller network (say 20 nodes), I could probably send a
packet from every source node to every destination and use the
AsciiTraceHelper to get the links on the routes. But with 118 node
network, this may take forever.

Thanks!
Syd

posco

unread,
Jan 26, 2012, 2:01:14 PM1/26/12
to ns-3-users
what I meant is no way to infer link utilisation from rtt and loss. In
stead, you may try to install trace on every node, e.g.

void FlowTrace::SetupTxTrace(int dev_id, int ith_id)
{
std::ostringstream oss;
oss << "/NodeList/"<<dev_id<<"/DeviceList/"<<ith_id<<"/
$ns3::CsmaNetDevice/TxQueue/Dequeue";
Config::Connect (oss.str (), MakeCallback (&FlowTrace::TxTrace,
this));
}

and then in the callback, capture number of bytes entering the link.

void FlowTrace::TxTrace(std::string context, Ptr<Packet const> packet)
{
total_bytes[dev][iface]+=packet->GetSize();
}

and then compute link utilisation for every specified time window
(e.g. 1s)

void FlowTrace::CalcStatictis()
{
//compute link utilisation
...
...
Simulator::Schedule (Seconds (1), &FlowTrace::CalcStatictis,
this);
}


Hope this helps.

-Posco

Ali Sydney

unread,
Jan 29, 2012, 1:27:35 PM1/29/12
to ns-3-...@googlegroups.com
How should I go about determining the values for "dev" and "iface" in "total_bytes[dev][iface]" as defined in the function "TxTrace"?


REF:
Below is a snapshot of the actual script where I'm trying to print the number of bytes on each interface of every node. However, in my call to "CalcStatictis" the total_bytes values are always 0. It appears that "total_bytes[dev][iface]" is not being populated. 

// Install a trace on all pointToPoint interfaces of every node
void NS3ElectricalModel::SetupTxTrace(int dev_id, int ith_id)
{
   std::ostringstream oss;
   oss << "/NodeList/"<<dev_id<<"/DeviceList/"<<ith_id<<"/$ns3::PointToPointNetDevice/TxQueue/Dequeue";
   Config::Connect (oss.str (), MakeCallback (&NS3ElectricalModel::TxTrace, this));
}

// Callback
void NS3ElectricalModel::TxTrace(std::string context, Ptr<Packet const> packet)
{
     total_bytes[devI][ifaceI]+=packet->GetSize();

}

void NS3ElectricalModel::CalcStatictis()
{
   //compute link utilisation
int node, eth;
node=eth=0;

// For every node in the node container "Nodes_Tier3"
  for (NodeContainer::Iterator n = Nodes_Tier3.Begin (); n != Nodes_Tier3.End (); ++n) 
    {
      Ptr<Node> n = *node;
     
      // For every interface on node "n"
      for (uint32_t eth = 0; eth < n->GetNDevices (); ++eth)
        {
            // Print out the number of bytes
           std::cout<<"Interface " << "\t" << eth << "\t" << "bytes" << total_bytes[node][eth]
          eth++;
        }
     node++;
     eth=0;
    }

   Simulator::Schedule (Seconds (1), &NS3ElectricalModel::CalcStatictis,this);
}

-Syd





--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To post to this group, send email to ns-3-...@googlegroups.com.
To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.


Syd

unread,
Jan 29, 2012, 7:41:40 PM1/29/12
to ns-3-users
In my previous post, I said "total_bytes[dev][iface]" was not being
populated. Actually, I manually set dev=0 and iface=0 and so
total_bytes[0][0] was being populated. However, can you help me figure
out how to dynamically set "dev" and "iface"?

posco

unread,
Jan 30, 2012, 5:09:08 AM1/30/12
to ns-3-users
dev = i-th node.
iface = j-th devices in i-th node.

e.g.

for(int i=0; i<(int)c.GetN(); i++)
{
for(int j=1; j<(int)c.Get(i)->GetNDevices(); j++)
{
SetupTxTrace(i,j);
}
}

-Posco

Ali Sydney

unread,
Jan 30, 2012, 9:16:21 AM1/30/12
to ns-3-...@googlegroups.com
I do something similar when calling  "SetupTxTrace" as shown in the REF. However, in the "TxTrace" function, how are the values for "dev" and "iface" passed to this function (i.e. TxTrace)? Does the "Connect" call from "SetupTxTrace" implicitly pass the values for "dev" and "iface" to TxTrace? 

Config::Connect (oss.str (), MakeCallback (&NS3ElectricalModel::TxTrace,
 this));



REF:

// IN MAIN FUNCTION
...

  NetDeviceContainer devs;
  for (NodeContainer::Iterator i = Nodes_Tier3.Begin (); i != Nodes_Tier3.End (); ++i)
    {
      Ptr<Node> node = *i;
      for (uint32_t j = 0; j < node->GetNDevices (); ++j)
        {
          devs.Add (node->GetDevice (j));
        }
    }

  // Setup trace on all devices 
  for (NetDeviceContainer::Iterator i = devs.Begin (); i != devs.End (); ++i)
    {
      Ptr<NetDevice> dev = *i;
      NS3ElectricalModel::SetupTxTrace( dev->GetNode ()->GetId (), dev->GetIfIndex ());
     }

 NS3ElectricalModel::CalcStatictis();

...

}

//END OF MAIN FUNCTION


 // Install a trace on all pointToPoint interfaces of every node
void 
NS3ElectricalModel::SetupTxTrace(int dev_id, int ith_id)
 {
    std::ostringstream oss;
    oss <<
 "/NodeList/"<<dev_id<<"/DeviceList/"<<ith_id<<"/$ns3::PointToPointNetDevice /TxQueue/Dequeue";
    Config::Connect (oss.str (), MakeCallback (&NS3ElectricalModel::TxTrace,
 this));
 }

 // Callback
 void 
NS3ElectricalModel::TxTrace(std::string context, Ptr<Packet const>
 packet)
 {
      total_bytes[dev][iface]+=packet->GetSize();
 }

void 

Syd

unread,
Jan 30, 2012, 9:57:50 AM1/30/12
to ns-3-users
From your previous post, that is correct (i.e. passing the node and
its corresponding device to to SetupTxTrace): and I have done
something similar (as shown in the previous post).

But I was referring to to the values of "dev" and "iface" in the
function "TxTrace". Which function passes these values to "TxTrace"?
It appears that "SetupTxTrace" makes a "Connect" call to "TxTrace".
Are the values for "dev" and "iface" implicitly passed? Or do I have
to modify the connect call as follows?

Config::Connect (oss.str (), MakeCallback
(&NS3ElectricalModel::TxTrace,this, dev_id, ith_id));

-Syd

posco

unread,
Jan 31, 2012, 5:56:20 AM1/31/12
to ns-3-users
NS3ElectricalModel::TxTrace(std::string context, Ptr<Packet
const>packet)
{
//"dev" and "iface" are incorporated in context string, so you'll need
to parse the string for retrieving them

Syd

unread,
Jan 31, 2012, 6:04:46 PM1/31/12
to ns-3-users
Hi Posco,
Everything works perfectly! Thanks a million!

Cheers!
Syd
> > > > To unsubscribe from this...
>
> read more »
Reply all
Reply to author
Forward
0 new messages