move code around
--HG-- rename : src/node/application-list.cc => src/applications/application-list.cc rename : src/node/application-list.h => src/applications/application-list.h rename : src/node/application.cc => src/applications/application.cc rename : src/node/application.h => src/applications/application.h rename : src/node/onoff-application.cc => src/applications/onoff-application.cc rename : src/node/onoff-application.h => src/applications/onoff-application.h rename : src/node/arp-cache.cc => src/internet-node/arp-cache.cc rename : src/node/arp-cache.h => src/internet-node/arp-cache.h rename : src/node/arp-header.cc => src/internet-node/arp-header.cc rename : src/node/arp-header.h => src/internet-node/arp-header.h rename : src/node/arp-ipv4-interface.cc => src/internet-node/arp-ipv4-interface.cc rename : src/node/arp-ipv4-interface.h => src/internet-node/arp-ipv4-interface.h rename : src/node/arp.cc => src/internet-node/arp.cc rename : src/node/arp.h => src/internet-node/arp.h rename : src/node/ascii-trace.cc => src/internet-node/ascii-trace.cc rename : src/node/ascii-trace.h => src/internet-node/ascii-trace.h rename : src/node/header-utils.cc => src/internet-node/header-utils.cc rename : src/node/header-utils.h => src/internet-node/header-utils.h rename : src/node/i-arp-private.cc => src/internet-node/i-arp-private.cc rename : src/node/i-arp-private.h => src/internet-node/i-arp-private.h rename : src/node/i-ipv4-impl.cc => src/internet-node/i-ipv4-impl.cc rename : src/node/i-ipv4-impl.h => src/internet-node/i-ipv4-impl.h rename : src/node/i-ipv4-private.cc => src/internet-node/i-ipv4-private.cc rename : src/node/i-ipv4-private.h => src/internet-node/i-ipv4-private.h rename : src/node/i-udp-impl.cc => src/internet-node/i-udp-impl.cc rename : src/node/i-udp-impl.h => src/internet-node/i-udp-impl.h rename : src/node/internet-node.cc => src/internet-node/internet-node.cc rename : src/node/internet-node.h => src/internet-node/internet-node.h rename : src/node/ipv4-checksum.cc => src/internet-node/ipv4-checksum.cc rename : src/node/ipv4-checksum.h => src/internet-node/ipv4-checksum.h rename : src/node/ipv4-end-point-demux.cc => src/internet-node/ipv4-end-point-demux.cc rename : src/node/ipv4-end-point-demux.h => src/internet-node/ipv4-end-point-demux.h rename : src/node/ipv4-end-point.cc => src/internet-node/ipv4-end-point.cc rename : src/node/ipv4-end-point.h => src/internet-node/ipv4-end-point.h rename : src/node/ipv4-header.cc => src/internet-node/ipv4-header.cc rename : src/node/ipv4-header.h => src/internet-node/ipv4-header.h rename : src/node/ipv4-interface.cc => src/internet-node/ipv4-interface.cc rename : src/node/ipv4-interface.h => src/internet-node/ipv4-interface.h rename : src/node/ipv4-l4-demux.cc => src/internet-node/ipv4-l4-demux.cc rename : src/node/ipv4-l4-demux.h => src/internet-node/ipv4-l4-demux.h rename : src/node/ipv4-l4-protocol.cc => src/internet-node/ipv4-l4-protocol.cc rename : src/node/ipv4-l4-protocol.h => src/internet-node/ipv4-l4-protocol.h rename : src/node/ipv4-loopback-interface.cc => src/internet-node/ipv4-loopback-interface.cc rename : src/node/ipv4-loopback-interface.h => src/internet-node/ipv4-loopback-interface.h rename : src/node/ipv4.cc => src/internet-node/ipv4.cc rename : src/node/ipv4.h => src/internet-node/ipv4.h rename : src/node/l3-demux.cc => src/internet-node/l3-demux.cc rename : src/node/l3-demux.h => src/internet-node/l3-demux.h rename : src/node/l3-protocol.cc => src/internet-node/l3-protocol.cc rename : src/node/l3-protocol.h => src/internet-node/l3-protocol.h rename : src/node/pcap-trace.cc => src/internet-node/pcap-trace.cc rename : src/node/pcap-trace.h => src/internet-node/pcap-trace.h rename : src/node/sgi-hashmap.h => src/internet-node/sgi-hashmap.h rename : src/node/udp-header.cc => src/internet-node/udp-header.cc rename : src/node/udp-header.h => src/internet-node/udp-header.h rename : src/node/udp-socket.cc => src/internet-node/udp-socket.cc rename : src/node/udp-socket.h => src/internet-node/udp-socket.h rename : src/node/udp.cc => src/internet-node/udp.cc rename : src/node/udp.h => src/internet-node/udp.h
This commit is contained in:
1 parent
681415672a
commit
fcd1de99c9
60 files changed
+114
-100
No files matched your search
@@ -1,195 +0,0 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2006 Georgia Tech Research Corporation
|
||||
*
|
||||
* 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: George F. Riley<riley@ece.gatech.edu>
|
||||
*/
|
||||
|
||||
// Implementation for ns3 Application base class.
|
||||
// George F. Riley, Georgia Tech, Fall 2006
|
||||
|
||||
#include "application.h"
|
||||
#include "node.h"
|
||||
#include "ns3/nstime.h"
|
||||
#include "ns3/random-variable.h"
|
||||
#include "ns3/simulator.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
// Application Methods
|
||||
|
||||
// \brief Application Constructor
|
||||
Application::Application(Node * n)
|
||||
: m_node (n),
|
||||
m_startVar(0), m_stopVar(0),
|
||||
m_start(false), m_stop(false)
|
||||
{
|
||||
m_node->Ref ();
|
||||
}
|
||||
|
||||
Application::Application(const Application& o)
|
||||
: m_node(0), m_startVar(0), m_stopVar(0),
|
||||
m_start(false), m_stop(false)
|
||||
{ // Copy constructor
|
||||
m_node = o.m_node;
|
||||
m_node->Ref ();
|
||||
// Copy the start and stop random variables if they exist
|
||||
if (o.m_startVar) m_startVar = o.m_startVar->Copy();
|
||||
if (o.m_stopVar) m_stopVar = o.m_stopVar->Copy();
|
||||
if (o.m_start) ScheduleStart();
|
||||
if (o.m_stop) ScheduleStop();
|
||||
}
|
||||
|
||||
|
||||
// \brief Application Destructor
|
||||
Application::~Application()
|
||||
{}
|
||||
|
||||
void
|
||||
Application::DoDispose (void)
|
||||
{
|
||||
if (m_node != 0)
|
||||
{
|
||||
m_node->Unref ();
|
||||
m_node = 0;
|
||||
}
|
||||
if (m_start)
|
||||
{
|
||||
Simulator::Cancel(m_startEvent);
|
||||
m_start = false;
|
||||
}
|
||||
if (m_stop)
|
||||
{
|
||||
Simulator::Cancel(m_stopEvent);
|
||||
m_stop = false;
|
||||
}
|
||||
delete m_startVar;
|
||||
m_startVar = 0;
|
||||
delete m_stopVar;
|
||||
m_stopVar = 0;
|
||||
}
|
||||
|
||||
Application& Application::operator=(const Application& rhs)
|
||||
{
|
||||
if (this == &rhs) return *this; // Self assignment
|
||||
m_node->Unref ();
|
||||
m_node = 0;
|
||||
m_node = rhs.m_node;
|
||||
m_node->Ref ();
|
||||
|
||||
delete m_startVar;
|
||||
m_startVar = 0;
|
||||
if (rhs.m_startVar) m_startVar = rhs.m_startVar->Copy();
|
||||
|
||||
delete m_stopVar;
|
||||
m_stopVar = 0;
|
||||
if (rhs.m_stopVar) m_stopVar = rhs.m_stopVar->Copy();
|
||||
|
||||
m_start = false;
|
||||
if (rhs.m_start) ScheduleStart();
|
||||
if (rhs.m_stop) ScheduleStop();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// \brief Specify application start time
|
||||
// The virtual method STartApp will be called at the time
|
||||
// specified by startTime.
|
||||
// \param Time to start application (absolute time, from start of simulation)
|
||||
void Application::Start(const Time& startTime)
|
||||
{
|
||||
delete m_startVar;
|
||||
m_startVar = new ConstantVariable(startTime.GetSeconds());
|
||||
ScheduleStart();
|
||||
}
|
||||
|
||||
void Application::Start(const RandomVariable& startVar)
|
||||
{ // Start at random time
|
||||
delete m_startVar;
|
||||
m_startVar = startVar.Copy();
|
||||
ScheduleStart();
|
||||
}
|
||||
|
||||
|
||||
// \brief Specify application stop time
|
||||
// The virtual method StopApp will be called at the time
|
||||
// specified by stopTime.
|
||||
// \param Time to stop application (absolute time, from start of simulation)
|
||||
void Application::Stop(const Time& stopTime)
|
||||
{
|
||||
delete m_stopVar;
|
||||
m_stopVar = new ConstantVariable(stopTime.GetSeconds());
|
||||
ScheduleStop();
|
||||
}
|
||||
|
||||
void Application::Stop(const RandomVariable& stopVar)
|
||||
{ // Stop at random time
|
||||
delete m_stopVar;
|
||||
m_stopVar = stopVar.Copy();
|
||||
ScheduleStop();
|
||||
}
|
||||
|
||||
// \brief Assign this application to a given node
|
||||
// Called by the application manager capability when adding
|
||||
// an application to a node.
|
||||
void Application::SetNode(Node * n)
|
||||
{
|
||||
if (m_node != 0)
|
||||
{
|
||||
m_node->Unref ();
|
||||
}
|
||||
m_node = n;
|
||||
m_node->Ref ();
|
||||
}
|
||||
|
||||
Node* Application::PeekNode() const
|
||||
{
|
||||
return m_node;
|
||||
}
|
||||
|
||||
// Protected methods
|
||||
// StartApp and StopApp will likely be overridden by application subclasses
|
||||
void Application::StartApplication()
|
||||
{ // Provide null functionality in case subclass is not interested
|
||||
}
|
||||
|
||||
void Application::StopApplication()
|
||||
{ // Provide null functionality in case subclass is not interested
|
||||
}
|
||||
|
||||
|
||||
// Private helpers
|
||||
void Application::ScheduleStart()
|
||||
{
|
||||
m_startEvent = Simulator::Schedule(Seconds(m_startVar->GetValue()) -
|
||||
Simulator::Now(),
|
||||
&Application::StartApplication, this);
|
||||
m_start = true;
|
||||
}
|
||||
|
||||
void Application::ScheduleStop()
|
||||
{
|
||||
m_stopEvent = Simulator::Schedule(Seconds(m_stopVar->GetValue()) -
|
||||
Simulator::Now(),
|
||||
&Application::StopApplication, this);
|
||||
m_stop = true;
|
||||
}
|
||||
|
||||
} //namespace ns3
|
||||
|
||||
|
||||
Reference in new issue
Block a user