Application helper
Application helper是创建、配置、安装ndnSIM application的入口。
基本用法:
- 创建一个特定类型的app:
// Create helper for the consumer generating Interests with constant rate
AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
- 设置前缀
前缀是interest请求数据的时候用的,返回data的时候也会用到
consumerHelper.SetPrefix(prefix);
- 设置特定的属性
// Set frequency parameter
consumerHelper.SetAttribute("Frequency", StringValue ("10")); // 10 interests a second
- 安装
NodeContainer nodes;
...
consumerHelper.Install(nodes)
各种apps
ConsumerCbr
以预定义的模式来产生Interest包,比如固定频率,指数随机等。
// Create application using the app helper
AppHelper helper("ns3::ndn::ConsumerCbr");
- 固定频率
// Set attribute using the app helper
helper.SetAttribute("Frequency", DoubleValue (1.0));
- 随机
参数选项
- ”none”没有随机化
- “uniform” (0, 1/Frequency)范围内的均匀分布
- “exponential”平均值为1/Frequency的指数分布
// Set attribute using the app helper
helper.SetAttribute("Randomize", StringValue("uniform"));
ConsumerZipfMandelbrot
产生服从Zipf-Mandelbrot分布的interest
// Create application using the app helper
ndn::AppHelper helper("ns3::ndn::ConsumerZipfMandelbrot");
ConsumerBatches
ConsumerBatches是一种开关风格的应用,它可以在特定的节点产生指定数量的interest。
// Create application using the app helper
ndn::AppHelper consumerHelper("ns3::ndn::ConsumerBatches");
主要参数
Batches
用于指定interest包的模式,默认为空,模式是指,有多少interest包在什么时候被发送。如1个Interest在时间点1秒时,被发送,5个Interest在2秒时被发送,2个Interest在10秒时被发送。
// Set attribute using the app helper
consumerHelper.SetAttribute("Batches", StringValue("1s 1 2s 5 10s 2"));
由于Interest包不是瞬发的,ConsumerBatches仅仅是在指定时间开始数据包的发送,有可能出现如下结果:
1s 0 ndn.Consumer:SendPacket(): [INFO ] > Interest for 0
2s 0 ndn.Consumer:SendPacket(): [INFO ] > Interest for 1
2s 0 ndn.Consumer:SendPacket(): [INFO ] > Interest for 2
2.2s 0 ndn.Consumer:SendPacket(): [INFO ] > Interest for 3
2.4s 0 ndn.Consumer:SendPacket(): [INFO ] > Interest for 4
2.6s 0 ndn.Consumer:SendPacket(): [INFO ] > Interest for 5
10s 0 ndn.Consumer:SendPacket(): [INFO ] > Interest for 6
10.2s 0 ndn.Consumer:SendPacket(): [INFO ] > Interest for 7
ConsumerWindow
ConsumerWindow是一种产生变化速率Interest包的app。
// Create application using the app helper
AppHelper 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 helper
AppHelper consumerHelper("ns3::ndn::Producer");
Custom applications
APP通过AppLinkService 与系统的核心进行交互,为了简化NDN中APP的实现, ndnSIM提供了一个基本的App类, 它已经将AppLinkService 创建好并注册到NDN的协议栈中,同时,提供了默认的处理Interest和Data包的方法。
研究代码中。。。更多详细待补充