Add a simpler olsr::EnableAllNodes API as suggested by Mathieu.

This commit is contained in:
Gustavo J. A. M. Carneiro
2007-07-30 17:33:12 +01:00
parent acde0b6311
commit e4dedb226f
4 changed files with 93 additions and 14 deletions

View File

@@ -65,7 +65,7 @@
#include "ns3/onoff-application.h"
#include "ns3/debug.h"
#include "ns3/olsr-agent.h"
#include "ns3/olsr.h"
using namespace ns3;
@@ -138,20 +138,9 @@ int main (int argc, char *argv[])
// Run OLSR in each node.
ComponentManager::Create<OlsrAgent, Ptr<Node> >
(OlsrAgent::cid, OlsrAgent::iid, n0)->Start ();
ComponentManager::Create<OlsrAgent, Ptr<Node> >
(OlsrAgent::cid, OlsrAgent::iid, n1)->Start ();
ComponentManager::Create<OlsrAgent, Ptr<Node> >
(OlsrAgent::cid, OlsrAgent::iid, n2)->Start ();
ComponentManager::Create<OlsrAgent, Ptr<Node> >
(OlsrAgent::cid, OlsrAgent::iid, n3)->Start ();
olsr::EnableAllNodes ();
#if 1
// Create the OnOff application to send UDP datagrams of size
// 210 bytes at a rate of 448 Kb/s
Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
@@ -176,7 +165,6 @@ int main (int argc, char *argv[])
// Start the application
ooff->Start(Seconds(1.1));
ooff->Stop (Seconds(10.0));
#endif
// Configure tracing of all enqueue, dequeue, and NetDevice receive events
// Trace output will be sent to the simple-p2p.tr file

52
src/routing/olsr/olsr.cc Normal file
View File

@@ -0,0 +1,52 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2007 INESC Porto
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
*/
#include "olsr-agent.h"
#include "olsr.h"
namespace ns3 { namespace olsr {
void
EnableAllNodes (void)
{
EnableNodes (NodeList::Begin (), NodeList::End ());
}
void
EnableNodes (NodeList::Iterator begin, NodeList::Iterator end)
{
for (NodeList::Iterator i = begin; i != end; i++)
{
EnableNode (*i);
}
}
void
EnableNode (Ptr<Node> node)
{
ComponentManager::Create<OlsrAgent, Ptr<Node> >
(OlsrAgent::cid, OlsrAgent::iid, node)->Start ();
}
}} // namespace ns3, olsr

37
src/routing/olsr/olsr.h Normal file
View File

@@ -0,0 +1,37 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2007 INESC Porto
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
*/
#ifndef OLSR_H
#define OLSR_H
#include "ns3/node-list.h"
namespace ns3
{
namespace olsr
{
void EnableAllNodes (void);
void EnableNodes (NodeList::Iterator begin, NodeList::Iterator end);
void EnableNode (Ptr<Node> node);
}
}
#endif /* OLSR_H */

View File

@@ -12,9 +12,11 @@ def build(bld):
'routing-table.cc',
'olsr-agent.cc',
'olsr-agent-impl.cc',
'olsr.cc',
]
headers = bld.create_obj('ns3header')
headers.source = [
'olsr-agent.h',
'olsr.h',
]