简单了解一下ndnSIM中的APP

来源:互联网 发布:用友软件 编辑:程序博客网 时间:2024/04/29 09:36

Application helper

Application helper是创建、配置、安装ndnSIM application的入口。
基本用法:

  • 创建一个特定类型的app:
// Create helper for the consumer generating Interests with constant rateAppHelper consumerHelper("ns3::ndn::ConsumerCbr");
  • 设置前缀
    前缀是interest请求数据的时候用的,返回data的时候也会用到
consumerHelper.SetPrefix(prefix);
  • 设置特定的属性
// Set frequency parameterconsumerHelper.SetAttribute("Frequency", StringValue ("10")); // 10 interests a second
  • 安装
NodeContainer nodes;...consumerHelper.Install(nodes)

各种apps

ConsumerCbr

以预定义的模式来产生Interest包,比如固定频率,指数随机等。

// Create application using the app helperAppHelper helper("ns3::ndn::ConsumerCbr");
  • 固定频率
 // Set attribute using the app helperhelper.SetAttribute("Frequency", DoubleValue (1.0));
  • 随机
    参数选项
    1. ”none”没有随机化
    2. “uniform” (0, 1/Frequency)范围内的均匀分布
    3. “exponential”平均值为1/Frequency的指数分布
// Set attribute using the app helperhelper.SetAttribute("Randomize", StringValue("uniform"));

ConsumerZipfMandelbrot

产生服从Zipf-Mandelbrot分布的interest

// Create application using the app helperndn::AppHelper helper("ns3::ndn::ConsumerZipfMandelbrot");

ConsumerBatches

ConsumerBatches是一种开关风格的应用,它可以在特定的节点产生指定数量的interest。

// Create application using the app helperndn::AppHelper consumerHelper("ns3::ndn::ConsumerBatches");

主要参数

Batches

用于指定interest包的模式,默认为空,模式是指,有多少interest包在什么时候被发送。如1个Interest在时间点1秒时,被发送,5个Interest在2秒时被发送,2个Interest在10秒时被发送。

// Set attribute using the app helperconsumerHelper.SetAttribute("Batches", StringValue("1s 1 2s 5 10s 2"));

由于Interest包不是瞬发的,ConsumerBatches仅仅是在指定时间开始数据包的发送,有可能出现如下结果:

1s 0 ndn.Consumer:SendPacket(): [INFO ] > Interest for 02s 0 ndn.Consumer:SendPacket(): [INFO ] > Interest for 12s 0 ndn.Consumer:SendPacket(): [INFO ] > Interest for 22.2s 0 ndn.Consumer:SendPacket(): [INFO ] > Interest for 32.4s 0 ndn.Consumer:SendPacket(): [INFO ] > Interest for 42.6s 0 ndn.Consumer:SendPacket(): [INFO ] > Interest for 510s 0 ndn.Consumer:SendPacket(): [INFO ] > Interest for 610.2s 0 ndn.Consumer:SendPacket(): [INFO ] > Interest for 7

ConsumerWindow

ConsumerWindow是一种产生变化速率Interest包的app。

// Create application using the app helperAppHelper consumerHelper("ns3::ndn::ConsumerWindow");

参数:

  • window 它的值表示Initial number of Interests that will be send out without waiting for the data (number of outstanding Interests)
  • PayloadSize data的payload
  • Size 默认-1,Amount of data to be requested (will stop issuing Interests after Size data is received) ,If Size is set to -1, Interests will be requested till the end of the simulation.

Producer

// Create application using the app helperAppHelper consumerHelper("ns3::ndn::Producer");

Custom applications

APP通过AppLinkService 与系统的核心进行交互,为了简化NDN中APP的实现, ndnSIM提供了一个基本的App类, 它已经将AppLinkService 创建好并注册到NDN的协议栈中,同时,提供了默认的处理Interest和Data包的方法。

研究代码中。。。更多详细待补充

0 0