Get Associated Access point address

46 views
Skip to first unread message

Chandrani ray chowdhury

unread,
Oct 24, 2019, 1:48:26 AM10/24/19
to ns-3-users
Does anybody help me to get the associated access point address of a wifi node in ns3

Chandrani ray chowdhury

unread,
Oct 24, 2019, 3:44:29 AM10/24/19
to ns-3-users
below is my code, but it shows no association.
can somebody please help me.

void GetAssociatedAccessPointID(Ptr<Node> node1)
{
        uint32_t assoid;
Ptr<NetDevice> dev1 = node1->GetDevice(0);
Ptr<WifiNetDevice> wifi_dev1 = DynamicCast<WifiNetDevice>(dev1);
Mac48Address staAdrs = Mac48Address::ConvertFrom(wifi_dev1->GetAddress());
std::cout<<"mac address=====of station "<<staAdrs<<std::endl;
Ptr<WifiRemoteStationManager> wr = wifi_dev1->GetRemoteStationManager();
uint32_t i,j=0;
Mac48Address adrs;
Ptr<WifiNetDevice> wifi_apdev1;
for(i=0;i<numDAUs;i++)
{
wifi_apdev1= DynamicCast<WifiNetDevice>(m_DAUs.Get(i)->GetDevice(0));
Mac48Address adrs = Mac48Address::ConvertFrom(wifi_apdev1->GetAddress());
std::cout<<"mac address====="<<adrs<<std::endl;
if(wr->IsAssociated(adrs))
{
j=i;
break;
}
}
assoid=j;
std::cout<<"associated id==="<<assoid<<std::endl;
}

Rajarishi Devarajan

unread,
Oct 24, 2019, 5:04:35 AM10/24/19
to ns-3-...@googlegroups.com
Can you also share the error message that you encountered while compiling or running the script ?

Regards,
Rishi

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
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 view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/630ba8fc-0f8e-4cc5-9d87-83a359d64552%40googlegroups.com.

Chandrani ray chowdhury

unread,
Oct 24, 2019, 5:24:29 AM10/24/19
to ns-3-users
The code does not show any error, but always shows the association id is zero, while from  pcapTrace I found that will be 1 (Mac address: 00:00:00:00:00:02). 1 is the node id
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-...@googlegroups.com.

Chandrani ray chowdhury

unread,
Oct 24, 2019, 7:42:50 AM10/24/19
to ns-3-users
solved

void SmartGridRoming::GetAssociatedAccessPointID(Ptr<Node> node1)
{
Ptr<NetDevice> dev1 = node1->GetDevice(0);
Ptr<WifiNetDevice> wifi_dev1 = DynamicCast<WifiNetDevice>(dev1);
//Mac48Address staAdrs = Mac48Address::ConvertFrom(wifi_dev1->GetAddress());
//Mac48Address staAdrs = wifi_dev1->GetMac()->GetAddress();
//Ptr<WifiRemoteStationManager> wr = wifi_dev1->GetRemoteStationManager();
Ptr<WifiMac> mac1 = wifi_dev1->GetMac();
Ptr<StaWifiMac> sta1mac1 = mac1->GetObject<StaWifiMac>();
//Ptr<WifiRemoteStationManager> wr = sta1mac1->GetWifiRemoteStationManager();
uint32_t i;
//Mac48Address adrs;
Ptr<WifiNetDevice> wifi_apdev1;
for(i=0;i<numDAUs;i++)
{
wifi_apdev1= DynamicCast<WifiNetDevice>(m_DAUs.Get(i)->GetDevice(0));
//Mac48Address adrs = wifi_apdev1->GetMac()->GetAddress();
//Mac48Address adrs = Mac48Address::ConvertFrom(wifi_apdev1->GetAddress());
//std::cout<<"mac address=====of station "<<staAdrs<<std::endl;
//std::cout<<"ap index ====="<<i<<std::endl;
//std::cout<<"ap mac address====="<<adrs<<std::endl;
if(sta1mac1->IsAssociatedPublic())
{
std::cout<<"====================================="<<std::endl;
std::cout<<"got associated"<<std::endl;
std::cout<<"ap mac address====="<<mac1->GetBssid()<<std::endl;
std::cout<<"sta mac address====="<<mac1->GetAddress()<<std::endl;
std::cout<<"====================================="<<std::endl;
/*if(sta1mac1->GetWifiRemoteStationManager()->IsAssociated(adrs))
{
std::cout<<"got associated"<<std::endl;
assoid=i;
std::cout<<"associated id==="<<assoid<<std::endl;
} */
}
}
}
Reply all
Reply to author
Forward
0 new messages