Discussion:
simple wimax OnOffApp problem
Sebastian Wolny
2011-11-16 22:05:01 UTC
Permalink
Hi all,
I`m trying to prepare a simple wimax onoff application to present
differences between schedulers and flowservice types. OnOffApplication
is installed on the SS Node and the sink is installed on the p2pNode.
To
The problem is that the sink appliacation doesn`t receive packets
generated on SS. Could someone help to resolv the problem?
--
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-users-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to ns-3-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.
Sebastian Wolny
2011-11-16 22:53:03 UTC
Permalink
Sory,forgot to paste my code...

/* +-----+
// | SS0 | ()-->
// +-----+ \
// 10.1.1.1 \
// ------- \
// ((*)) \
// ---->-------->-------->------->------()
// 10.1.1.2
// +------------+ 10.1.2.1 10.1.2.2
// |Base Station| ==((*)) ---------------------- N1
// +------------+ N0 100Mbit,1ms
//
*/
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/mobility-module.h"
#include "ns3/config-store-module.h"
#include "ns3/wimax-module.h"
#include "ns3/internet-module.h"
#include "ns3/global-route-manager.h"
#include "ns3/ipcs-classifier-record.h"
#include "ns3/service-flow.h"
#include <iostream>
#include "ns3/point-to-point-module.h"
#include "ns3/flow-monitor-helper.h"
#include "ns3/flow-monitor.h"

NS_LOG_COMPONENT_DEFINE ("Wimax");

using namespace ns3;

int main (int argc, char *argv[])
{
bool verbose = false;

int duration = 5;
WimaxHelper::SchedulerType scheduler =
WimaxHelper::SCHED_TYPE_SIMPLE;

LogComponentEnable ("OnOffApplication", LOG_LEVEL_INFO);
LogComponentEnable ("PacketSink", LOG_LEVEL_INFO);

NodeContainer ssNodes;
NodeContainer bsNodes;
NodeContainer p2pNodes;

ssNodes.Create (1);
bsNodes.Create (1);
p2pNodes.Add (bsNodes.Get(0));
p2pNodes.Create (1);

PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue
("100Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("1ms"));

WimaxHelper wimax;

NetDeviceContainer ssDevs, bsDevs;
NetDeviceContainer p2pDevs;

p2pDevs = pointToPoint.Install (p2pNodes);

ssDevs = wimax.Install (ssNodes,
WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
scheduler);
bsDevs = wimax.Install (bsNodes,
WimaxHelper::DEVICE_TYPE_BASE_STATION,
WimaxHelper::SIMPLE_PHY_TYPE_OFDM, scheduler);

wimax.EnableAscii ("BS", bsDevs);
wimax.EnableAscii ("SS", ssDevs);
pointToPoint.EnableAscii ("p2p", p2pDevs);

Ptr<SubscriberStationNetDevice> ss;

ss = ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ();
ss->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);


Ptr<BaseStationNetDevice> bs;

bs = bsDevs.Get (0)->GetObject<BaseStationNetDevice> ();

InternetStackHelper stack;
stack.Install (bsNodes);
stack.Install (ssNodes);
stack.Install (p2pNodes.Get (1));

Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");

Ipv4InterfaceContainer SSinterfaces = address.Assign (ssDevs);
Ipv4InterfaceContainer BSinterface = address.Assign (bsDevs);

address.SetBase ("10.1.2.0", "255.255.255.0");
Ipv4InterfaceContainer p2pInterfaces = address.Assign (p2pDevs);

if (verbose)
{
wimax.EnableLogComponents (); // Turn on all wimax logging
}



DataRate dataRate ("1Mb/s");
OnOffHelper onoff = OnOffHelper ("ns3::UdpSocketFactory",
Address());
AddressValue remoteAddress
(InetSocketAddress(p2pInterfaces.GetAddress(1),1025));

onoff.SetAttribute ("Remote", remoteAddress);
onoff.SetAttribute ("OnTime", StringValue("Constant:0.01"));
onoff.SetAttribute ("OffTime", StringValue("Constant:0.5"));
onoff.SetAttribute ("DataRate", DataRateValue(dataRate));
onoff.SetAttribute ("PacketSize", UintegerValue(1024));

ApplicationContainer apps;
apps.Add(onoff.Install(ssNodes.Get(0)));

apps.Start (Seconds (1));
apps.Stop (Seconds (duration));


PacketSinkHelper sink = PacketSinkHelper ("ns3::UdpSocketFactory",
InetSocketAddress(p2pInterfaces.GetAddress(1),1025));
apps = sink.Install(p2pNodes.Get(1));

apps.Start(Seconds(0.9));
apps.Stop(Seconds(duration + 0.05));



Simulator::Stop(Seconds(duration + 0.1));


IpcsClassifierRecord ClassifierUgs (Ipv4Address("0.0.0.0"),
Ipv4Mask ("0.0.0.0"),
Ipv4Address("0.0.0.0"),
Ipv4Mask ("0.0.0.0"),
0,
65000,
0,
65000,
17,
1);



ServiceFlow * sf_up = new ServiceFlow(ServiceFlow::SF_DIRECTION_UP);
sf_up->SetServiceSchedulingType(ServiceFlow::SF_TYPE_BE);
sf_up->SetMaxSustainedTrafficRate(1000000);
sf_up->SetRequestTransmissionPolicy(0);
ServiceFlow * sf_down = new
ServiceFlow(ServiceFlow::SF_DIRECTION_DOWN);
sf_down->SetServiceSchedulingType(ServiceFlow::SF_TYPE_BE);
sf_down->SetMaxSustainedTrafficRate(1000000);
sf_down->SetRequestTransmissionPolicy(0);

//BsServiceFlowManager flowManager = BsServiceFlowManager(bs);
//flowManager.AddServiceFlow(sf_up);
//flowManager.AddServiceFlow(sf_down);

ss->AddServiceFlow(sf_up);
ss->AddServiceFlow(sf_down);


FlowMonitorHelper flowmonitor_helper = FlowMonitorHelper();
Ptr<FlowMonitor> monitor = flowmonitor_helper.InstallAll();
monitor->SetAttribute("DelayBinWidth", ns3::DoubleValue(0.001));
monitor->SetAttribute("JitterBinWidth", ns3::DoubleValue(0.001));
monitor->SetAttribute("PacketSizeBinWidth", ns3::DoubleValue(20));

Ipv4GlobalRoutingHelper::PopulateRoutingTables ();


NS_LOG_INFO ("Starting simulation.....");
Simulator::Run ();


std::map<FlowId, FlowMonitor::FlowStats> staty_per_flow = monitor-
GetFlowStats();
std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i;


for (i=staty_per_flow.begin();i != staty_per_flow.end(); i++)
{
std::cout << "Flow " << i->first <<" transmitted bitrate: " << i-
second.txBytes * 8 / (i->second.timeLastTxPacket / 100000000 - i-
second.timeFirstTxPacket / 100000000) / 100<<" Kb/s"<< std::endl;
std::cout << "Flow " << i->first << " received bitrate: " << i-
second.rxBytes * 8 / (i->second.timeLastRxPacket / 100000000 - i-
second.timeFirstRxPacket / 100000000) / 100<<" Kb/s"<< std::endl;
std::cout<<"------------------------"<<std::endl;
}
monitor->SerializeToXmlFile("wynik.xml",true,true);
Simulator::Destroy ();
NS_LOG_INFO ("Done.");

return 0;
}
--
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-users-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to ns-3-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.
Sebastian Wolny
2011-11-21 09:29:51 UTC
Permalink
Noone can help?
Post by Sebastian Wolny
Sory,forgot to paste my code...
/*      +-----+
//      | SS0 |  ()-->
//      +-----+       \
//     10.1.1.1        \
//      -------         \
//        ((*))          \
//                        ---->-------->-------->------->------()
//                  10.1.1.2
//               +------------+ 10.1.2.1                    10.1.2.2
//               |Base Station| ==((*)) ---------------------- N1
//               +------------+  N0         100Mbit,1ms
//
*/
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/mobility-module.h"
#include "ns3/config-store-module.h"
#include "ns3/wimax-module.h"
#include "ns3/internet-module.h"
#include "ns3/global-route-manager.h"
#include "ns3/ipcs-classifier-record.h"
#include "ns3/service-flow.h"
#include <iostream>
#include "ns3/point-to-point-module.h"
#include "ns3/flow-monitor-helper.h"
#include "ns3/flow-monitor.h"
NS_LOG_COMPONENT_DEFINE ("Wimax");
using namespace ns3;
int main (int argc, char *argv[])
{
  bool verbose = false;
  int duration = 5;
  WimaxHelper::SchedulerType scheduler =
WimaxHelper::SCHED_TYPE_SIMPLE;
  LogComponentEnable ("OnOffApplication", LOG_LEVEL_INFO);
  LogComponentEnable ("PacketSink", LOG_LEVEL_INFO);
  NodeContainer ssNodes;
  NodeContainer bsNodes;
  NodeContainer p2pNodes;
  ssNodes.Create (1);
  bsNodes.Create (1);
  p2pNodes.Add (bsNodes.Get(0));
  p2pNodes.Create (1);
  PointToPointHelper pointToPoint;
  pointToPoint.SetDeviceAttribute ("DataRate", StringValue
("100Mbps"));
  pointToPoint.SetChannelAttribute ("Delay", StringValue ("1ms"));
  WimaxHelper wimax;
  NetDeviceContainer ssDevs, bsDevs;
  NetDeviceContainer p2pDevs;
  p2pDevs = pointToPoint.Install (p2pNodes);
  ssDevs = wimax.Install (ssNodes,
                          WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
                          WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
                          scheduler);
  bsDevs = wimax.Install (bsNodes,
WimaxHelper::DEVICE_TYPE_BASE_STATION,
WimaxHelper::SIMPLE_PHY_TYPE_OFDM, scheduler);
  wimax.EnableAscii ("BS", bsDevs);
  wimax.EnableAscii ("SS", ssDevs);
  pointToPoint.EnableAscii ("p2p", p2pDevs);
  Ptr<SubscriberStationNetDevice> ss;
  ss = ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ();
  ss->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
  Ptr<BaseStationNetDevice> bs;
  bs = bsDevs.Get (0)->GetObject<BaseStationNetDevice> ();
  InternetStackHelper stack;
  stack.Install (bsNodes);
  stack.Install (ssNodes);
  stack.Install (p2pNodes.Get (1));
  Ipv4AddressHelper address;
  address.SetBase ("10.1.1.0", "255.255.255.0");
  Ipv4InterfaceContainer SSinterfaces = address.Assign (ssDevs);
  Ipv4InterfaceContainer BSinterface = address.Assign (bsDevs);
  address.SetBase ("10.1.2.0", "255.255.255.0");
  Ipv4InterfaceContainer p2pInterfaces = address.Assign (p2pDevs);
  if (verbose)
    {
      wimax.EnableLogComponents ();  // Turn on all wimax logging
    }
  DataRate dataRate ("1Mb/s");
  OnOffHelper onoff = OnOffHelper ("ns3::UdpSocketFactory",
Address());
  AddressValue remoteAddress
(InetSocketAddress(p2pInterfaces.GetAddress(1),1025));
  onoff.SetAttribute ("Remote", remoteAddress);
  onoff.SetAttribute ("OnTime", StringValue("Constant:0.01"));
  onoff.SetAttribute ("OffTime", StringValue("Constant:0.5"));
  onoff.SetAttribute ("DataRate", DataRateValue(dataRate));
  onoff.SetAttribute ("PacketSize", UintegerValue(1024));
  ApplicationContainer apps;
  apps.Add(onoff.Install(ssNodes.Get(0)));
  apps.Start (Seconds (1));
  apps.Stop (Seconds (duration));
  PacketSinkHelper sink = PacketSinkHelper ("ns3::UdpSocketFactory",
InetSocketAddress(p2pInterfaces.GetAddress(1),1025));
  apps = sink.Install(p2pNodes.Get(1));
  apps.Start(Seconds(0.9));
  apps.Stop(Seconds(duration + 0.05));
  Simulator::Stop(Seconds(duration + 0.1));
  IpcsClassifierRecord ClassifierUgs (Ipv4Address("0.0.0.0"),
                                        Ipv4Mask ("0.0.0.0"),
                                        Ipv4Address("0.0.0.0"),
                                        Ipv4Mask ("0.0.0.0"),
                                        0,
                                        65000,
                                        0,
                                        65000,
                                        17,
                                        1);
  ServiceFlow * sf_up = new ServiceFlow(ServiceFlow::SF_DIRECTION_UP);
  sf_up->SetServiceSchedulingType(ServiceFlow::SF_TYPE_BE);
  sf_up->SetMaxSustainedTrafficRate(1000000);
  sf_up->SetRequestTransmissionPolicy(0);
  ServiceFlow * sf_down = new
ServiceFlow(ServiceFlow::SF_DIRECTION_DOWN);
  sf_down->SetServiceSchedulingType(ServiceFlow::SF_TYPE_BE);
  sf_down->SetMaxSustainedTrafficRate(1000000);
  sf_down->SetRequestTransmissionPolicy(0);
  //BsServiceFlowManager flowManager = BsServiceFlowManager(bs);
  //flowManager.AddServiceFlow(sf_up);
  //flowManager.AddServiceFlow(sf_down);
  ss->AddServiceFlow(sf_up);
  ss->AddServiceFlow(sf_down);
  FlowMonitorHelper flowmonitor_helper = FlowMonitorHelper();
  Ptr<FlowMonitor> monitor = flowmonitor_helper.InstallAll();
  monitor->SetAttribute("DelayBinWidth", ns3::DoubleValue(0.001));
  monitor->SetAttribute("JitterBinWidth", ns3::DoubleValue(0.001));
  monitor->SetAttribute("PacketSizeBinWidth", ns3::DoubleValue(20));
  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
  NS_LOG_INFO ("Starting simulation.....");
  Simulator::Run ();
 std::map<FlowId, FlowMonitor::FlowStats> staty_per_flow = monitor->GetFlowStats();
 std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i;
 for (i=staty_per_flow.begin();i != staty_per_flow.end(); i++)
 {
  std::cout << "Flow " << i->first <<" transmitted bitrate: " << i-
second.txBytes * 8 / (i->second.timeLastTxPacket / 100000000 - i-
second.timeFirstTxPacket / 100000000) / 100<<" Kb/s"<< std::endl;
  std::cout << "Flow " << i->first << " received bitrate: " << i->second.rxBytes * 8 / (i->second.timeLastRxPacket / 100000000 - i-
second.timeFirstRxPacket / 100000000) / 100<<" Kb/s"<< std::endl;
  std::cout<<"------------------------"<<std::endl;
 }
  monitor->SerializeToXmlFile("wynik.xml",true,true);
  Simulator::Destroy ();
  NS_LOG_INFO ("Done.");
  return 0;
}
--
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-users-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
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.
Loading...