opnet14.5学习总结三

来源:互联网 发布:caffe style transfer 编辑:程序博客网 时间:2024/04/28 20:28

opnet14.5学习总结三

看懂的问题要总结
存疑的地方要记录

计包模型的总结。

1.那些地方可以写c代码

The three primary places to use Proto-C are as follows:

• Enter Executive—code that is executed when the module moves into a state
• Exit Executive—code that is executed when the module leaves a state
• Transition Executive—code that is executed in response to a specific event

疑问:转移的过程中会执行代码,然后到达一个新的状态。紧接着执行新状态的入口代码。为什么不把新状态的入口代码放在前一个状态的转移过程中呢?出口代码何时执行?

2.那些地方可以申明变量
临时变量、状态变量、代码中的变量

You can declare variables in three places:

  • Variables declared in the temporary variables block do not retain their values between invocations of the FSM.
  • Variables declared in the state variables block retain their values from invocation to invocation.
  • Variables declared inside a state’s executive are only defined while that executive is executed.

2.控制权
仿真的控制权主要掌握在仿真核心手里。当发生中断的时候,仿真核心会将控制权交给相应的进程模型。进程模型处理完后又将控制权还给仿真核心。
这里的控制权是指对什么的控制呢?应该是系统资源,比如内存等。

3.为什么需要init状态?
计包的逻辑需要两部:

  • 一个状态等待包的来临
  • 包来临后计算包的个数

个人感觉这里只需要一个idle状态就可以。当包到达时指向自身。
当然,包来临后跳转到另一个状态也是可以。FSM的分工更加清晰。
那么何时需要init状态呢?

You also need an initialization state that sets the appropriate variables to zero.

如果init只是为了使一些程序即将用到的变量赋初始值的话,直观第一个包到达时就可以设置。
不过有些变量的初始值只需要设置一次,如果放在包达到时设置的话就会多次赋值。

4.强制状态和非强制状态
区别在于执行完入口代码是否将控制权返还给仿真核心。

An unforced (red) state is one that returns control of the simulation to the Simulation Kernel after executing its enter executives. A forced (green) state is one that does not return control, but instead immediately executes the exit executives and transitions to another state.

5.condition
condition是状态转移的条件,转移状态时不一定需要执行代码。

6.default condition

  • 仿真核心维持的时间列表是面向所有的进程模型的
  • 每一次只有一个进程模型响应
  • 其余的进程不响应,变设置为default

You may be wondering why you included a transition from idle back to itself and named that transition default. As the simulation executes, the Simulation Kernel manages a list of events to take place. As each event reaches the top (or head) of that list, it becomes an interrupt. Interrupts are often delivered to specific modules, and this occurrence is what activates the module’s process model.

7.帮助文档
提供了两个帮助文档:

  • ctrl+h 最常用的
  • ctrl+shift+h 最全面的

如何使用帮助文档?
我们不可能对所有的核心函数都熟悉,当我们觉得自己需要什么函数的时候,我们先找到大致的方向,然后进一步查找,做到有的放矢。

举例:

  1. The first task—determining the packet stream for the current interrupt—has to do with processing an interrupt. Find the section called Interrupt Processing.
  2. From the KP descriptions, you determine that op_intrpt_strm() will return the necessary information.
  3. The next two tasks, getting the packet’s pointer and using that pointer to destroy the packet, both involve packet manipulation. Look in the Packet Generation and Processing section. You can use op_pk_get() to determine the packet’s pointer, then use that return value (the pointer) to call op_pk_destroy() to destroy the packet.
    4.The final task is to write out the value of the statistic. Refer to the Statistic Recording section for information on the op_stat_write() KP.

8.Process Interfaces

  • 进程模型组成模块,模块组成节点模型。节点的属性本质上来源于进程的属性。
  • 进程相当于操作系统的底层,里面有很多变量,但是为了降低使用者的复杂度或者没必要让使用者接触那么多变量,我们可以设置其属性为hidden,这样在节点层就看不见这个属性。
  • 属性提升的层级:进程层设置属性promoted,这样模块在选择进程模型时会显示这些属性。将这些属性进一步提升promoted,这样在节点层就能看见。
  • 每一个进程模型都要设置其begsim intrpt attribute to enabled。仿真开始执行这件事也是一个中断。所有节点的所有进程都会接受这个中断,从而取得控制权。
  • 仿真核心维护的事件列表不断的发生,事件发生就是中断,中断的通信机制是广播。
  • 进程接口中设置的priority有什么用?

9.模块的属性提升
我们队模块进行属性配置时,经常会用到一个操作就是属性提升promoted
发包的函数我们可以自定义。
在进程模型中我们申明了一个统计量packet count,这个统计量可以在节点层可见,从而收集数据。

10.属性提升和申明统计量的区别
属性提升是一级一级的提升。
进程层的统计量申明在节点层直接可见。
这两者的不同本质在与属性和统计量不是一回事。属性属于输入,我们可以对其进行控制。统计量是输出,我们对属性设置后希望得到相应的统计量的变化情况。
统计量的名字有一个继承的特征。count模块使用了包计数的进程模型,包计数的进程模型中申明了统计量packet count,这样在节点层这个统计量就是count.packet count。我们可以对其重命名。
提升的属性的命名也是继承。

11.同时进行两个仿真
复制场景,设置不同的输入量,同时进行两个仿真。

tags:opnet

0 0
原创粉丝点击