Closed akhila-rao closed 7 years ago
Hi,
I was able to solve this. I needed to do ./waf build ./waf install (as you previously suggested)
I was confused before because from reading about ns3 I learnt that I can use the build.py script to build ns3 and its python bindings (people also suggested using ./waf --apiscan=all). I even looked at the code of build.py and it has the sections to build ns3 and its pybindings, but I guess it misses something out ??
Anyway, thank you for your help. I should have tried your solution first before making this post.
Sorry, I do not familiar with build.py, but I think maybe build.py does not perform the step of install NS-3 Python library.
Print message into file as log is an option, another choice is using log system. NS-3 has its own log system, that log system uses std::clog to output log. In the case of running NS-3 script (C++) via waf script, the log will print on terminal. OpenNet can call NS-3 functions without waf, but it also makes print log becomes tricky.
Add following lines in OpenNet example script:
from ns.core import *
LogComponentEnable ("WifiPhy", LOG_LEVEL_LOGIC)
Add following code in WifiPhy::DoInitialize (void):
const unsigned int length = 8192;
char buffer[length];
m_fileStream.open ("/tmp/logFile.txt");
m_fileStream.rdbuf()->pubsetbuf(buffer, length);
std::clog.rdbuf (m_fileStream.rdbuf ());
Use the following functions to output log in wifi-phy.cc:
NS_LOG_LOGIC (" Just a test message. \n");
Then build NS-3 with:
./waf build
./waf install
After running OpenNet example script, the log should be found at /tmp/logFile.txt.
By the way, after add a new function in NS-3 module, perform an API scanning to generate interface for Python binding is recommended.
# ./waf --apiscan=wifi
# ./waf build
# ./waf install
Hi,
I need to make changes in the underlying ns3 code in OpenNet. I basically need to enable automatic frame sniffing on each node, as soon as it is created. I have a simple script as in the /OpenNet/mininet/examples/opennet/ folder that sets up one controller 2 APs and 2 stations. I start off by doing a simple sanity check to see if OpenNet is properly connected to ns3. I add a simple C++ cout statement in NotifyMonitorSniffRx method in wifi-phy.cc and in the Install method in wifi-net-device.cc to ensure that they are being called at least.
I build using ./build in the ns-allinone folder which from reading the code seems to build ns3 and the python bindings. I then do ./install -n in the mininet/util folder, and finally start pox and run my example python script that sends pings from one station to another. I do not see any print statements from ns3 on stdout. I even tried creating files at these locations and basically nothing happens. Any ideas on what I am doing wrong ? How can I ensure that the ns3 code is even being executed. Both the methods in which I have put a cout statement should be called if a wifi device has been setup and frames have been received.
This question is different from my previous post, because there I was accessing new functions through python bindings. But, now I just want some print statements in ns3 to be printed on the screen to ensure that that portion of the code is being executed.