如何在OPNET Modeler的调试模式下显示打印语句? [英] How can I show print statements in debug mode of OPNET Modeler?

查看:236
本文介绍了如何在OPNET Modeler的调试模式下显示打印语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在OPNET Modeler中编写C ++代码。
我尝试在调试器模式下模拟我的场景我需要跟踪我写的功能。我需要在我的代码中显示打印语句。



我在调试器模式下使用: *** ltr function_name()** * 然后 *** c ***



但结果如下:

 为命令摘要键入'help'


ODB> ltr enqueue_packet()
添加trace#0:标签上的trace(enqueue_packet())

ODB> c
| -------------------------------------------- --------------------------------- |
|进度:时间(1分52秒);活动(500,002)|
|速度:平均(82,575事件/秒);当前(82,575事件/秒)|
|时间:已过(6.1秒)|
| DES日志:28条目|
| --------------------------------------------- -------------------------------- |
| --------------------------------------------- -------------------------------- |
|进度:时间(1分55秒);活动(1,000,002)|
|速度:平均(69,027事件/秒);当前(59,298事件/秒)|
|时间:过去(14秒)|
| DES日志:28条目|
| --------------------------------------------- -------------------------------- |
| --------------------------------------------- -------------------------------- |
|进度:时间(1分59秒);活动(1,500,002)|
|速度:平均(51,464次/秒);当前(34,108事件/秒)|
|时间:已逝(29秒)|
| DES日志:28条目|
| --------------------------------------------- -------------------------------- |
| --------------------------------------------- -------------------------------- |
|模拟完成 - 整理结果。 |
|活动总数(1,591,301);平均速度(48,803事件/秒)|
|时间:过去(33秒);模拟(2分0秒)|
| DES日志:29条目|
| --------------------------------------------- -------------------------------- |
| --------------------------------------------- -------------------------------- |
|阅读网络模型。 |
| --------------------------------------------- -------------------------------- |

我需要在我的代码中显示打印语句。
哪里必须出现?
运行模拟之前有任何步骤,以确保OPNET调试器使用Visual Studio&

解决方案

OPNET Modeler提供以下命令来打印跟踪输出:



op_prg_odb_print_major()将标准输出设备的字符串序列以主要缩进级别开始的ODB跟踪语句的格式打印。



op_prg_odb_print_minor()在标准输出设备上打印一系列字符串,格式为轻微缩进级别的ODB跟踪语句。



op_prg_text_output()打印一系列用户定义的字符串到标准输出设备。



例如:

  if(op_prg_odb_ltrace_active(tcp_window)){
/ *启用跟踪,输出窗口相关变量* /
char str0 [128],str1 [128],str2 [128];
sprintf(str0,rcv requests pending:(%d),num_rcvs_allowed);
sprintf(str1,local receive window:(%d),receive_window);
sprintf(str2,remote receive window:(%d),remote_window);
op_prg_odb_print_major(窗口相关变量,str0,str1,str2,OPC_NIL);

sprintf(str0,send unacked:(%d),send_unacked);
sprintf(str1,send_next:(%d),send_next);
sprintf(str2,receive next:(%d),receive_next);
op_prg_odb_print_minor(str0,str1,str2,OPC_NIL);
}

出现在标准输出设备上的示例输出:

  |窗口相关变量
| rcv请求待处理:(3)
|本地收到窗口:(6400)
|远程接收窗口:(10788)
|发送unacked:(4525)
| send_next:(5000)
| receive_next:(1200)

[从OPNET Modeler文档中获取的代码]



注意:我猜你正在修改标准模型并使用stdmod Repository。如果是这种情况,您的代码未被编译,您将不会在调试器中看到任何打印语句。请参阅首选项网络模拟存储库,查看是否使用存储库,而不是编译自己的代码。


I'm writing C++ code in OPNET Modeler. I try to simulate my scenario in debugger mode & I need to trace the function that I wrote it. I need to show print statements which I put it in my code.

I used in debugger mode: ***ltr function_name()*** then ***c***

But the result looks like:

Type 'help' for Command Summary


ODB> ltr enqueue_packet()
Added trace #0: trace on label (enqueue_packet())

ODB> c
|-----------------------------------------------------------------------------|
| Progress: Time (1 min. 52 sec.); Events (500,002)                           |
| Speed: Average (82,575 events/sec.); Current (82,575 events/sec.)           |
| Time : Elapsed (6.1 sec.)                                                   |
| DES Log: 28 entries                                                         |
|-----------------------------------------------------------------------------|
|-----------------------------------------------------------------------------|
| Progress: Time (1 min. 55 sec.); Events (1,000,002)                         |
| Speed: Average (69,027 events/sec.); Current (59,298 events/sec.)           |
| Time : Elapsed (14 sec.)                                                    |
| DES Log: 28 entries                                                         |
|-----------------------------------------------------------------------------|
|-----------------------------------------------------------------------------|
| Progress: Time (1 min. 59 sec.); Events (1,500,002)                         |
| Speed: Average (51,464 events/sec.); Current (34,108 events/sec.)           |
| Time : Elapsed (29 sec.)                                                    |
| DES Log: 28 entries                                                         |
|-----------------------------------------------------------------------------|
|-----------------------------------------------------------------------------|
| Simulation Completed - Collating Results.                                   |
| Events: Total (1,591,301); Average Speed (48,803 events/sec.)               |
| Time  : Elapsed (33 sec.); Simulated (2 min. 0 sec.)                        |
| DES Log: 29 entries                                                         |
|-----------------------------------------------------------------------------|
|-----------------------------------------------------------------------------|
| Reading network model.                                                      |
|-----------------------------------------------------------------------------|

I need to show the print statements in my code. Where it has to be appeared? Is there any step before run the simulation to insure that OPNET debugger using Visual Studio & go through my code??

解决方案

OPNET Modeler provides the following commands to print trace output:

op_prg_odb_print_major() Prints a sequence of strings to the standard output device, in the format of ODB trace statements starting at the major indentation level.

op_prg_odb_print_minor() Prints a sequence of strings to the standard output device, in the format of ODB trace statements at the minor indentation level.

op_prg_text_output() Prints a sequence of user-defined strings to the standard output device.

For example:

if (op_prg_odb_ltrace_active ("tcp_window")) {
  /* a trace is enabled, output Window-Related Variables */
  char str0[128], str1[128], str2[128];
  sprintf (str0, "rcv requests pending : (%d)", num_rcvs_allowed);
  sprintf (str1, "local receive window : (%d)", receive_window);
  sprintf (str2, "remote receive window : (%d)", remote_window);
  op_prg_odb_print_major ("Window-Related Variables", str0, str1, str2, OPC_NIL);

  sprintf (str0, "send unacked : (%d)", send_unacked);
  sprintf (str1, "send_next : (%d)", send_next);
  sprintf (str2, "receive next : (%d)", receive_next);
  op_prg_odb_print_minor (str0, str1, str2, OPC_NIL);
}

Example output as it appears on the standard output device:

            |       Window-Related Variables
            |               rcv requests pending : (3)
            |               local receive window : (6400)
            |               remote receive window : (10788)
            |               send unacked : (4525)
            |               send_next : (5000)
            |               receive_next : (1200)

[Code taken from OPNET Modeler documentation.]

Note: I am guessing that you are modifying the standard models and are using the stdmod Repository. If this is the case, your code is not being compiled and you will not see any print statements in the debugger. See preference "Network simulation Repositories" to see if you are using a repository instead of compiling your own code.

这篇关于如何在OPNET Modeler的调试模式下显示打印语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆