a***@gmail.com
2018-11-22 05:55:49 UTC
Hello,
I work on the latest version of ns-3-lbt code for LTE/Wi-Fi
coexistence. I am trying to add a new TraceSource to keep track of
collisions in Wi-Fi module. Therefore, I added a new TraceSource, which I
call "Collision", in dca-txop.cc/.h files. My implementation is much
similar to other TraceSources already implemented in wifi-mac.cc/h (e.g.,
MacTx). I double checked the ns3-object.txt file to make sure that I am
connecting to the correct path. My code runs without errors, but
TraceSource I created still does not fire as expected. I thought it could
be a path issue, but I already verified it. I appreciate if you could point
me out of any thing wrong in my implementation. Thank you!
Please, check the following on how I created the new TraceSource - blue
lines (modified codes are also attached):
*In dca-txop.h file:*
*Step1:* I added the following line as a private member at the end of class
DcaTxop :
TracedCallback<Ptr<const Packet> > m_collisionTrace;
*In dca-txop.cc file:*
*Step 1*: I added the following lines at the end of TypeId
DcaTxop::GetTypeId:
.AddTraceSource ("Collision",
"A packet has been collided",
MakeTraceSourceAccessor (&DcaTxop::m_collisionTrace),
"ns3::Packet::TracedCallback")
*Step 2:* I added a new line to call m_collisionTrace in NotifyCollision()
function:
void
DcaTxop::NotifyCollision (void)
{
NS_LOG_FUNCTION (this);
NS_LOG_DEBUG ("collision");
m_collisionTrace(m_currentPacket); //fire the trace for collision
m_dcf->StartBackoffNow (m_rng->GetNext (0, m_dcf->GetCw ()));
std::cout<<"Time: "<<Simulator::Now().GetSeconds()<<", dca-txop,
NotifyCollision, new CWmin "<<m_dcf->GetCw()<<std::endl; // I add this line
to make sure the
RestartAccessIfNeeded ();
}
*In simulationScript.cc (this is my main simulation script): *
*Step 1:* I checked for the correct path by running $ ./waf --doxygen and
looked for the correct path of Collision TraceSource in doc/ns3-object.txt
ns3::DcaTxop
Config Paths
ns3::DcaTxop is accessible through the following paths with Config::Set and
Config::Connect:
*
"/NodeList/[i]/DeviceList/[i]/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/DcaTxop"
*Step 2:* I connect to the TraceSource that I created using the path I
created:
Config::Connect
("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/DcaTxop/Collision",
MakeCallback (&RecordPhyCollision)); // Record collisions
*Step 3:* The following is the implementation for RecordPhyCollision.
void RecordPhyCollision(std::string context, Ptr<const Packet> packet)
{
WifiMacHeader wifiMacHeader;
packet->PeekHeader (wifiMacHeader);
uint64_t packetId = packet->GetUid();
uint32_t nodeId = ContextToNodeId (context);
std::cout<<"Time: "<<Simulator::Now().GetSeconds()<<" wifi-ai,
RecordPhyCollision, nodeId "<<nodeId<<" packetId "<<packetId<<std::endl;
}
Kind Regards,
Ali
I work on the latest version of ns-3-lbt code for LTE/Wi-Fi
coexistence. I am trying to add a new TraceSource to keep track of
collisions in Wi-Fi module. Therefore, I added a new TraceSource, which I
call "Collision", in dca-txop.cc/.h files. My implementation is much
similar to other TraceSources already implemented in wifi-mac.cc/h (e.g.,
MacTx). I double checked the ns3-object.txt file to make sure that I am
connecting to the correct path. My code runs without errors, but
TraceSource I created still does not fire as expected. I thought it could
be a path issue, but I already verified it. I appreciate if you could point
me out of any thing wrong in my implementation. Thank you!
Please, check the following on how I created the new TraceSource - blue
lines (modified codes are also attached):
*In dca-txop.h file:*
*Step1:* I added the following line as a private member at the end of class
DcaTxop :
TracedCallback<Ptr<const Packet> > m_collisionTrace;
*In dca-txop.cc file:*
*Step 1*: I added the following lines at the end of TypeId
DcaTxop::GetTypeId:
.AddTraceSource ("Collision",
"A packet has been collided",
MakeTraceSourceAccessor (&DcaTxop::m_collisionTrace),
"ns3::Packet::TracedCallback")
*Step 2:* I added a new line to call m_collisionTrace in NotifyCollision()
function:
void
DcaTxop::NotifyCollision (void)
{
NS_LOG_FUNCTION (this);
NS_LOG_DEBUG ("collision");
m_collisionTrace(m_currentPacket); //fire the trace for collision
m_dcf->StartBackoffNow (m_rng->GetNext (0, m_dcf->GetCw ()));
std::cout<<"Time: "<<Simulator::Now().GetSeconds()<<", dca-txop,
NotifyCollision, new CWmin "<<m_dcf->GetCw()<<std::endl; // I add this line
to make sure the
RestartAccessIfNeeded ();
}
*In simulationScript.cc (this is my main simulation script): *
*Step 1:* I checked for the correct path by running $ ./waf --doxygen and
looked for the correct path of Collision TraceSource in doc/ns3-object.txt
ns3::DcaTxop
Config Paths
ns3::DcaTxop is accessible through the following paths with Config::Set and
Config::Connect:
*
"/NodeList/[i]/DeviceList/[i]/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/DcaTxop"
*Step 2:* I connect to the TraceSource that I created using the path I
created:
Config::Connect
("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/DcaTxop/Collision",
MakeCallback (&RecordPhyCollision)); // Record collisions
*Step 3:* The following is the implementation for RecordPhyCollision.
void RecordPhyCollision(std::string context, Ptr<const Packet> packet)
{
WifiMacHeader wifiMacHeader;
packet->PeekHeader (wifiMacHeader);
uint64_t packetId = packet->GetUid();
uint32_t nodeId = ContextToNodeId (context);
std::cout<<"Time: "<<Simulator::Now().GetSeconds()<<" wifi-ai,
RecordPhyCollision, nodeId "<<nodeId<<" packetId "<<packetId<<std::endl;
}
Kind Regards,
Ali
--
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 post to this group, send email to ns-3-***@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.
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 post to this group, send email to ns-3-***@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.