A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
forwarder.h
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#ifndef FORWARDER_H
10#define FORWARDER_H
11
12#include "ns3/application.h"
13#include "ns3/point-to-point-net-device.h"
14
15namespace ns3
16{
17namespace lorawan
18{
19
20class LoraNetDevice;
21
22/**
23 * @ingroup lorawan
24 *
25 * This application forwards packets between NetDevices:
26 * LoraNetDevice -> PointToPointNetDevice and vice versa.
27 */
28class Forwarder : public Application
29{
30 public:
31 Forwarder(); //!< Default constructor
32 ~Forwarder() override; //!< Destructor
33
34 /**
35 * Register this type.
36 * @return The object TypeId.
37 */
38 static TypeId GetTypeId();
39
40 /**
41 * Sets the device to use to communicate with the end devices.
42 *
43 * @param loraNetDevice The LoraNetDevice on this node.
44 */
45 void SetLoraNetDevice(Ptr<LoraNetDevice> loraNetDevice);
46
47 /**
48 * Sets the P2P device to use to communicate with the network server.
49 *
50 * @param pointToPointNetDevice The P2PNetDevice on this node.
51 */
52 void SetPointToPointNetDevice(Ptr<PointToPointNetDevice> pointToPointNetDevice);
53
54 /**
55 * Receive a packet from the LoraNetDevice.
56 *
57 * @param loraNetDevice The LoraNetDevice we received the packet from.
58 * @param packet The packet we received.
59 * @param protocol The protocol number associated to this packet.
60 * @param sender The address of the sender.
61 * @return True if we can handle the packet, false otherwise.
62 */
63 bool ReceiveFromLora(Ptr<NetDevice> loraNetDevice,
64 Ptr<const Packet> packet,
65 uint16_t protocol,
66 const Address& sender);
67
68 /**
69 * Receive a packet from the PointToPointNetDevice.
70 *
71 * @copydoc ns3::NetDevice::ReceiveCallback
72 */
74 Ptr<const Packet> packet,
75 uint16_t protocol,
76 const Address& sender);
77
78 /**
79 * Start the application.
80 */
81 void StartApplication() override;
82
83 /**
84 * Stop the application.
85 */
86 void StopApplication() override;
87
88 private:
89 Ptr<LoraNetDevice> m_loraNetDevice; //!< Pointer to the node's LoraNetDevice
90
91 Ptr<PointToPointNetDevice> m_pointToPointNetDevice; //!< Pointer to the P2PNetDevice we use to
92 //!< communicate with the network server
93};
94
95} // namespace lorawan
96} // namespace ns3
97
98#endif /* FORWARDER */
a polymophic address class
Definition address.h:114
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
a unique identifier for an interface.
Definition type-id.h:50
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:89
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:91
~Forwarder() override
Destructor.
Definition forwarder.cc:37
Hold together all LoRa related objects.
Every class exported by the ns3 library is enclosed in the ns3 namespace.