opnet的sink模块学习 分类: opnet 2014-05-18 10:28 161人阅读 评论(0) 收藏

时间:2021-07-04 17:27:47

opnet的sink模块学习                                                    分类:            opnet             2014-05-18 10:28    161人阅读    评论(0)    收藏

Sink模块的状态机很简单,只有INIT和DISCARD两个,非强制状态只有DISCARD用于包的销毁。Sink模块的作用就是销毁从输入流接收到的包,并且返回关于包的一系列统计量。

Init的入口代码为

/* Initilaize the statistic handles to keep         */

/* track of traffic sinked by this process.         */

bits_rcvd_stathandle               =op_stat_reg ("Traffic Sink.Traffic Received (bits)",                          OPC_STAT_INDEX_NONE,OPC_STAT_LOCAL);

bitssec_rcvd_stathandle        =op_stat_reg ("Traffic Sink.Traffic Received (bits/sec)",                  OPC_STAT_INDEX_NONE,OPC_STAT_LOCAL);

pkts_rcvd_stathandle              =op_stat_reg ("Traffic Sink.Traffic Received (packets)",                  OPC_STAT_INDEX_NONE,OPC_STAT_LOCAL);

pktssec_rcvd_stathandle       =op_stat_reg ("Traffic Sink.Traffic Received (packets/sec)", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);

ete_delay_stathandle               =op_stat_reg ("Traffic Sink.End-to-End Delay (seconds)",              OPC_STAT_INDEX_NONE,OPC_STAT_LOCAL);

bits_rcvd_gstathandle            =op_stat_reg ("Traffic Sink.Traffic Received (bits)",                          OPC_STAT_INDEX_NONE,OPC_STAT_GLOBAL);

bitssec_rcvd_gstathandle      =op_stat_reg ("Traffic Sink.Traffic Received (bits/sec)",                  OPC_STAT_INDEX_NONE,OPC_STAT_GLOBAL);

pkts_rcvd_gstathandle           =op_stat_reg ("Traffic Sink.Traffic Received (packets)",                  OPC_STAT_INDEX_NONE,OPC_STAT_GLOBAL);

pktssec_rcvd_gstathandle     =op_stat_reg ("Traffic Sink.Traffic Received (packets/sec)", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);

ete_delay_gstathandle            =op_stat_reg ("Traffic Sink.End-to-End Delay (seconds)",              OPC_STAT_INDEX_NONE,OPC_STAT_GLOBAL);

op_stat_reg函数的作用是返回进程模型中节点或模块统计量,即初始化统计量句柄,第一个参数为统计量所在组的名称

所以上述代码分别返回的是局部统计量和全局统计量,包括:收到的bit数,bit速率,包数,包速率,端对端延时

DISCARD仅有出口代码:

/* Obtain the incoming packet.       */

pkptr = op_pk_get (op_intrpt_strm ());

从输入流中获取包的指针

/* Caclulate metrics to be updated.                 */

pk_size = (double) op_pk_total_size_get (pkptr);

ete_delay = op_sim_time () - op_pk_creation_time_get (pkptr);

计算包的总体大小和包传输延时

/* Update local statistics. */

op_stat_write函数功能为写入统计量,第一个参数为统计量的统计量句柄,第二个参数为统计量将写入的值。

op_stat_write (bits_rcvd_stathandle,            pk_size);收到的bit数

op_stat_write (pkts_rcvd_stathandle,           1.0); 收到的包

op_stat_write (ete_delay_stathandle,                    ete_delay);端对端延时

op_stat_write (bitssec_rcvd_stathandle,      pk_size);
bit速率

op_stat_write (bitssec_rcvd_stathandle,      0.0);

op_stat_write (pktssec_rcvd_stathandle,     1.0);  包速率

op_stat_write (pktssec_rcvd_stathandle,     0.0);

/* Update global statistics.     */全局统计量

op_stat_write (bits_rcvd_gstathandle,                   pk_size);

op_stat_write (pkts_rcvd_gstathandle,                  1.0);

op_stat_write (ete_delay_gstathandle,                  ete_delay);

op_stat_write (bitssec_rcvd_gstathandle,   pk_size);

op_stat_write (bitssec_rcvd_gstathandle,   0.0);

op_stat_write (pktssec_rcvd_gstathandle, 1.0);

op_stat_write (pktssec_rcvd_gstathandle, 0.0);

/* Destroy the received packet.      */

op_pk_destroy (pkptr); 销毁包

版权声明:本文为博主原创文章,未经博主允许不得转载。