A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lora-net-device.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 LORA_NET_DEVICE_H
10#define LORA_NET_DEVICE_H
11
12#include "ns3/net-device.h"
13
14namespace ns3
15{
16namespace lorawan
17{
18
19/**
20 * @defgroup lorawan LoRaWAN Models
21 *
22 * This section documents the API of the ns-3 lorawan module. For a generic functional description,
23 * please refer to the ns-3 manual.
24 */
25
26class LoraChannel;
27class LoraPhy;
28class LorawanMac;
29
30/**
31 * @ingroup lorawan
32 *
33 * Hold together all LoRa related objects.
34 *
35 * This class holds together pointers to LoraChannel, LoraPhy and LorawanMac,
36 * exposing methods through which Application instances can send packets. The
37 * Application only needs to craft its packets, the NetDevice will take care of
38 * calling the LorawanMac's Send method with the appropriate parameters.
39 */
41{
42 public:
43 /**
44 * Register this type.
45 * @return The object TypeId.
46 */
47 static TypeId GetTypeId();
48
49 LoraNetDevice(); //!< Default constructor
50 ~LoraNetDevice() override; //!< Destructor
51
52 /**
53 * Set which LorawanMac instance is linked to this device.
54 *
55 * @param mac The MAC layer to use.
56 */
57 void SetMac(Ptr<LorawanMac> mac);
58
59 /**
60 * Set which LoraPhy instance is linked to this device.
61 *
62 * @param phy The PHY layer to use.
63 */
64 void SetPhy(Ptr<LoraPhy> phy);
65
66 /**
67 * Get the LorawanMac instance that is linked to this NetDevice.
68 *
69 * @return The MAC we are currently using.
70 */
71 Ptr<LorawanMac> GetMac() const;
72
73 /**
74 * Get the LoraPhy instance that is linked to this NetDevice.
75 *
76 * @return The PHY we are currently using.
77 */
78 Ptr<LoraPhy> GetPhy() const;
79
80 /**
81 * Send a packet through the LoRaWAN stack.
82 *
83 * @param packet The packet to send.
84 */
85 void Send(Ptr<Packet> packet);
86
87 /**
88 * @copydoc ns3::NetDevice::Send
89
90 * @note This function is implemented to achieve compliance with the NetDevice
91 * interface. Note that the dest and protocolNumber args are ignored.
92 */
93 bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) override;
94
95 /**
96 * Callback the Mac layer calls whenever a packet arrives and needs to be
97 * forwarded up the stack.
98 *
99 * @param packet The packet that was received.
100 */
101 void Receive(Ptr<Packet> packet);
102
103 // From class NetDevice. Some of these have little meaning for a LoRaWAN
104 // network device (since, for instance, IP is not used in the standard)
106 Ptr<Channel> GetChannel() const override;
107 void SetNode(Ptr<Node> node) override;
108 Ptr<Node> GetNode() const override;
109
110 void SetIfIndex(const uint32_t index) override;
111 uint32_t GetIfIndex() const override;
112 void SetAddress(Address address) override;
113 Address GetAddress() const override;
114 bool SetMtu(const uint16_t mtu) override;
115 uint16_t GetMtu() const override;
116 bool IsLinkUp() const override;
117 void AddLinkChangeCallback(Callback<void> callback) override;
118 bool IsBroadcast() const override;
119 Address GetBroadcast() const override;
120 bool IsMulticast() const override;
121 Address GetMulticast(Ipv4Address multicastGroup) const override;
122 Address GetMulticast(Ipv6Address addr) const override;
123 bool IsBridge() const override;
124 bool IsPointToPoint() const override;
125 bool SendFrom(Ptr<Packet> packet,
126 const Address& source,
127 const Address& dest,
128 uint16_t protocolNumber) override;
129 bool NeedsArp() const override;
131 bool SupportsSendFrom() const override;
132
133 protected:
134 /**
135 * Receive a packet from the lower layer and pass the
136 * packet up the stack.
137 *
138 * @param packet The packet we need to forward.
139 * @param from The from address.
140 * @param to The to address.
141 *
142 * @todo Not implemented, this is a placeholder for future implementation.
143 */
145
146 private:
147 /**
148 * Return the LoraChannel this device is connected to.
149 *
150 * @return A pointer to the LoraChannel object.
151 */
153
154 /**
155 * Complete the configuration of this LoRa device by connecting all lower
156 * components (PHY, MAC, Channel) together.
157 */
158 void CompleteConfig();
159
160 // Member variables
161 Ptr<Node> m_node; //!< The Node this NetDevice is connected to.
162 Ptr<LoraPhy> m_phy; //!< The LoraPhy this NetDevice is connected to.
163 Ptr<LorawanMac> m_mac; //!< The LorawanMac this NetDevice is connected to.
164 bool m_configComplete; //!< Whether the configuration was already completed.
165
166 /**
167 * Upper layer callback used for notification of new data packet arrivals.
168 */
170};
171
172} // namespace lorawan
173} // namespace ns3
174
175#endif /* LORA_NET_DEVICE_H */
a polymophic address class
Definition address.h:114
Callback template class.
Definition callback.h:428
Ipv4 addresses are stored in host order in this class.
Describes an IPv6 address.
an EUI-48 address
Network layer to device interface.
Definition net-device.h:87
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address &, const Address &, PacketType > PromiscReceiveCallback
Definition net-device.h:341
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address & > ReceiveCallback
Definition net-device.h:311
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
a unique identifier for an interface.
Definition type-id.h:50
The class that delivers packets among PHY layers.
uint16_t GetMtu() const override
void SetMac(Ptr< LorawanMac > mac)
Set which LorawanMac instance is linked to this device.
Address GetMulticast(Ipv4Address multicastGroup) const override
Make and return a MAC multicast address using the provided multicast group.
bool NeedsArp() const override
Ptr< Node > GetNode() const override
bool IsPointToPoint() const override
Return true if the net device is on a point-to-point link.
bool IsMulticast() const override
void SetReceiveCallback(NetDevice::ReceiveCallback cb) override
bool IsBridge() const override
Return true if the net device is acting as a bridge.
Ptr< LoraPhy > GetPhy() const
Get the LoraPhy instance that is linked to this NetDevice.
~LoraNetDevice() override
Destructor.
Ptr< LoraChannel > DoGetChannel() const
Return the LoraChannel this device is connected to.
Ptr< LorawanMac > m_mac
The LorawanMac this NetDevice is connected to.
bool SupportsSendFrom() const override
LoraNetDevice()
Default constructor.
bool IsLinkUp() const override
Ptr< Channel > GetChannel() const override
void SetPromiscReceiveCallback(PromiscReceiveCallback cb) override
void AddLinkChangeCallback(Callback< void > callback) override
void SetAddress(Address address) override
Set the address of this interface.
static TypeId GetTypeId()
Register this type.
Address GetBroadcast() const override
Ptr< LorawanMac > GetMac() const
Get the LorawanMac instance that is linked to this NetDevice.
void ForwardUp(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Receive a packet from the lower layer and pass the packet up the stack.
Ptr< LoraPhy > m_phy
The LoraPhy this NetDevice is connected to.
Ptr< Node > m_node
The Node this NetDevice is connected to.
bool IsBroadcast() const override
void SetIfIndex(const uint32_t index) override
Address GetAddress() const override
bool SetMtu(const uint16_t mtu) override
void Receive(Ptr< Packet > packet)
Callback the Mac layer calls whenever a packet arrives and needs to be forwarded up the stack.
void SetNode(Ptr< Node > node) override
NetDevice::ReceiveCallback m_receiveCallback
Upper layer callback used for notification of new data packet arrivals.
bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override
bool m_configComplete
Whether the configuration was already completed.
void CompleteConfig()
Complete the configuration of this LoRa device by connecting all lower components (PHY,...
void SetPhy(Ptr< LoraPhy > phy)
Set which LoraPhy instance is linked to this device.
uint32_t GetIfIndex() const override
void Send(Ptr< Packet > packet)
Send a packet through the LoRaWAN stack.
Base class for PHY layers implementing the LoRa modulation scheme.
Definition lora-phy.h:81
Class representing the LoRaWAN MAC layer.
Definition lorawan-mac.h:36
Every class exported by the ns3 library is enclosed in the ns3 namespace.