ns3 日志系统 及 命令行传参

reference

常用

define in .cc

NS_LOG_COMPONENT_DEFINE ("DcaTxop");

设置显示等级

代码

void LogComponentEnable (char const *name, enum LogLevel level);
void LogComponentEnableAll (enum LogLevel level);
void LogComponentDisable (char const *name, enum LogLevel level);
void LogComponentDisableAll (enum LogLevel level);
  • 前缀
LOG_PREFIX_FUNC    = 0x80000000, //!< Prefix all trace prints with function.
LOG_PREFIX_TIME    = 0x40000000, //!< Prefix all trace prints with simulation time.
LOG_PREFIX_NODE    = 0x20000000, //!< Prefix all trace prints with simulation node.
LOG_PREFIX_LEVEL   = 0x10000000, //!< Prefix all trace prints with log level (severity).
LOG_PREFIX_ALL     = 0xf0000000  //!< All prefixes.
  • examples
LogComponentEnable("test", LOG_LEVEL_INFO); //* 会显示该level及以上的
LogComponentEnable("test", LOG_DEBUG); //* 只会显示这个等级的
LogComponentEnable("test", LOG_ERROR|LOG_PREFIX_FUNC); //* 只会显示这个等级的

命令行 (recommended)

	// enable all
NS_LOG="*" ./waf --run xxx  
	// enable specified component and specified level
NS_LOG="test=level_info" ./waf --run xxx
	// add prefix
NS_LOG="test=info|prefix_level" ./waf --run xxx

	// integrate all
NS_LOG="<log-component>=<option>|<option>...:<log-component>..." ./waf --run xxx
  • 或者采用环境变量的方式
export NS_LOG=UdpEchoClientApplication=level_all
./waf --run xxxx

还有啥*, **,***,自己看官网吧…

配合cmdline传参

NS_LOG="*=error:test=debug" ../waf --run "myTopo --recordInterval=0.01"
NS_LOG="*=error:test=debug" ../waf --run myTopo --command-template="gdb --args %s ns3::PointToPointNetDevice::DataRate=10Mbps"

另一种想要结合命令行传参和gdb功能的就是

NS_LOG="*=error:test=debug" ../waf --run myTopo --command-template="gdb --args %s "
	# e.g.
NS_LOG="*=error:test=debug"  ../waf --run lp_exp1 --command-template="gdb --args %s ns3::PointToPointNetDevice::DataRate=10Mbps trackTM=\"false\" mars=\"true\" TMReadMaxNum=\"2000\" TMRecordMaxNum=\"10000\" recordInterval=\"0.005\" readInterval=\"1\" reportInterval=\"0.073\" openGymPort=\"5561\" "
>>>>>> 这里似乎等号后面不需要加引号...which我后续再check把...
# 进入gdb后
(gdb) run --ns3::PointToPointNetDevice::DataRate=10Mbps

注意事项

  • configure的时候不要-d optimized 不然NSLOG就不好使了 …
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值