00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "olsr-helper.h"
00021 #include "ns3/olsr-agent.h"
00022 #include "ns3/node-list.h"
00023
00024 namespace ns3 {
00025
00026 OlsrHelper::OlsrHelper ()
00027 {
00028 m_agentFactory.SetTypeId ("ns3::olsr::AgentImpl");
00029 }
00030
00031 void
00032 OlsrHelper::SetAgent (std::string tid,
00033 std::string n0, const AttributeValue &v0,
00034 std::string n1, const AttributeValue &v1,
00035 std::string n2, const AttributeValue &v2,
00036 std::string n3, const AttributeValue &v3,
00037 std::string n4, const AttributeValue &v4,
00038 std::string n5, const AttributeValue &v5,
00039 std::string n6, const AttributeValue &v6,
00040 std::string n7, const AttributeValue &v7)
00041 {
00042 m_agentFactory.SetTypeId (tid);
00043 m_agentFactory.Set (n0, v0);
00044 m_agentFactory.Set (n1, v1);
00045 m_agentFactory.Set (n2, v2);
00046 m_agentFactory.Set (n3, v3);
00047 m_agentFactory.Set (n4, v4);
00048 m_agentFactory.Set (n5, v5);
00049 m_agentFactory.Set (n6, v6);
00050 m_agentFactory.Set (n7, v7);
00051 }
00052
00053 void
00054 OlsrHelper::Install (NodeContainer container)
00055 {
00056 for (NodeContainer::Iterator i = container.Begin (); i != container.End (); ++i)
00057 {
00058 Ptr<Node> node = *i;
00059 Install (node);
00060 }
00061 }
00062 void
00063 OlsrHelper::Install (Ptr<Node> node)
00064 {
00065 if (node->GetObject<olsr::Agent> () != 0)
00066 {
00067 NS_FATAL_ERROR ("OlsrHelper::Install(): Aggregating "
00068 "an Olsr Agent to a node with an existing Olsr Agent");
00069 return;
00070 }
00071 Ptr<olsr::Agent> agent = m_agentFactory.Create<olsr::Agent> ();
00072 agent->SetNode (node);
00073 node->AggregateObject (agent);
00074 agent->Start ();
00075 }
00076 void
00077 OlsrHelper::InstallAll (void)
00078 {
00079 Install (NodeContainer::GetGlobal ());
00080 }
00081
00082 }