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