TDMA for NS3

2,185 views
Skip to first unread message

ns3...@gmail.com

unread,
Feb 1, 2014, 6:39:32 PM2/1/14
to ns-3-...@googlegroups.com
Hi,
Does NS3 support TDMA because I could not find any example??Can anybody help me with that.Thanks in advance for your help.
best regards,

ns3 geek

unread,
Feb 1, 2014, 7:50:06 PM2/1/14
to ns-3-...@googlegroups.com
I have tried the following code to implement and run the provided example of TDMA;

But the results are wrong as no packets are received by the sink.I got the following trace file:

d 90.0712 /NodeList/2/DeviceList/0/$ns3::TdmaNetDevice/Mac/MacTxDrop ns3::LlcSnapHeader (type 0x800) ns3::Ipv4Header (tos 0x0 DSCP Default ECN Not-ECT ttl 1 id 29 protocol 17 offset (bytes) 0 flags [none] length: 40 10.1.1.3 > 10.1.1.255) ns3::UdpHeader (length: 20 269 > 269) ns3::dsdv::DsdvHeader (DestinationIpv4: 10.1.1.3 Hopcount: 1 SequenceNumber: 12)

d 90.0913 /NodeList/0/DeviceList/0/$ns3::TdmaNetDevice/Mac/MacTxDrop ns3::LlcSnapHeader (type 0x800) ns3::Ipv4Header (tos 0x0 DSCP Default ECN Not-ECT ttl 1 id 5 protocol 17 offset (bytes) 0 flags [none] length: 40 10.1.1.1 > 10.1.1.255) ns3::UdpHeader (length: 20 269 > 269) ns3::dsdv::DsdvHeader (DestinationIpv4: 10.1.1.1 Hopcount: 1 SequenceNumber: 12) 

can anybody help me what I did wrong??It looks like that the routes are not established properly.Following is the snippet of the routing table;

Node: 1 Time: 98.000s 
DSDV Routing table
Destination  Gateway Interface HopCount SeqNum LifeTime SettlingTime
10.1.1.255 10.1.1.255 10.1.1.2 0         14              -9223371938.855s 0.000s
127.0.0.1 127.0.0.1 127.0.0.1 0         0 -9223371938.855s 0.000s

thanks in advance for your help and time.best regards,



--
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/5w60gWAd4WI/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/groups/opt_out.

Tommaso Pecorella

unread,
Feb 2, 2014, 11:52:28 AM2/2/14
to ns-3-...@googlegroups.com
Hi,

I did manage to run it as well (quite painful, there's a lot of errors and things to be changed).
Nevertheless, it seems to be working. So, try again.

T.

ns3 geek

unread,
Feb 2, 2014, 12:07:53 PM2/2/14
to ns-3-...@googlegroups.com
thanks for the reply and time.Highly appreciate that.If you donot mind can you please share your expertly modified code so that I can compare and figure out my faults.I shall be very thankful for that.

Best regards,

Tommaso Pecorella

unread,
Feb 2, 2014, 12:38:43 PM2/2/14
to ns-3-...@googlegroups.com
Here.

It should work in 3.19, but I'm not totally sure. I'm working an a modified 3.19 (I have some pending patches not yet approved), and I didn't test it on a "clean" 3.19.

T.
simple-wireless-tdma.zip

Tommaso Pecorella

unread,
Feb 2, 2014, 12:40:02 PM2/2/14
to ns-3-...@googlegroups.com
forgot the modified example... sorry.

T
tdma-example.cc

ns3 geek

unread,
Feb 2, 2014, 1:05:42 PM2/2/14
to ns-3-...@googlegroups.com
bundle of thanks.Highly appreciate that.Let me try it out on ns3.19

Best regards,

ns3...@gmail.com

unread,
Feb 2, 2014, 1:34:37 PM2/2/14
to ns-3-...@googlegroups.com
Its working in NS3.19. Great work. Thanks once again for all your time and help.
Best regards,
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.

ns3 geek

unread,
Feb 2, 2014, 8:53:08 PM2/2/14
to ns-3-...@googlegroups.com
If i want to create a scenario in which nodes operate in two modes one is the random access mode and second is the TDMA  mode.These modes are periodic and have non-overlaping timing. e.g.
                                            ___________________________                                              _______________________ 
___Random Access Mode___|          TDMA mode                  | ___Random Access Mode____|          TDMA mode                   
In that case do I need to create two separate set of the nodes placed at the same locations and contained in different containers (one for each). Then apply respective wifi models to them i.e. to the first one apply the random access and second one TDMA.
Is this a valid solution to tackle such a situation. Kindly please provide your expert opinion or any suggestion??

Best regards,

Amir Reda

unread,
Feb 3, 2014, 2:28:33 AM2/3/14
to ns-3-...@googlegroups.com
CreateDevices (std::string tr_name)
{

/*
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
  wifiMac.SetType ("ns3::AdhocWifiMac");
  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
  YansWifiChannelHelper wifiChannel;
  wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
  wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel");
  wifiPhy.SetChannel (wifiChannel.Create ());
  WifiHelper wifi;
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue (m_phyMode), "ControlMode",StringValue (m_phyMode));

  devices = wifi.Install (wifiPhy, wifiMac, anNodes);
  gdevices = wifi.Install (wifiPhy, wifiMac, gNodes);

  AsciiTraceHelper ascii;
  wifiPhy.EnableAsciiAll (ascii.CreateFileStream (tr_name + ".tr"));
  wifiPhy.EnablePcapAll (tr_name);
 */
 
     Config::SetDefault ("ns3::SimpleWirelessChannel::MaxRange", DoubleValue (27800));
     Config::SetDefault ("ns3::SimpleWirelessChannel::GroundRange", DoubleValue (150000));
     Config::SetDefault ("ns3::SimpleWirelessChannel::GroundID", IntegerValue (0));
      // default allocation, each node gets a slot to transmit
      TdmaHelper tdma = TdmaHelper (anNodes.GetN ()+gNodes.GetN(), anNodes.GetN ()+gNodes.GetN()); // in this case selected, numSlots = nodes
    
      TdmaControllerHelper controller;
      controller.Set ("SlotTime", TimeValue (MicroSeconds (1100)));
      controller.Set ("GaurdTime", TimeValue (MicroSeconds (100)));
      controller.Set ("InterFrameTime", TimeValue (MicroSeconds (10)));
      tdma.SetTdmaControllerHelper (controller);

      devices = tdma.Install (anNodes);

      gdevices = tdma.Install (gNodes);


      AsciiTraceHelper ascii;
      Ptr<OutputStreamWrapper> stream = ascii.CreateFileStream (tr_name + (".tr"));
      tdma.EnableAsciiAll (stream); 
}

note
this is if you use
two different nodes with two different range such as GroundRange = 150000 others 27800

hope this is useful for u


You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, 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/groups/opt_out.



--
Warmest regards and best wishes for a good health,urs sincerely
mero

Tommaso Pecorella

unread,
Feb 3, 2014, 3:30:03 AM2/3/14
to ns-3-...@googlegroups.com
Hi,

it could work, but it won't "out of the box".

In order to make it happen, you'll have to modify both MACs (the TDMA and the Random one) to respect the non-overlapping periods. Kinda hard imho, even if the recent WiFi sleep proposed enhancement could help on that.
Overall, I feel it's a bit of an awkward solution, and I don't honestly see what (real) system could simulate.

If your goal is to simulate a real system where the MAC provides both random access and guaranteed (TDMA-like) slots, you'd better model the MAC correctly, otherwise you'll get results, but they'll be heavily affected by the incorrect modelling.

Cheers,

T.

ns3 geek

unread,
Feb 3, 2014, 2:07:23 PM2/3/14
to ns-3-...@googlegroups.com
thanks for the reply and your time.its really helpful and I really appreciate that.

Best regards,

msis...@ualberta.ca

unread,
Feb 7, 2014, 1:07:54 AM2/7/14
to ns-3-...@googlegroups.com
Hello,

I copied and ran the example. The trace file is generating

d 15.0069 /NodeList/3/DeviceList/0/$ns3::TdmaNetDevice/Mac/MacTxDrop ns3::LlcSnapHeader (type 0x800) ns3::Ipv4Header (tos 0x0 DSCP Default ECN Not-ECT ttl 1 id 0 protocol 17 offset (bytes) 0 flags [none] length: 40 10.1.1.4 > 10.1.1.255) ns3::UdpHeader (length: 20 269 > 269) ns3::dsdv::DsdvHeader (DestinationIpv4: 10.1.1.4 Hopcount: 1 SequenceNumber: 2)
d 15.0136 /NodeList/2/DeviceList/0/$ns3::TdmaNetDevice/Mac/MacTxDrop ns3::LlcSnapHeader (type 0x800) ns3::Ipv4Header (tos 0x0 DSCP Default ECN Not-ECT ttl 1 id 0 protocol 17 offset (bytes) 0 flags [none] length: 40 10.1.1.3 > 10.1.1.255) ns3::UdpHeader (length: 20 269 > 269) ns3::dsdv::DsdvHeader (DestinationIpv4: 10.1.1.3 Hopcount: 1 SequenceNumber: 2)

and the csv file says number of packets received is zero. Im running it with default parameters. Am I ding something wrong.

Thanks
Mohammad

AhlEM AhlAM

unread,
Sep 11, 2014, 9:36:03 AM9/11/14
to ns-3-...@googlegroups.com
  helped me a lot, thank you very much

Nurullah Shahin

unread,
May 26, 2015, 2:21:52 AM5/26/15
to ns-3-...@googlegroups.com
Dear Tommaso Pecorella,

I compiled successfully the TDMA MAC protocol from http://code.nsnam.org/tomh/ns-3-simple-wireless/
In this model, Tdma schedules every node in round robin manner, but I want there should not be any priority among nodes.
That means, each node must use its own slot even it generates before getting its own slot.
Example, node 1 should use 1-th slot
               node 3 should use 1-th slot
                :
                :
              node 50 should use 50-th slot
Here, if all nodes generates data traffic at the same time, then we get the proper slot sequence as our need.
But, when each node generates data at random time, this model apply round robin manner.
Could you please help me to implement TDMA MAC protocol without round robin manner.

Thanks,

Nurullah Shahin

Tommaso Pecorella

unread,
May 26, 2015, 3:11:45 AM5/26/15
to ns-3-...@googlegroups.com
Do not post the same message twice. Simply don't.

About using a fixed allocation, it should be a simple matter of changing some code. By this group policy, we don't do other people's work. We just help with specific doubts.
Read the code, understand it and change it. If you have problems write (once).

T.

Nurullah Shahin

unread,
Jun 3, 2015, 3:33:45 AM6/3/15
to ns-3-...@googlegroups.com
Hi Tommaso Pecorella,

Sorry for mail repetition. 

Could you give any idea that, I want to configure that, at run time of the simulation, suppose 20%(randomly selected) out of 50 nodes can use their own slot in a frame, in the next frame  20%(randomly selected) out of 50 can use. At this time, I use on-off application that all nodes generate & use their own slot at the run time.

Thanks for your advise.

Nurullah Shahin

For more options, visit https://groups.google.com/d/optout.

pedi pedro

unread,
Jun 8, 2015, 4:35:10 AM6/8/15
to ns-3-...@googlegroups.com
Dear Amir and Dear Geek and Dear all,

You mentioned about defining two mode of nodes.

Can I used from your this theory about applying time slot to node that are locating in right direction and left direction (like highway scenario)

first I want to find that this node is located in which direction and after that apply it time slot ? (if you have another idea please tell me)

so that is true defined two group node ( rightNodes and leftNodes ) ?

I am Thanks in advance to all of you for helping and giving your expert idea.



NodeContainer nodes;
  
NodeContainer rightnodes;
NodeContainer leftnodes;

void
TdmaExample::CreateNodes ()
{
  std::cout << "Creating " << (unsigned) m_nWifis << " nodes.\n";
  nodes.Create (m_nWifis);
  
   rightNodes.Create (m_nWifis);  // for nodes in right direction
   leftNodes.Create (m_nWifis);    //  for nodes in left direction
 
  /* if nodes is rightdirection
     nodes = rightNodes
  rightNodes.Create (m_nWifis);
 
  else
   node is leftdirection
   nodes = leftNodes
      leftNodes.Create (m_nWifis);
 */  

  NS_ASSERT_MSG (m_nWifis > m_nSinks, "Sinks must be less or equal to the number of nodes in network");
  
}

'
'
'
  devices = wifi.Install (wifiPhy, wifiMac, rightNodes);   //  devices = wifi.Install (wifiPhy, wifiMac, anNodes);
  ldevices = wifi.Install (wifiPhy, wifiMac, leftNodes);   //  gdevices = wifi.Install (wifiPhy, wifiMac, gNodes);


 // default allocation, each node gets a slot to transmit
      TdmaHelper tdma = TdmaHelper (rightNodes.GetN ()+leftNodes.GetN(), rightNodes.GetN ()+leftNodes.GetN());   // in this case selected, numSlots = nodes
    
      TdmaControllerHelper controller;
     '
     '
    '

      devices = tdma.Install (rightNodes);
      ldevices = tdma.Install (leftNodes);


    '
    '

Tommaso Pecorella

unread,
Jun 9, 2015, 3:50:53 PM6/9/15
to ns-3-...@googlegroups.com
Hi,

what you are trying to do is a new MAC protocol. Please study the MAC you want to modify and ns-3 in general.
How you generate data (the OnOff application is not relevant.

Have a nice study,

T.

Nurullah Shahin

unread,
Jun 10, 2015, 1:12:52 AM6/10/15
to ns-3-...@googlegroups.com
Dear Tommaso Pecorella,

Thanks for your advice.

Mainly, I want to implement a TDMA Multichannel MAC protocol for VANET. You know there is 1 Control Channel (CCH) and 6 Service Channel (SCH) and every node should send at least one beacon/control message(broadcast) in 100ms period/frame. I already design a model, so now I am trying to implement it. At first, I am configuring CCH, where a node gets two slot in a frame. Because I don't have much knowledge. I completed my requirement by this way :

        Time tempTime =MicroSeconds(m_totalTime);
        Time start_time = MilliSeconds(0.0);
        Time stop_time = MilliSeconds(100);
        Time end_time = MilliSeconds(tempTime);
        Time step_time = MilliSeconds(100);
        //uint32_t m_source[3];
        uint32_t *m_source;
        uint32_t *total_source;
        m_source = new uint32_t[];
        total_source = new uint32_t[m_nWifis];
        uint32_t threshold =50; // percentage of total nodes
        uint32_t i=0;

        for (uint32_t i = 0; i <= m_nWifis-1 ; i++ )
        {
            Ptr<Node> node = NodeList::GetNode (i);
            Ipv4Address nodeAddress = node->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal ();
            std::cout << "SetupPacketReceive (nodeAddress, node) " << nodeAddress << " " << node << std::endl;
            outfile1<< "SetupPacketReceive (nodeAddress, node) " << nodeAddress << " " << node << std::endl;
            outfile2<< "SetupPacketReceive (nodeAddress, node) " << nodeAddress << " " << node << std::endl;
            Ptr<Socket> sink = SetupPacketReceive (nodeAddress, node);
        }

        Config::SetDefault ("ns3::TDMAApplication::PacketSize",UintegerValue (pktSize));
        Config::SetDefault ("ns3::TDMAApplication::BurstIntensity", StringValue (m_rate));

        ns3::ApplicationContainer app;

        UniformVariable rand_nodes (0,99);

        std::cout<<std::endl;
        outfile2<<std::endl;

        for (; start_time < end_time; start_time=start_time+step_time)
        {
            std::cout<<"At time = "<<start_time.GetMilliSeconds()<<" ms to "<<stop_time.GetMilliSeconds()<<" ms"<<std::endl;
            outfile2 <<"At time = "<<start_time.GetMilliSeconds()<<" ms to "<<stop_time.GetMilliSeconds()<<" ms"<<std::endl;

            uint32_t m=0;
            // Set random variables of the source (client)
            for(uint32_t j=0;j<m_nWifis;j++)
            {
                total_source[j] = rand_nodes.GetInteger(0,99);
                if(total_source[j]>threshold)
                {
                    std::cout<<"Node["<<j+1<<"]= "<<total_source[j]<<std::endl;
                    outfile2<<"Node["<<j+1<<"]= "<<total_source[j]<<std::endl;
                    m_source[m]=j;
                    m++;
                }
            }

            std::cout<<"Total Nodes: "<<m<<std::endl;
            outfile2<<"Total Nodes: "<<m<<std::endl;

            ns3::TDMAApplicationHelper tdmaApps ("ns3::UdpSocketFactory", Address (InetSocketAddress (Ipv4Address("255.255.255.255"), port)));
            tdmaApps.SetAttribute ("MeanBurstArrivals", RandomVariableValue (ConstantVariable (20)));
            tdmaApps.SetAttribute ("MeanBurstTimeLength", RandomVariableValue (ConstantVariable (0.005)));
            tdmaApps.SetAttribute ("H", DoubleValue (0.7));


            for(uint32_t j=0;j<m;j++)
            {
                app = tdmaApps.Install (nodes.Get(m_source[j]));
                app.Start (MilliSeconds (start_time));
                app.Stop (MilliSeconds (stop_time));

            }
            stop_time+=step_time;
            std::cout<<std::endl;
            outfile2<<std::endl;
    }

Is there any efficient way doing the same thing?

Now, I am trying to implement 6 SCH, So, could you give me any idea. Those are also TDMA based.

Thanks,

Nurullah Shahin

Tommaso Pecorella

unread,
Jun 10, 2015, 1:30:43 AM6/10/15
to ns-3-...@googlegroups.com
Hi,

you can not implement a MAC protocol in this way. You should understand how a MAC protocol is implemented in ns-3 (i.e., how a NetDevice works) and develop it starting from that point. Study the csma module, it's easy enough to be understood.
Otherwise, all you will do is to "use" ns-3 for the event and time parts. It's much like using a cannon to kill mosquitoes, and you'll not be able to use the other ns-3 features, like TCP/IP models, applications, etc.
Summarizing: study csma module and understand how a NetDevice works.

have fun studying,

T.

pedi pedro

unread,
Jun 10, 2015, 6:03:26 AM6/10/15
to ns-3-...@googlegroups.com
Dear Tommaso Pecorella,

Actually I want to modify TDMA instead of assigning default time slot with this case that when one node sends request to CCH and after that get time slot to node. And also I should be define the direction of nodes (which nodes are left or right) in case of highway or city scenario . It means that assigning time slot in both direction. And after detects the direction of nodes , get or assign the specific time slot to nodes


for  exp. if node x is in right direction : assign TRx ( time slot for nod of right direction)
or of node y is in left direction :  assign TLy

on frame on CCH :  TRx,TLy,...

I am very thankful for your supporting

ero Z

unread,
Nov 15, 2015, 8:35:19 AM11/15/15
to ns-3-users

Hi
I use NS3-24  there is no  ConstantVariable (double c);and UniformVariable (double s, double l); what can use to instead of them ? thank you
在 2014年2月3日星期一 UTC+8上午12:52:28,Tommaso Pecorella写道:

Konstantinos

unread,
Nov 15, 2015, 10:04:23 AM11/15/15
to ns-3-users
Hi,

Random Variables are explained in the first chapter of the manual
https://www.nsnam.org/docs/manual/html/random-variables.html
You can see the also the change in the API as of ns-3.15.

Regards,
K.

Lokesh Sharma

unread,
Apr 24, 2016, 9:23:01 PM4/24/16
to ns-3-users
Hello sir

I wants to do node some selection procedure in tdma slots, so please advice me how can i do. 

Mohammed Mustafa

unread,
Jul 22, 2017, 5:42:26 AM7/22/17
to ns-3-users
Sir Need to i9plement TDMA in BSN .help me out in coding...
Reply all
Reply to author
Forward
0 new messages