Reference applications
ndnSIM包含一些可用作NDN仿真基礎的參考應用程序。
ConsumerCbr
一個以預定義模式(恒定頻率,恒定平均速率,興趣發(fā)布間隔均勻隨機分布或者指數(shù)隨機分布)產生興趣業(yè)務的應用。
// Create application using the app helper
AppHelper helper("ns3::ndn::ConsumerCbr");
這個應用有以下屬性:
- 頻率(默認1Hz,1 per second),既是期望的頻率for randomized version也是準確的頻率for contant version
// Set attribute using the app helper
helper.SetAttribute("Frequency", DoubleValue (1.0));
- Randomize (默認"none")
明確是否要對興趣包的間隔進行隨機化。有以下幾個變量可以考慮:
"none": no randomization
"uniform": uniform distribution in range (0, 1/Frequency)
"exponential": exponential distribution with mean 1/Frequency
// Set attribute using the app helper
helper.SetAttribute("Randomize", StringValue("uniform"));
ConsumerZipfMandelbrot
請求內容服從Zipf-Mandelbrot分布,繼承自ConsumerCbr
// Create application using the app helper
ndn::AppHelper helper("ns3::ndn::ConsumerZipfMandelbrot");
Frequency and Randomize屬性的設置和ComsumerCbr一致
多了一個屬性:
- NumberOfContents(默認100)應用所請求的不同內容(序列)的數(shù)量
ConsumerBatches
在指定的模擬點生成指定數(shù)量的興趣的開關式應用程序。
// Create application using the app helper
ndn::AppHelper consumerHelper("ns3::ndn::ConsumerBatches");
有以下屬性:
- Batches (默認:Empty)
指定興趣數(shù)據包的確切模式,指定何時以及應該發(fā)送多少興趣數(shù)據包。
下面的例子定義1s時應該請求一個興趣,2s時請求5個興趣,10S時請求2個興趣。
/ /Set attribute using the app helper
consumerHelper.SetAttribute("Batches", StringValue("1s 1 2s 5 10s 2"));
興趣不會在指定時間一起發(fā)出,而是會根據估計的重傳時間分開發(fā)送:
所以,可能會導致以下的興趣發(fā)送表:
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
一個生成可變速率興趣包發(fā)送的app,實現(xiàn)了一個簡單的基于滑動窗口的興趣生成機制。
// Create application using the app helper
AppHelper consumerHelper("ns3::ndn::ConsumerWindow");
有以下屬性:
- Window(默認1):在不等待數(shù)據(未完成興趣的數(shù)量)的情況下將被發(fā)送的初始興趣數(shù)量
- PayloadSize(默認1040):期望的數(shù)據包負載的大小
- Size(默認-1):
要請求的數(shù)據量(將在收到大小數(shù)據后停止發(fā)布興趣)如果Size設置為-1,則將要求興趣直到模擬結束。
Producer
replying every incoming Interest with Data packet with a specified size and name same as in Interest.
// Create application using the app helper
AppHelper consumerHelper("ns3::ndn::Producer");