Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
209 additions
and 0 deletions.
- +30 −0 extensions/ping-client-app.cpp
- +75 −0 extensions/ping-client-app.hpp
- +30 −0 extensions/ping-server-app.cpp
- +74 −0 extensions/ping-server-app.hpp
@@ -0,0 +1,30 @@ | ||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | ||
/* | ||
* Copyright (c) 2015 University of California, Los Angeles | ||
* | ||
* 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 | ||
* | ||
* Authors: Spyridon (Spyros) Mastorakis <mastorakis@cs.ucla.edu> | ||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu> | ||
*/ | ||
|
||
#include "ping-client-app.hpp" | ||
|
||
namespace ns3 { | ||
namespace ndn { | ||
|
||
NS_OBJECT_ENSURE_REGISTERED(PingClientApp); | ||
|
||
} // namespace ndn | ||
} // namespace ns3 |
@@ -0,0 +1,75 @@ | ||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | ||
/* | ||
* Copyright (c) 2015 University of California, Los Angeles | ||
* | ||
* 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 | ||
* | ||
* Authors: Spyridon (Spyros) Mastorakis <mastorakis@cs.ucla.edu> | ||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu> | ||
*/ | ||
|
||
#include "ns3/ndnSIM-module.h" | ||
#include "ns3/integer.h" | ||
#include "ns3/string.h" | ||
|
||
#include "ping-client.hpp" | ||
|
||
namespace ns3 { | ||
namespace ndn { | ||
|
||
namespace ping = ::ndn::ping; | ||
|
||
class PingClientApp : public Application | ||
{ | ||
public: | ||
static TypeId | ||
GetTypeId() | ||
{ | ||
static TypeId tid = TypeId("PingClientApp") | ||
.SetParent<Application>() | ||
.AddConstructor<PingClientApp>() | ||
.AddAttribute("Prefix", "Prefix for ping interests", StringValue("/"), | ||
MakeNameAccessor(&PingClientApp::m_prefix), MakeNameChecker()) | ||
.AddAttribute("nPings", "Number of ping interests to send", IntegerValue(1), | ||
MakeIntegerAccessor(&PingClientApp::m_nPings), MakeIntegerChecker<int32_t>()); | ||
|
||
|
||
return tid; | ||
} | ||
|
||
protected: | ||
// inherited from Application base class. | ||
virtual void | ||
StartApplication() | ||
{ | ||
m_instance.reset(new ping::PingClient); | ||
m_instance->setPrefix(m_prefix); | ||
m_instance->setNPings(m_nPings); | ||
m_instance->run(); | ||
} | ||
|
||
virtual void | ||
StopApplication() | ||
{ | ||
m_instance.reset(); | ||
} | ||
|
||
private: | ||
std::unique_ptr<ping::PingClient> m_instance; | ||
uint32_t m_nPings; | ||
Name m_prefix; | ||
}; | ||
|
||
} // namespace ndn | ||
} // namespace ns3 |
@@ -0,0 +1,30 @@ | ||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | ||
/* | ||
* Copyright (c) 2015 University of California, Los Angeles | ||
* | ||
* 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 | ||
* | ||
* Authors: Spyridon (Spyros) Mastorakis <mastorakis@cs.ucla.edu> | ||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu> | ||
*/ | ||
|
||
#include "ping-server-app.hpp" | ||
|
||
namespace ns3 { | ||
namespace ndn { | ||
|
||
NS_OBJECT_ENSURE_REGISTERED(PingServerApp); | ||
|
||
} // namespace ndn | ||
} // namespace ns3 |
@@ -0,0 +1,74 @@ | ||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | ||
/* | ||
* Copyright (c) 2015 University of California, Los Angeles | ||
* | ||
* 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 | ||
* | ||
* Authors: Spyridon (Spyros) Mastorakis <mastorakis@cs.ucla.edu> | ||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu> | ||
*/ | ||
|
||
#include "ns3/ndnSIM-module.h" | ||
#include "ns3/integer.h" | ||
#include "ns3/string.h" | ||
|
||
#include "ping-server.hpp" | ||
|
||
namespace ns3 { | ||
namespace ndn { | ||
|
||
namespace ping = ::ndn::ping; | ||
|
||
class PingServerApp : public Application | ||
{ | ||
public: | ||
static TypeId | ||
GetTypeId() | ||
{ | ||
static TypeId tid = TypeId("PingServerApp") | ||
.SetParent<Application>() | ||
.AddConstructor<PingServerApp>() | ||
.AddAttribute("Prefix", "Prefix for ping interests", StringValue("/"), | ||
MakeNameAccessor(&PingServerApp::m_prefix), MakeNameChecker()) | ||
.AddAttribute("nMaxPings", "Maximum number of ping interests to be satisfied", IntegerValue(1), | ||
MakeIntegerAccessor(&PingServerApp::m_nMaxPings), MakeIntegerChecker<int32_t>()); | ||
|
||
return tid; | ||
} | ||
|
||
protected: | ||
// inherited from Application base class. | ||
virtual void | ||
StartApplication() | ||
{ | ||
m_instance.reset(new ping::PingServer); | ||
m_instance->setPrefix(m_prefix); | ||
m_instance->setNMaxPings(m_nMaxPings); | ||
m_instance->run(); | ||
} | ||
|
||
virtual void | ||
StopApplication() | ||
{ | ||
m_instance.reset(); | ||
} | ||
|
||
private: | ||
std::unique_ptr<ping::PingServer> m_instance; | ||
std::uint32_t m_nMaxPings; | ||
Name m_prefix; | ||
}; | ||
|
||
} // namespace ndn | ||
} // namespace ns3 |