WiMAX module suports several uplink schedulers
authorFlavio Kubota <flaviokubota@gmail.com>
Tue Aug 11 15:02:12 2009 -0300 (6 months ago)
changeset 4533e47d6551e51a
parent 4532 f0fabfce95cc
child 4534 d83c8c86b46b
WiMAX module suports several uplink schedulers
src/devices/wimax/uplink-scheduler.cc
src/devices/wimax/uplink-scheduler.h
src/devices/wimax/wimax-bs-net-device.cc
src/devices/wimax/wimax-bs-net-device.h
src/devices/wimax/wimax-net-device.cc
src/devices/wimax/wimax-net-device.h
src/devices/wimax/wimax-ss-net-device.cc
src/devices/wimax/wscript
src/helper/wimax-helper.cc
src/helper/wimax-helper.h
     1.1 --- a/src/devices/wimax/uplink-scheduler.cc	Mon Aug 10 09:48:12 2009 -0300
     1.2 +++ b/src/devices/wimax/uplink-scheduler.cc	Tue Aug 11 15:02:12 2009 -0300
     1.3 @@ -38,6 +38,12 @@
     1.4  namespace ns3
     1.5  {
     1.6  
     1.7 +  NS_OBJECT_ENSURE_REGISTERED (UplinkScheduler);
     1.8 +
     1.9 +  UplinkScheduler::UplinkScheduler()
    1.10 +  {
    1.11 +  }
    1.12 +
    1.13    UplinkScheduler::UplinkScheduler(Ptr<WimaxBaseStationNetDevice> bs) :
    1.14      m_bs(bs), m_timeStampIrInterval(Seconds(0)), m_nrIrOppsAllocated(0),
    1.15          m_isIrIntrvlAllocated(false), m_isInvIrIntrvlAllocated(false),
    1.16 @@ -51,6 +57,14 @@
    1.17      m_uplinkAllocations.clear();
    1.18    }
    1.19  
    1.20 +  TypeId
    1.21 +  UplinkScheduler::GetTypeId(void)
    1.22 +  {
    1.23 +    static TypeId tid =
    1.24 +        TypeId("ns3::UplinkScheduler") .SetParent<Object> () .AddConstructor<UplinkScheduler> ();
    1.25 +    return tid;
    1.26 +  }
    1.27 +
    1.28    uint8_t
    1.29    UplinkScheduler::GetNrIrOppsAllocated(void) const
    1.30    {
    1.31 @@ -1008,4 +1022,10 @@
    1.32        }
    1.33    }
    1.34  
    1.35 +  void
    1.36 +  UplinkScheduler::ConfigureBs(Ptr<WimaxBaseStationNetDevice> bs)
    1.37 +  {
    1.38 +    m_bs = bs;
    1.39 +  }
    1.40 +
    1.41  }//namespace ns3
     2.1 --- a/src/devices/wimax/uplink-scheduler.h	Mon Aug 10 09:48:12 2009 -0300
     2.2 +++ b/src/devices/wimax/uplink-scheduler.h	Tue Aug 11 15:02:12 2009 -0300
     2.3 @@ -28,6 +28,7 @@
     2.4  #include "wimax-phy.h"
     2.5  #include "ul-job.h"
     2.6  #include "service-flow-record.h"
     2.7 +#include "ns3/object.h"
     2.8  
     2.9  namespace ns3
    2.10  {
    2.11 @@ -38,12 +39,16 @@
    2.12    class ServiceFlowRecord;
    2.13    class UlJob;
    2.14  
    2.15 -  class UplinkScheduler
    2.16 +  class UplinkScheduler : public Object
    2.17    {
    2.18    public:
    2.19 +    UplinkScheduler ();
    2.20      UplinkScheduler(Ptr<WimaxBaseStationNetDevice> bs);
    2.21      ~UplinkScheduler(void);
    2.22  
    2.23 +    static TypeId
    2.24 +    GetTypeId(void);
    2.25 +
    2.26      uint8_t
    2.27      GetNrIrOppsAllocated(void) const;
    2.28      bool
    2.29 @@ -64,6 +69,7 @@
    2.30      void
    2.31      AddUplinkAllocation(OfdmUlMapIe &ulMapIe, const uint32_t &allocationSize,
    2.32          uint32_t &symbolsToAllocation, uint32_t &availableSymbols);
    2.33 +
    2.34      void
    2.35      Schedule(void);
    2.36      void
    2.37 @@ -109,6 +115,9 @@
    2.38      int
    2.39      ComparePriority (PriorityUlJob & a, PriorityUlJob & b);
    2.40  
    2.41 +    void
    2.42 +    ConfigureBs(Ptr<WimaxBaseStationNetDevice> bs);
    2.43 +
    2.44    private:
    2.45      Ptr<WimaxBaseStationNetDevice> m_bs;
    2.46      std::list<OfdmUlMapIe> m_uplinkAllocations;
     3.1 --- a/src/devices/wimax/wimax-bs-net-device.cc	Mon Aug 10 09:48:12 2009 -0300
     3.2 +++ b/src/devices/wimax/wimax-bs-net-device.cc	Tue Aug 11 15:02:12 2009 -0300
     3.3 @@ -22,11 +22,11 @@
     3.4  #include "ns3/simulator.h"
     3.5  #include "ns3/drop-tail-queue.h"
     3.6  #include "ns3/node.h"
     3.7 +#include "uplink-scheduler.h"
     3.8  #include "wimax-bs-net-device.h"
     3.9  #include "wimax-phy.h"
    3.10  #include "packet-burst.h"
    3.11  #include "ss-record.h"
    3.12 -#include "uplink-scheduler.h"
    3.13  #include "bs-scheduler.h"
    3.14  #include "wimax-mac-queue.h"
    3.15  #include "burst-profile-manager.h"
    3.16 @@ -58,11 +58,18 @@
    3.17    {
    3.18      static TypeId
    3.19          tid =
    3.20 -            TypeId("ns3::WimaxBaseStationNetDevice") .SetParent<WimaxNetDevice> () .AddConstructor<
    3.21 -                WimaxBaseStationNetDevice> () .AddTraceSource(
    3.22 +            TypeId("ns3::WimaxBaseStationNetDevice")
    3.23 +            .SetParent<WimaxNetDevice> ()
    3.24 +            .AddConstructor<WimaxBaseStationNetDevice> ()
    3.25 +            .AddTraceSource(
    3.26                  "BSRx",
    3.27                  "XXX",
    3.28 -                MakeTraceSourceAccessor(&WimaxBaseStationNetDevice::m_traceBSRx));
    3.29 +                MakeTraceSourceAccessor(&WimaxBaseStationNetDevice::m_traceBSRx))
    3.30 +            .AddAttribute ("UplinkScheduler", "Uplink Scheduler for BS",
    3.31 +               PointerValue (),
    3.32 +               MakePointerAccessor (&WimaxBaseStationNetDevice::m_uplinkScheduler),
    3.33 +               MakePointerChecker<UplinkScheduler> ())
    3.34 +                ;
    3.35      return tid;
    3.36    }
    3.37  
    3.38 @@ -89,14 +96,15 @@
    3.39          m_ulAllocationNumber(0), m_rangingOppNumber(0), m_cidFactory(
    3.40              new ConnectionIdentifierFactory()), m_ssManager(new SSManager()),
    3.41          m_allocationStartTime(0), m_classifier(Create<
    3.42 -            MacAddressPacketClassifier> ()), m_uplinkScheduler(
    3.43 -            new UplinkScheduler(this)), m_scheduler(new BSScheduler(this)),
    3.44 +            MacAddressPacketClassifier> ()), m_scheduler(new BSScheduler(this)),
    3.45          m_linkManager(new BSLinkManager(this)), m_psDuration(Seconds(0))
    3.46    {
    3.47      LogComponentEnable("WimaxBaseStationNetDevice", LOG_LEVEL_INFO);
    3.48      mbs_classifier = new IPCS_BS_Packet_classifier(this);
    3.49      m_symbolDuration = Seconds(0);
    3.50 -    m_uplinkScheduler->UplinkSchedWindowTimer();
    3.51 +    //m_uplinkScheduler->UplinkSchedWindowTimer();
    3.52 +    //m_uplinkSchedulert->UplinkSchedWindowTimer();
    3.53 +
    3.54    }
    3.55  
    3.56    WimaxBaseStationNetDevice::~WimaxBaseStationNetDevice(void)
    3.57 @@ -108,8 +116,9 @@
    3.58    {
    3.59      delete m_cidFactory;
    3.60      delete m_ssManager;
    3.61 -    delete m_uplinkScheduler;
    3.62      delete m_scheduler;
    3.63 +
    3.64 +    m_uplinkScheduler = 0;
    3.65      m_cidFactory = 0;
    3.66      m_ssManager = 0;
    3.67      m_uplinkScheduler = 0;
    3.68 @@ -294,7 +303,7 @@
    3.69      return m_classifier;
    3.70    }
    3.71  
    3.72 -  UplinkScheduler*
    3.73 +  Ptr<UplinkScheduler>
    3.74    WimaxBaseStationNetDevice::GetUplinkScheduler(void) const
    3.75    {
    3.76      return m_uplinkScheduler;
    3.77 @@ -435,6 +444,12 @@
    3.78      std::cout << "\t\tPaket Size:  " << packet->GetSize() << std::endl;
    3.79      std::cout << "\t\tProtocol:    " << protocolNumber << std::endl;
    3.80  
    3.81 +    std::cout << "TraceDelay: TX (BS), To: " << dest
    3.82 +              << ", Uid: " << packet->GetUid ()
    3.83 +              << ", time: " << (Simulator::Now()).GetSeconds ()
    3.84 +              << ", Packet Size:  " << packet->GetSize()
    3.85 +              << std::endl;
    3.86 +
    3.87      if (protocolNumber == 2048)
    3.88        {
    3.89          //SSRecord *ssRecord = m_ssManager->GetSSRecord(dest);
     4.1 --- a/src/devices/wimax/wimax-bs-net-device.h	Mon Aug 10 09:48:12 2009 -0300
     4.2 +++ b/src/devices/wimax/wimax-bs-net-device.h	Tue Aug 11 15:02:12 2009 -0300
     4.3 @@ -31,6 +31,8 @@
     4.4  #include "ns3/ipv4-address.h"
     4.5  #include "IPCS_BS_Packet_classifier.h"
     4.6  #include "IPCS_BS_Bind_Parameter_Record.h"
     4.7 +//#include "uplink-scheduler.h"
     4.8 +
     4.9  
    4.10  namespace ns3
    4.11  {
    4.12 @@ -39,12 +41,12 @@
    4.13    class Packet;
    4.14    class SSRecord;
    4.15    class SSManager;
    4.16 -  class UplinkScheduler;
    4.17    class BSScheduler;
    4.18    class BurstProfileManager;
    4.19    class BSLinkManager;
    4.20    class PacketClassifier;
    4.21    class IPCS_BS_Packet_classifier;
    4.22 +  class UplinkScheduler;
    4.23  
    4.24    class WimaxBaseStationNetDevice : public WimaxNetDevice
    4.25    {
    4.26 @@ -123,7 +125,7 @@
    4.27      GetSSManager(void) const;
    4.28      Ptr<PacketClassifier>
    4.29      GetClassifier(void) const;
    4.30 -    UplinkScheduler*
    4.31 +    Ptr<UplinkScheduler>
    4.32      GetUplinkScheduler(void) const;
    4.33      BSLinkManager*
    4.34      GetLinkManager(void) const;
    4.35 @@ -267,7 +269,10 @@
    4.36      uint32_t m_allocationStartTime;
    4.37  
    4.38      Ptr<PacketClassifier> m_classifier;
    4.39 -    UplinkScheduler *m_uplinkScheduler;
    4.40 +    //UplinkScheduler *m_uplinkScheduler;
    4.41 +    Ptr<UplinkScheduler> m_uplinkScheduler;
    4.42 +
    4.43 +
    4.44      BSScheduler *m_scheduler;
    4.45      BSLinkManager *m_linkManager;
    4.46  
     5.1 --- a/src/devices/wimax/wimax-net-device.cc	Mon Aug 10 09:48:12 2009 -0300
     5.2 +++ b/src/devices/wimax/wimax-net-device.cc	Tue Aug 11 15:02:12 2009 -0300
     5.3 @@ -54,24 +54,32 @@
     5.4    {
     5.5      static TypeId
     5.6          tid =
     5.7 -            TypeId("ns3::WimaxNetDevice") .SetParent<NetDevice> () .AddAttribute(
     5.8 +            TypeId("ns3::WimaxNetDevice")
     5.9 +            .SetParent<NetDevice> ()
    5.10 +            .AddAttribute(
    5.11                  "Node", "XXX", PointerValue(), MakePointerAccessor(
    5.12                      &WimaxNetDevice::GetNode, &WimaxNetDevice::SetNode),
    5.13 -                MakePointerChecker<Node> ()) .AddAttribute("Phy", "XXX",
    5.14 +                MakePointerChecker<Node> ())
    5.15 +            .AddAttribute("Phy", "XXX",
    5.16                  PointerValue(), MakePointerAccessor(&WimaxNetDevice::GetPhy,
    5.17 -                    &WimaxNetDevice::SetPhy), MakePointerChecker<WimaxPhy> ()) .AddAttribute(
    5.18 +                    &WimaxNetDevice::SetPhy), MakePointerChecker<WimaxPhy> ())
    5.19 +            .AddAttribute(
    5.20                  "InitialRangingConnection",
    5.21                  "XXX",
    5.22                  PointerValue(),
    5.23                  MakePointerAccessor(&WimaxNetDevice::m_initialRangingConnection),
    5.24 -                MakePointerChecker<WimaxConnection> ()) .AddAttribute(
    5.25 +                MakePointerChecker<WimaxConnection> ())
    5.26 +            .AddAttribute(
    5.27                  "BroadcastConnection", "XXX", PointerValue(),
    5.28                  MakePointerAccessor(&WimaxNetDevice::m_broadcastConnection),
    5.29 -                MakePointerChecker<WimaxConnection> ()) .AddAttribute(
    5.30 +                MakePointerChecker<WimaxConnection> ())
    5.31 +            .AddAttribute(
    5.32                  "MaxMsduSize", "XXX", UintegerValue(1500),
    5.33                  MakeUintegerAccessor(&WimaxNetDevice::m_maxMsduSize),
    5.34 -                MakeUintegerChecker<uint16_t> (1, 1500)) .AddTraceSource("Rx",
    5.35 -                "XXX", MakeTraceSourceAccessor(&WimaxNetDevice::m_traceRx)) .AddTraceSource(
    5.36 +                MakeUintegerChecker<uint16_t> (1, 1500))
    5.37 +            .AddTraceSource("Rx",
    5.38 +                "XXX", MakeTraceSourceAccessor(&WimaxNetDevice::m_traceRx))
    5.39 +            .AddTraceSource(
    5.40                  "Tx", "XXX",
    5.41                  MakeTraceSourceAccessor(&WimaxNetDevice::m_traceTx));
    5.42      return tid;
    5.43 @@ -565,5 +573,17 @@
    5.44      NS_LOG_LOGIC("MAC IPv6 multicast address is " << ad);
    5.45      return ad;
    5.46    }
    5.47 +/*
    5.48 +  Ptr<UplinkScheduler>
    5.49 +  WimaxNetDevice::GetUplinkScheduler(void)
    5.50 +  {
    5.51 +    return m_uplinkScheduler;
    5.52 +  }
    5.53 +
    5.54 +  void
    5.55 +  WimaxNetDevice::SetUplinkScheduler (Ptr<UplinkScheduler> uplinkScheduler)
    5.56 +  {
    5.57 +    m_uplinkScheduler = uplinkScheduler;
    5.58 +  }*/
    5.59  
    5.60  }//namespace ns3
     6.1 --- a/src/devices/wimax/wimax-net-device.h	Mon Aug 10 09:48:12 2009 -0300
     6.2 +++ b/src/devices/wimax/wimax-net-device.h	Tue Aug 11 15:02:12 2009 -0300
     6.3 @@ -54,6 +54,7 @@
     6.4    class ConnectionManager;
     6.5    class ServiceFlowManager;
     6.6    class BandwidthManager;
     6.7 +  class UplinkScheduler;
     6.8  
     6.9    class WimaxNetDevice : public NetDevice
    6.10    {
    6.11 @@ -223,6 +224,11 @@
    6.12      GetMobility(void);
    6.13      void
    6.14      SetMobility(Ptr<Object> mobility);
    6.15 +/*
    6.16 +    Ptr<UplinkScheduler>
    6.17 +    GetUplinkScheduler(void);
    6.18 +    void
    6.19 +    SetUplinkScheduler (Ptr<UplinkScheduler> uplinkScheduler);*/
    6.20  
    6.21    private:
    6.22      virtual bool
     7.1 --- a/src/devices/wimax/wimax-ss-net-device.cc	Mon Aug 10 09:48:12 2009 -0300
     7.2 +++ b/src/devices/wimax/wimax-ss-net-device.cc	Tue Aug 11 15:02:12 2009 -0300
     7.3 @@ -421,11 +421,13 @@
     7.4      std::cout << "SS (" << source << "):" << std::endl;
     7.5      std::cout << "\tSending packet..." << std::endl;
     7.6      std::cout << "\t\tDestination: " << dest << std::endl;
     7.7 -    std::cout << "\t\tPaket Size:  " << packet->GetSize() << std::endl;
     7.8 +    std::cout << "\t\tPacket Size:  " << packet->GetSize() << std::endl;
     7.9      std::cout << "\t\tProtocol:    " << protocolNumber << std::endl;
    7.10 -    std::cout << "TraceDelay: TX (SS), To: " << dest 
    7.11 -              << ", Uid: " << packet->GetUid () 
    7.12 -              << ", time: " << Simulator::Now() << std::endl;
    7.13 +    std::cout << "TraceDelay: TX (SS), To: " << dest
    7.14 +              << ", Uid: " << packet->GetUid ()
    7.15 +              << ", time: " << (Simulator::Now()).GetSeconds ()
    7.16 +              << ", Packet Size:  " << packet->GetSize()
    7.17 +              << std::endl;
    7.18  
    7.19      ServiceFlow *serviceFlow = 0;
    7.20  #ifdef JDEBUG1
     8.1 --- a/src/devices/wimax/wscript	Mon Aug 10 09:48:12 2009 -0300
     8.2 +++ b/src/devices/wimax/wscript	Tue Aug 11 15:02:12 2009 -0300
     8.3 @@ -44,6 +44,7 @@
     8.4              'ss-manager.cc',
     8.5              'connection-manager.cc',
     8.6              'uplink-scheduler.cc',
     8.7 +            'uplink-scheduler-qos.cc',
     8.8              'bs-scheduler.cc',
     8.9              'wimax-mac-queue.cc',
    8.10              'burst-profile-manager.cc',
    8.11 @@ -112,7 +113,10 @@
    8.12              'IPCS_BS_Packet_classifier.h',
    8.13              'cost231-propagation-model.h',
    8.14              'propagation.h',
    8.15 -            'ul-job.h'
    8.16 +            'uplink-scheduler.h',
    8.17 +            'uplink-scheduler-qos.h',
    8.18 +            'ul-job.h',
    8.19 +            'service-flow-record.h'
    8.20              ]
    8.21  		        
    8.22          module.uselib = 'ITPP'
     9.1 --- a/src/helper/wimax-helper.cc	Mon Aug 10 09:48:12 2009 -0300
     9.2 +++ b/src/helper/wimax-helper.cc	Tue Aug 11 15:02:12 2009 -0300
     9.3 @@ -194,28 +194,54 @@
     9.4      return phy;
     9.5    }
     9.6  
     9.7 +  Ptr<UplinkScheduler>
     9.8 +  WimaxHelper::CreateUplinkScheduler(SchedulerType schedulerType)
     9.9 +  {
    9.10 +    Ptr<UplinkScheduler> uplinkScheduler;
    9.11 +    switch (schedulerType)
    9.12 +      {
    9.13 +        case SCHED_TYPE_SIMPLE:
    9.14 +          uplinkScheduler = CreateObject<UplinkScheduler> ();
    9.15 +          break;
    9.16 +        case SCHED_TYPE_QOS:
    9.17 +          uplinkScheduler = CreateObject<UplinkSchedulerQoS> ();
    9.18 +          break;
    9.19 +      }
    9.20 +    return uplinkScheduler;
    9.21 +  }
    9.22 +
    9.23    NetDeviceContainer
    9.24    WimaxHelper::Install(NodeContainer c, NetDeviceType deviceType,
    9.25        PhyType phyType)
    9.26    {
    9.27 +    SchedulerType schedulerType = SCHED_TYPE_QOS;
    9.28 +
    9.29      NetDeviceContainer devices;
    9.30      for (NodeContainer::Iterator i = c.Begin(); i != c.End(); i++)
    9.31        {
    9.32          Ptr<Node> node = *i;
    9.33          Ptr<WimaxPhy> phy = CreatePhy(phyType);
    9.34          Ptr<WimaxNetDevice> device;
    9.35 +        Ptr<UplinkScheduler> uplinkScheduler = CreateUplinkScheduler (schedulerType);
    9.36  
    9.37          if (deviceType == DEVICE_TYPE_BASE_STATION)
    9.38 -          device = CreateObject<WimaxBaseStationNetDevice> ("Node",
    9.39 -              PointerValue(node), "Phy", PointerValue(phy));
    9.40 +          {
    9.41 +          // attach phy
    9.42 +          Ptr<WimaxBaseStationNetDevice> deviceBS;
    9.43 +          deviceBS = CreateObject<WimaxBaseStationNetDevice> ("Node",
    9.44 +              PointerValue (node), "Phy", PointerValue (phy), "UplinkScheduler", PointerValue(uplinkScheduler));
    9.45 +          device = deviceBS;
    9.46 +          uplinkScheduler->ConfigureBs (deviceBS);
    9.47 +          }
    9.48          else
    9.49 +          {
    9.50            device = CreateObject<WimaxSubscriberStationNetDevice> ("Node",
    9.51                PointerValue(node), "Phy", PointerValue(phy));
    9.52 -
    9.53 +          }
    9.54          device->SetAddress(Mac48Address::Allocate());
    9.55          phy->SetDevice(device);
    9.56          device->Start();
    9.57 -        device->Attach(m_channel);
    9.58 +        device->Attach(m_channel);  // attach channel
    9.59  
    9.60          node->AddDevice(device);
    9.61          devices.Add(device);
    10.1 --- a/src/helper/wimax-helper.h	Mon Aug 10 09:48:12 2009 -0300
    10.2 +++ b/src/helper/wimax-helper.h	Tue Aug 11 15:02:12 2009 -0300
    10.3 @@ -31,11 +31,15 @@
    10.4  #include "ns3/deprecated.h"
    10.5  #include "ns3/service-flow.h"
    10.6  #include "ns3/propagation.h"
    10.7 +#include "ns3/uplink-scheduler.h"
    10.8 +#include "ns3/uplink-scheduler-qos.h"
    10.9 +
   10.10  namespace ns3
   10.11  {
   10.12  
   10.13    class WimaxChannel;
   10.14    class WimaxPhy;
   10.15 +  class UplinkScheduler;
   10.16    class QoSParameterSet;
   10.17  
   10.18    /**
   10.19 @@ -54,6 +58,11 @@
   10.20        PHY_TYPE_SIMPLE, PHY_TYPE_OFDM, SIMPLE_PHY_TYPE_OFDM
   10.21      };
   10.22  
   10.23 +    enum SchedulerType
   10.24 +    {
   10.25 +      SCHED_TYPE_SIMPLE, SCHED_TYPE_QOS
   10.26 +    };
   10.27 +
   10.28      WimaxHelper(void);
   10.29      ~WimaxHelper(void);
   10.30  
   10.31 @@ -86,6 +95,9 @@
   10.32      Ptr<WimaxPhy>
   10.33      CreatePhy(PhyType phyType);
   10.34  
   10.35 +    Ptr<UplinkScheduler>
   10.36 +    CreateUplinkScheduler(SchedulerType schedulerType);
   10.37 +
   10.38      /**
   10.39       * \param channel a channel to use
   10.40       * \param c a set of nodes
   10.41 @@ -169,6 +181,9 @@
   10.42      NetDeviceContainer
   10.43      Install(NodeContainer c, NetDeviceType deviceType, PhyType phyType, Ptr<
   10.44          WimaxChannel> channel);
   10.45 +    NetDeviceContainer
   10.46 +    Install(NodeContainer c, NetDeviceType deviceType, PhyType phyType, Ptr<
   10.47 +        WimaxChannel> channel, SchedulerType schedulerType);
   10.48      Ptr<WimaxPhy>
   10.49      CreatePhyWithoutChannel(PhyType phyType);
   10.50