Problem to access MacQueue of nodes

173 views
Skip to first unread message

Kevin Tewouda

unread,
May 4, 2015, 11:33:33 AM5/4/15
to ns-3-...@googlegroups.com
Hello,
here's my problem, I want to access every second, via a method to queues of my simulation nodes. But then, I realize that from my second loop iteration, I have an error saying "the program ends with a signed sigsev". Probably an error related to pointers. Please, can someone tell me where there is a problem in the following code
thank you in advance.

void
VanetRoutingExperiment::CheckPhyAndMac ()
{
    //vectors used to know how many packets where in the queue of each node
    std::vector<int> nbPacketsBE, nbPacketsBK;
    //variable used to know actual time of the simulation
    //static int time = 0;
    //time++;

    for(uint32_t i = 0; i < m_adhocTxNodes.GetN(); i++)
    {
        nbPacketsBE.push_back(0);
        nbPacketsBK.push_back(0);
    }

    PointerValue pointer, pointer2;
    //We verify the queue for each node
    for(uint32_t i = 0; i < m_adhocTxNodes.GetN(); i++)
    {
        //NS_LOG_UNCOND("te");
        Ptr<Node> node = m_adhocTxNodes.Get(i);
        Ptr<NetDevice> nd = node->GetDevice(i);
        Ptr<WifiNetDevice> device = nd->GetObject<WifiNetDevice> ();

        Ptr<WifiPhy> phy = device->GetPhy();
        Ptr<WifiMac> mac = device->GetMac();

        Ptr<YansWifiPhy> yansPhy = phy->GetObject<YansWifiPhy> ();
        Ptr<RegularWifiMac> rmac = mac->GetObject<RegularWifiMac> ();

        rmac->GetAttribute("BK_EdcaTxopN", pointer);
        rmac->GetAttribute("BE_EdcaTxopN", pointer2);

        Ptr<EdcaTxopN> edca;
        Ptr<EdcaTxopN> edca2;

        pointer.GetAccessor(edca);
        pointer.GetAccessor(edca2);

        Ptr<WifiMacQueue> macQueue = edca->GetEdcaQueue ();
        Ptr<WifiMacQueue> macQueue2 = edca->GetEdcaQueue ();

        bool empty = macQueue->IsEmpty();
        bool empty2 = macQueue2->IsEmpty();
        NS_LOG_UNCOND("yes");
        if(!empty)
        {
            //NS_LOG_UNCOND("BK: At least one packet remaining!");
            nbPacketsBK[i]++;
        }
        if(!empty2)
        {
            //NS_LOG_UNCOND("BE: At least one packet remaining!");
            nbPacketsBE[i]++;
        }
    }

    /*int frequency = yansPhy->GetFrequency();
    std::ostringstream oss;
    oss << frequency;
    NS_LOG_UNCOND(oss.str());*/

    //if the current time is close to the number of seconds of simulation, it records data in a file
    //if(m_TotalSimTime - (double)time <= 1.0)
    //{
        std::ofstream record("../../simulations/queue.tr", std::ios::out);
        std::string values;
        std::ostringstream oss;
        for(int i = 0; i < (int)nbPacketsBE.size(); i++)
        {
            oss << nbPacketsBE[i];
            values += oss.str() + " ";
        }
        values +="\n";
        for(int i = 0; i < (int)nbPacketsBK.size(); i++)
        {
            oss << nbPacketsBK[i];
            values += oss.str() + " ";
        }
        record << values;
    //}

    Simulator::Schedule (Seconds (1.0), &VanetRoutingExperiment::CheckPhyAndMac, this);
}

Tommaso Pecorella

unread,
May 4, 2015, 12:01:10 PM5/4/15
to ns-3-...@googlegroups.com
  for(uint32_t i = 0; i < m_adhocTxNodes.GetN(); i++)
   
{
       
//NS_LOG_UNCOND("te");
       
Ptr<Node> node = m_adhocTxNodes.Get(i);
       
Ptr<NetDevice> nd = node->GetDevice(i);
       
Ptr<WifiNetDevice> device = nd->GetObject<WifiNetDevice> ();
WHAT ?
I'm fairly sure that the i-th node doesn't have i NetDevices.

More or less like having "ONE 2 THREE 4 FIVE 6 SEVEN 8 NINE" password 

T.

Kevin Tewouda

unread,
May 5, 2015, 3:49:25 AM5/5/15
to ns-3-...@googlegroups.com
I apologize for the inconvenience.

Tommaso Pecorella

unread,
May 5, 2015, 4:09:26 AM5/5/15
to ns-3-...@googlegroups.com
Np. Copy-paste horrors happens.

Have fun,

T.
Reply all
Reply to author
Forward
0 new messages