A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
forwarder.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 University of Padova
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Davide Magrin <magrinda@dei.unipd.it>
18 */
19
20#include "forwarder.h"
21
22#include "ns3/log.h"
23
24namespace ns3
25{
26namespace lorawan
27{
28
29NS_LOG_COMPONENT_DEFINE("Forwarder");
30
32
33TypeId
35{
36 static TypeId tid = TypeId("ns3::Forwarder")
38 .AddConstructor<Forwarder>()
39 .SetGroupName("lorawan");
40 return tid;
41}
42
44{
46}
47
49{
51}
52
53void
55{
56 NS_LOG_FUNCTION(this << pointToPointNetDevice);
57
58 m_pointToPointNetDevice = pointToPointNetDevice;
59}
60
61void
63{
64 NS_LOG_FUNCTION(this << loraNetDevice);
65
66 m_loraNetDevice = loraNetDevice;
67}
68
69bool
71 Ptr<const Packet> packet,
72 uint16_t protocol,
73 const Address& sender)
74{
75 NS_LOG_FUNCTION(this << packet << protocol << sender);
76
77 Ptr<Packet> packetCopy = packet->Copy();
78
79 m_pointToPointNetDevice->Send(packetCopy, m_pointToPointNetDevice->GetBroadcast(), 0x800);
80
81 return true;
82}
83
84bool
86 Ptr<const Packet> packet,
87 uint16_t protocol,
88 const Address& sender)
89{
90 NS_LOG_FUNCTION(this << packet << protocol << sender);
91
92 Ptr<Packet> packetCopy = packet->Copy();
93
94 m_loraNetDevice->Send(packetCopy);
95
96 return true;
97}
98
99void
101{
102 NS_LOG_FUNCTION(this);
103
104 // TODO Make sure we are connected to both needed devices
105}
106
107void
109{
111
112 // TODO Get rid of callbacks
113}
114
115} // namespace lorawan
116} // namespace ns3
a polymophic address class
Definition: address.h:101
The base class for all ns3 applications.
Definition: application.h:62
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
void SetPointToPointNetDevice(Ptr< PointToPointNetDevice > pointToPointNetDevice)
Sets the P2P device to use to communicate with the network server.
Definition: forwarder.cc:54
static TypeId GetTypeId()
Register this type.
Definition: forwarder.cc:34
Forwarder()
Default constructor.
Definition: forwarder.cc:43
void StopApplication() override
Stop the application.
Definition: forwarder.cc:108
void StartApplication() override
Start the application.
Definition: forwarder.cc:100
Ptr< LoraNetDevice > m_loraNetDevice
Pointer to the node's LoraNetDevice.
Definition: forwarder.h:102
bool ReceiveFromPointToPoint(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &sender)
Receive a packet from the PointToPointNetDevice.
Definition: forwarder.cc:85
bool ReceiveFromLora(Ptr< NetDevice > loraNetDevice, Ptr< const Packet > packet, uint16_t protocol, const Address &sender)
Receive a packet from the LoraNetDevice.
Definition: forwarder.cc:70
void SetLoraNetDevice(Ptr< LoraNetDevice > loraNetDevice)
Sets the device to use to communicate with the end devices.
Definition: forwarder.cc:62
Ptr< PointToPointNetDevice > m_pointToPointNetDevice
Pointer to the P2PNetDevice we use to communicate with the network server.
Definition: forwarder.h:104
~Forwarder() override
Destructor.
Definition: forwarder.cc:48
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.