Discussion:
Adding New TraceSource in Wi-Fi Module - ns-3-lbt
a***@gmail.com
2018-11-22 05:55:49 UTC
Permalink
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
--
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.
Biljana Bojović
2018-11-22 10:43:56 UTC
Permalink
Hi Ali,

if your simulation script is configured as by default, you will need to
implement your new trace sources in EdcaTxopN class (edca-txop-n.h/cc)
instead of DcaTxop.

Cheers,
Biljana


On Thursday, November 22, 2018 at 6:55:49 AM UTC+1,
Post by a***@gmail.com
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
*In dca-txop.h file:*
*Step1:* I added the following line as a private member at the end of
TracedCallback<Ptr<const Packet> > m_collisionTrace;
*In dca-txop.cc file:*
*Step 1*: I added the following lines at the end of TypeId
.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
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
*
"/NodeList/[i]/DeviceList/[i]/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/DcaTxop"
*Step 2:* I connect to the TraceSource that I created using the path I
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.
Ali Mohammed
2018-11-26 18:43:45 UTC
Permalink
Hi Biljana,

Thanks for your insight and prompt response. I customize my simulation
script, and connect to my new trace source 'Collision' in both DcaTxop and
EdcaTxopN classes. I have tried to apply my changes within the default
script for running laa-wifi-indoor scenario, but the problem still exists
even with the default script. For your convenience, I have attached all
files, including the default simulation script with the new trace source
'Collision' being added. I am just wondering if I am missing any step,
because all other already existing trace sources fire and work properly.

*Note:* For implementation with the default script, I connect to the new
trace source 'Collision' in scenario-helper.cc file
(src/laa-wifi-coexistence/helper/scenario-helper.cc); see lines 2840-2941
in the attached files, and once the new trace source is fired, it is
supposed to call another function called RecordPhyCollision(); see lines
2316-2331 in the same file, which prints out a prompt message indicating
collision. I verify that collision happens by adding print commands in both
dca-txop.cc and edca-txop-n.cc under their NotifyCollision() member
function. During the simulation run, if the new trace source 'Collision'
fires properly, provided I am connecting to the right path, then we should
see two prompt output messages for each collision. Now, I only see one of
them coming from NotifyCollision() in dca-txop.cc and edca-txop-n.cc files.
By the way, I also tried to apply similar changes in the default
'laa-wifi-indoor.cc' script, but the problem still exists.


- After incorporating the attached files within their target locations,
please try to run:
$ ./waf --run "laa-wifi-indoor --transport=Ftp --ftpLambda=0.5"
and you will see one prompt message for each collision.

I appreciate your effort!

Thanks,
Ali
Post by Biljana Bojović
Hi Ali,
if your simulation script is configured as by default, you will need to
implement your new trace sources in EdcaTxopN class (edca-txop-n.h/cc)
instead of DcaTxop.
Cheers,
Biljana
On Thursday, November 22, 2018 at 6:55:49 AM UTC+1,
Post by a***@gmail.com
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
*In dca-txop.h file:*
*Step1:* I added the following line as a private member at the end of
TracedCallback<Ptr<const Packet> > m_collisionTrace;
*In dca-txop.cc file:*
*Step 1*: I added the following lines at the end of TypeId
.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
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
*
"/NodeList/[i]/DeviceList/[i]/$ns3::WifiNetDevice/Mac/$ns3::RegularWifiMac/DcaTxop"
*Step 2:* I connect to the TraceSource that I created using the path I
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
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.
Loading...