本文整理汇总了C++中Ptr::AddRoute方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::AddRoute方法的具体用法?C++ Ptr::AddRoute怎么用?C++ Ptr::AddRoute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ptr
的用法示例。
在下文中一共展示了Ptr::AddRoute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: entry
void
DsrCacheEntryTest::DoRun ()
{
Ptr<dsr::RouteCache> rcache = CreateObject<dsr::RouteCache> ();
std::vector<Ipv4Address> ip;
ip.push_back (Ipv4Address ("0.0.0.0"));
ip.push_back (Ipv4Address ("0.0.0.1"));
Ipv4Address dst = Ipv4Address ("0.0.0.1");
dsr::RouteCacheEntry entry (ip, dst, Seconds (1));
NS_TEST_EXPECT_MSG_EQ (entry.GetVector ().size (), 2, "trivial");
NS_TEST_EXPECT_MSG_EQ (entry.GetDestination (), Ipv4Address ("0.0.0.1"), "trivial");
NS_TEST_EXPECT_MSG_EQ (entry.GetExpireTime (), Seconds (1), "trivial");
entry.SetExpireTime (Seconds (3));
NS_TEST_EXPECT_MSG_EQ (entry.GetExpireTime (), Seconds (3), "trivial");
entry.SetDestination (Ipv4Address ("1.1.1.1"));
NS_TEST_EXPECT_MSG_EQ (entry.GetDestination (), Ipv4Address ("1.1.1.1"), "trivial");
ip.push_back (Ipv4Address ("0.0.0.2"));
entry.SetVector (ip);
NS_TEST_EXPECT_MSG_EQ (entry.GetVector ().size (), 3, "trivial");
NS_TEST_EXPECT_MSG_EQ (rcache->AddRoute (entry), true, "trivial");
std::vector<Ipv4Address> ip2;
ip2.push_back (Ipv4Address ("1.1.1.0"));
ip2.push_back (Ipv4Address ("1.1.1.1"));
Ipv4Address dst2 = Ipv4Address ("1.1.1.1");
dsr::RouteCacheEntry entry2 (ip2, dst2, Seconds (2));
dsr::RouteCacheEntry newEntry;
NS_TEST_EXPECT_MSG_EQ (rcache->AddRoute (entry2), true, "trivial");
NS_TEST_EXPECT_MSG_EQ (rcache->LookupRoute (dst2, newEntry), true, "trivial");
NS_TEST_EXPECT_MSG_EQ (rcache->DeleteRoute (Ipv4Address ("2.2.2.2")), false, "trivial");
NS_TEST_EXPECT_MSG_EQ (rcache->DeleteRoute (Ipv4Address ("1.1.1.1")), true, "trivial");
NS_TEST_EXPECT_MSG_EQ (rcache->DeleteRoute (Ipv4Address ("1.1.1.1")), false, "trivial");
}