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 * 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
13namespace ns3
14{
15namespace lorawan
16{
17
18NS_LOG_COMPONENT_DEFINE("Forwarder");
19
21
22TypeId
24{
25 static TypeId tid = TypeId("ns3::Forwarder")
27 .AddConstructor<Forwarder>()
28 .SetGroupName("lorawan");
29 return tid;
30}
31
36
41
42void
44{
45 NS_LOG_FUNCTION(this << pointToPointNetDevice);
46
47 m_pointToPointNetDevice = pointToPointNetDevice;
48}
49
50void
52{
53 NS_LOG_FUNCTION(this << loraNetDevice);
54
55 m_loraNetDevice = loraNetDevice;
56}
57
58bool
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
73bool
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
88void
90{
91 NS_LOG_FUNCTION(this);
92
93 // TODO Make sure we are connected to both needed devices
94}
95
96void
98{
100
101 // TODO Get rid of callbacks
102}
103
104} // namespace lorawan
105} // namespace ns3
a polymophic address class
Definition address.h:90
The base class for all ns3 applications.
Definition application.h:51
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
void SetPointToPointNetDevice(Ptr< PointToPointNetDevice > pointToPointNetDevice)
Sets the P2P device to use to communicate with the network server.
Definition forwarder.cc:43
static TypeId GetTypeId()
Register this type.
Definition forwarder.cc:23
Forwarder()
Default constructor.
Definition forwarder.cc:32
void StopApplication() override
Stop the application.
Definition forwarder.cc:97
void StartApplication() override
Start the application.
Definition forwarder.cc:89
Ptr< LoraNetDevice > m_loraNetDevice
Pointer to the node's LoraNetDevice.
Definition forwarder.h:91
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
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
void SetLoraNetDevice(Ptr< LoraNetDevice > loraNetDevice)
Sets the device to use to communicate with the end devices.
Definition forwarder.cc:51
Ptr< PointToPointNetDevice > m_pointToPointNetDevice
Pointer to the P2PNetDevice we use to communicate with the network server.
Definition forwarder.h:93
~Forwarder() override
Destructor.
Definition forwarder.cc:37
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.