A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
forwarder.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2017 University of Padova
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Davide Magrin <magrinda@dei.unipd.it>
7
*/
8
9
#include "
forwarder.h
"
10
11
#include "ns3/log.h"
12
13
namespace
ns3
14
{
15
namespace
lorawan
16
{
17
18
NS_LOG_COMPONENT_DEFINE
(
"Forwarder"
);
19
20
NS_OBJECT_ENSURE_REGISTERED
(Forwarder);
21
22
TypeId
23
Forwarder::GetTypeId
()
24
{
25
static
TypeId
tid =
TypeId
(
"ns3::Forwarder"
)
26
.
SetParent
<
Application
>()
27
.AddConstructor<Forwarder>()
28
.SetGroupName(
"lorawan"
);
29
return
tid;
30
}
31
32
Forwarder::Forwarder
()
33
{
34
NS_LOG_FUNCTION_NOARGS
();
35
}
36
37
Forwarder::~Forwarder
()
38
{
39
NS_LOG_FUNCTION_NOARGS
();
40
}
41
42
void
43
Forwarder::SetPointToPointNetDevice
(
Ptr<PointToPointNetDevice>
pointToPointNetDevice)
44
{
45
NS_LOG_FUNCTION
(
this
<< pointToPointNetDevice);
46
47
m_pointToPointNetDevice
= pointToPointNetDevice;
48
}
49
50
void
51
Forwarder::SetLoraNetDevice
(
Ptr<LoraNetDevice>
loraNetDevice)
52
{
53
NS_LOG_FUNCTION
(
this
<< loraNetDevice);
54
55
m_loraNetDevice
= loraNetDevice;
56
}
57
58
bool
59
Forwarder::ReceiveFromLora
(
Ptr<NetDevice>
loraNetDevice,
60
Ptr<const Packet>
packet,
61
uint16_t protocol,
62
const
Address
& sender)
63
{
64
NS_LOG_FUNCTION
(
this
<< packet << protocol << sender);
65
66
Ptr<Packet>
packetCopy = packet->Copy();
67
68
m_pointToPointNetDevice
->Send(packetCopy,
m_pointToPointNetDevice
->GetBroadcast(), 0x800);
69
70
return
true
;
71
}
72
73
bool
74
Forwarder::ReceiveFromPointToPoint
(
Ptr<NetDevice>
pointToPointNetDevice,
75
Ptr<const Packet>
packet,
76
uint16_t protocol,
77
const
Address
& sender)
78
{
79
NS_LOG_FUNCTION
(
this
<< packet << protocol << sender);
80
81
Ptr<Packet>
packetCopy = packet->Copy();
82
83
m_loraNetDevice
->Send(packetCopy);
84
85
return
true
;
86
}
87
88
void
89
Forwarder::StartApplication
()
90
{
91
NS_LOG_FUNCTION
(
this
);
92
93
// TODO Make sure we are connected to both needed devices
94
}
95
96
void
97
Forwarder::StopApplication
()
98
{
99
NS_LOG_FUNCTION_NOARGS
();
100
101
// TODO Get rid of callbacks
102
}
103
104
}
// namespace lorawan
105
}
// namespace ns3
ns3::Address
a polymophic address class
Definition
address.h:90
ns3::Application
The base class for all ns3 applications.
Definition
application.h:51
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
ns3::lorawan::Forwarder::SetPointToPointNetDevice
void SetPointToPointNetDevice(Ptr< PointToPointNetDevice > pointToPointNetDevice)
Sets the P2P device to use to communicate with the network server.
Definition
forwarder.cc:43
ns3::lorawan::Forwarder::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition
forwarder.cc:23
ns3::lorawan::Forwarder::Forwarder
Forwarder()
Default constructor.
Definition
forwarder.cc:32
ns3::lorawan::Forwarder::StopApplication
void StopApplication() override
Stop the application.
Definition
forwarder.cc:97
ns3::lorawan::Forwarder::StartApplication
void StartApplication() override
Start the application.
Definition
forwarder.cc:89
ns3::lorawan::Forwarder::m_loraNetDevice
Ptr< LoraNetDevice > m_loraNetDevice
Pointer to the node's LoraNetDevice.
Definition
forwarder.h:91
ns3::lorawan::Forwarder::ReceiveFromPointToPoint
bool ReceiveFromPointToPoint(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &sender)
Receive a packet from the PointToPointNetDevice.
Definition
forwarder.cc:74
ns3::lorawan::Forwarder::ReceiveFromLora
bool ReceiveFromLora(Ptr< NetDevice > loraNetDevice, Ptr< const Packet > packet, uint16_t protocol, const Address &sender)
Receive a packet from the LoraNetDevice.
Definition
forwarder.cc:59
ns3::lorawan::Forwarder::SetLoraNetDevice
void SetLoraNetDevice(Ptr< LoraNetDevice > loraNetDevice)
Sets the device to use to communicate with the end devices.
Definition
forwarder.cc:51
ns3::lorawan::Forwarder::m_pointToPointNetDevice
Ptr< PointToPointNetDevice > m_pointToPointNetDevice
Pointer to the P2PNetDevice we use to communicate with the network server.
Definition
forwarder.h:93
ns3::lorawan::Forwarder::~Forwarder
~Forwarder() override
Destructor.
Definition
forwarder.cc:37
forwarder.h
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition
log-macros-enabled.h:195
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:229
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
lorawan
model
forwarder.cc
Generated on Fri Nov 8 2024 13:59:02 for ns-3 by
1.11.0