Loading...
Searching...
No Matches
lora-forwarder.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2017 University of Padova
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Davide Magrin <magrinda@dei.unipd.it>
19 *
20 * Modified by: Bastien Tauran <bastien.tauran@viveris.fr>
21 */
22
23#include "lora-forwarder.h"
24
25#include "lora-beam-tag.h"
26
27#include "ns3/log.h"
28
29NS_LOG_COMPONENT_DEFINE("LoraForwarder");
30
31namespace ns3
32{
33
34NS_OBJECT_ENSURE_REGISTERED(LoraForwarder);
35
36TypeId
38{
39 static TypeId tid =
40 TypeId("ns3::LoraForwarder").SetParent<Application>().AddConstructor<LoraForwarder>();
41 return tid;
42}
43
45{
46 NS_LOG_FUNCTION_NOARGS();
47}
48
50{
51 NS_LOG_FUNCTION_NOARGS();
52}
53
54void
55LoraForwarder::SetPointToPointNetDevice(Ptr<PointToPointNetDevice> pointToPointNetDevice)
56{
57 NS_LOG_FUNCTION(this << pointToPointNetDevice);
58
59 m_pointToPointNetDevice = pointToPointNetDevice;
60}
61
62void
63LoraForwarder::SetLoraNetDevice(uint8_t beamId, Ptr<SatLorawanNetDevice> loraNetDevice)
64{
65 NS_LOG_FUNCTION(this << beamId << loraNetDevice);
66
67 m_satLorawanNetDevices[beamId] = loraNetDevice;
68}
69
70bool
71LoraForwarder::ReceiveFromLora(Ptr<SatLorawanNetDevice> loraNetDevice,
72 Ptr<const Packet> packet,
73 uint16_t protocol,
74 const Address& sender)
75{
76 NS_LOG_FUNCTION(this << packet << protocol << sender);
77
78 Ptr<Packet> packetCopy = packet->Copy();
79
80 m_pointToPointNetDevice->Send(packetCopy, m_pointToPointNetDevice->GetBroadcast(), protocol);
81
82 return true;
83}
84
85bool
86LoraForwarder::ReceiveFromPointToPoint(Ptr<NetDevice> pointToPointNetDevice,
87 Ptr<const Packet> packet,
88 uint16_t protocol,
89 const Address& sender)
90{
91 NS_LOG_FUNCTION(this << packet << protocol << sender);
92
93 Ptr<Packet> packetCopy = packet->Copy();
94
95 LoraBeamTag tag;
96 packetCopy->RemovePacketTag(tag);
97 uint8_t beamId = tag.GetBeamId();
98
99 // TODO not sure address is correct...
100 m_satLorawanNetDevices[beamId]->Send(packetCopy, sender, protocol);
101
102 return true;
103}
104
105void
107{
108 NS_LOG_FUNCTION(this);
109
110 // TODO Make sure we are connected to both needed devices
111}
112
113void
115{
116 NS_LOG_FUNCTION_NOARGS();
117
118 // TODO Get rid of callbacks
119}
120
121} // namespace ns3
Tag used to save various data about a packet, like its Spreading Factor and data about interference.
uint8_t GetBeamId() const
Read which beam ID this packet was transmitted with.
This application forwards packets between NetDevices: SatLorawanNetDevice -> PointToPointNetDevice an...
Ptr< PointToPointNetDevice > m_pointToPointNetDevice
Pointer to the P2PNetDevice we use to.
bool ReceiveFromLora(Ptr< SatLorawanNetDevice > loraNetDevice, Ptr< const Packet > packet, uint16_t protocol, const Address &sender)
Receive a packet from the LoraNetDevice.
std::map< uint8_t, Ptr< SatLorawanNetDevice > > m_satLorawanNetDevices
Map between beam ID and pointer to the node's SatLorawanNetDevice.
static TypeId GetTypeId(void)
void StartApplication(void)
Start the application.
void StopApplication(void)
Stop the application.
void SetLoraNetDevice(uint8_t beamId, Ptr< SatLorawanNetDevice > loraNetDevice)
Sets the device to use to communicate with the EDs.
bool ReceiveFromPointToPoint(Ptr< NetDevice > pointToPointNetDevice, Ptr< const Packet > packet, uint16_t protocol, const Address &sender)
Receive a packet from the PointToPointNetDevice.
void SetPointToPointNetDevice(Ptr< PointToPointNetDevice > pointToPointNetDevice)
Sets the P2P device to use to communicate with the NS.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.