About onoff application

244 views
Skip to first unread message

Lily

unread,
Nov 5, 2015, 4:06:22 PM11/5/15
to ns-3-users
Hi all,

I used onoff application in my test. I generated several flows with different source and destination. But I found that only the first one flow was generated.  I use udp server instead of packetsink application. My code logic as below:

udpserverhelper install on all nodes;

for(int i = src_start;  i < src_end; i++) {
    j = random_num;  //server
    Flow f(i, j);
    path = vector<int>();
    path = findPath(f);
    
   //-----------client start to send packets
  AddressValue remoteAddress (InetSocketAddress (j, 5000));

  OnOffHelper clientHelper ("ns3::UdpSocketFactory", Address ());

  clientHelper.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"));
  clientHelper.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"));
  clientHelper.SetAttribute ("Remote", remoteAddress);
  clientHelper.SetAttribute("Flowid", UintegerValue(f.fid));

   ApplicationContainer apps = client.Install (nodes.Get(path[0]));

}


In the test, 32 flows were setted.  When I checked the xml file, I just see one flow the first flow.  I don't know what's the problem.  The onoff application just support only one destination for different sources ?  Thanks.


Tommaso Pecorella

unread,
Nov 5, 2015, 5:17:01 PM11/5/15
to ns-3-users
Hi,

you can generate how many applications you want, and each of them can have how many flows it wants (OnOff just uses one flow per application).
The source code is not complete, and it's using non-standard stuff, so I can't say much. However I'd check the following:
1) All the applications are started (and not just one),
2) How you track the flows. Perhaps there are more flows and you're just not seeing them.

T.
Message has been deleted

Lily

unread,
Nov 5, 2015, 5:27:23 PM11/5/15
to ns-3-users
class Tools {
static void run(F f, int & fail_flow) {
vector <int> path;
findPath(f, path);

//--------------install routes
//get server ip address
Ipv4Address dest;
int lid1 = path[path.size()-2];
int lid2 = path[path.size()-1];
if (interfaces.count(ii(lid1, lid2))) {
dest = interfaces[ii(lid1, lid2)].GetAddress(1);
} else {
dest = interfaces[ii(lid2, lid1)].GetAddress(0);
}

.......................................................
//-----------client start to send packets
Address remoteAddress (InetSocketAddress (dest, 5000));

OnOffHelper clientHelper ("ns3::UdpSocketFactory", remoteAddress);
// clientHelper.SetAttribute ("OnTime", StringValue ("ns3::ExponentialRandomVariable[Mean=2]"));
// clientHelper.SetAttribute ("OffTime", StringValue ("ns3::ExponentialRandomVariable[Mean=0.5]"));

clientHelper.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"));
    clientHelper.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
clientHelper.SetAttribute("Flowid", UintegerValue(f.fid));

cout << "Onoff send at node " << nodes.Get(path[0])->GetId() << endl;
cout << "Onoff end at node " << dest << endl;

ApplicationContainer apps = clientHelper.Install (nodes.Get(path[0]));
apps.Start (Simulator::Now()); /* delay startup depending on node number */
apps.Stop (Seconds (cOffT));
cout <<"Flow " << f.fid << " start " <<Simulator::Now() <<endl;

path.clear();
}

};


  
int main() {
       uint16_t servPort = 8080;
PacketSinkHelper sinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), servPort));
// start a sink client on all nodes
ApplicationContainer sinkApp = sinkHelper.Install (nodes);
sinkApp.Start (Seconds (sOnT));
sinkApp.Stop (Seconds (sOffT));
 
  int flow_id = 0;

    //each host send to other host randomly
    int head = (1-pow(branch, level-1))/(1-branch);

    for(int i = head; i <= 52; i++) {
     int dst = 0;
        dst = getRandom(i);
     F f(i, dst, flow_id);
     flow_id++;
     cout << "src " << i << " dst " << dst <<endl;

  Tools::run(f, fail_flow);

//      Simulator::Schedule(Seconds(cOnT), &Tools::run, f, fail_flow);
    }

        FlowMonitorHelper flowmonHelper;
flowmonHelper.InstallAll (); 

// get xml file

}


That's the main piece of my code. I  saw the flows generated from xml files.  I haven't figure out what's the problem. 

Tommaso Pecorella

unread,
Nov 5, 2015, 6:21:17 PM11/5/15
to ns-3-users
Still no idea. I can't seem where the simulation is effectively started, so I have some lingering doubts.
One thing is weird tho, this line:
 apps.Start (Simulator::Now()); /* delay startup depending on node number */

According to where it is, all the apps will be started at time 0. This can cause an ARP storm and serious issues in establishing flows.

T.

Message has been deleted

Lily

unread,
Nov 5, 2015, 7:08:22 PM11/5/15
to ns-3-users


I defined a variable : double cOnT = 0.0.  If I use apps.Start (Seconds(cOnT)), all flows should start at the same time 0.0. Will it has the same problem? What's the common methods?

Actually, I never thought about ARP before. Before this, when I use udp client application to generate traffic, it works fine. The problem raised just when I change to onoff application. 

Logic of my code: (1) in main() ,generate source and destination id to define a flow ,and give each flow a flow id. This part is the for loop in main.

(2) then in the for loop , call the function run(flow, ..) of class Tools. This function will find a path for each flow, and add a host route entry on each node of the path. The route entry matched on flow id, that's why I add a flow id tag for each flow.  After that, I generate traffic use Onoff application. Client is the first hop of the path, and server is the last hop of the path.

In fact, when I used UDP client and server application, it works fine. Then I just modified the application and didn't touch any other part of the code it can work , but just only one flow generated. That's confusing.

I appreciate your help.

Jack Higgins

unread,
Nov 8, 2015, 9:35:21 PM11/8/15
to ns-3-users

Hi lily ,

I will just jump in the middle of the post.
First just try what Tommaso suggested . Try to have a deviation of time between the start of your applications. ( a few milliseconds should do the trick). This DOES matter. You might have some interesting results after that.

Keep me posted of your results... I am doing similar tests right now. :)

Best Regards,

Jack

Wenrui Ma

unread,
Nov 9, 2015, 10:03:17 AM11/9/15
to ns-3-...@googlegroups.com
I wrote my own routing algorithm. I try the suggestion, it doesn't work for me. Now I still use UDP application to simulate OnOff application. Hope you are doing well.


Regards,
Wenrui Ma

--
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/zfw3Yc5mU8E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages