OLD | NEW |
(Empty) | |
| 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 |
| 21 #ifndef FORWARDER_H |
| 22 #define FORWARDER_H |
| 23 |
| 24 #include "ns3/application.h" |
| 25 #include "ns3/lora-net-device.h" |
| 26 #include "ns3/point-to-point-net-device.h" |
| 27 #include "ns3/nstime.h" |
| 28 #include "ns3/attribute.h" |
| 29 |
| 30 namespace ns3 { |
| 31 |
| 32 /** |
| 33 * This application forwards packets between NetDevices: |
| 34 * LoraNetDevice -> PointToPointNetDevice and vice versa. |
| 35 */ |
| 36 class Forwarder : public Application |
| 37 { |
| 38 public: |
| 39 |
| 40 Forwarder (); |
| 41 ~Forwarder (); |
| 42 |
| 43 static TypeId GetTypeId (void); |
| 44 |
| 45 /** |
| 46 * Sets the device to use to communicate with the EDs. |
| 47 * |
| 48 * \param loraNetDevice The LoraNetDevice on this node. |
| 49 */ |
| 50 void SetLoraNetDevice (Ptr<LoraNetDevice> loraNetDevice); |
| 51 |
| 52 /** |
| 53 * Sets the P2P device to use to communicate with the NS. |
| 54 * |
| 55 * \param pointToPointNetDevice The P2PNetDevice on this node. |
| 56 */ |
| 57 void SetPointToPointNetDevice (Ptr<PointToPointNetDevice> pointToPointNetDevic
e); |
| 58 |
| 59 /** |
| 60 * Receive a packet from the LoraNetDevice. |
| 61 * |
| 62 * \param loraNetDevice The LoraNetDevice we received the packet from. |
| 63 * \param packet The packet we received. |
| 64 * \param protocol The protocol number associated to this packet. |
| 65 * \param sender The address of the sender. |
| 66 * \returns True if we can handle the packet, false otherwise. |
| 67 */ |
| 68 bool ReceiveFromLora (Ptr<NetDevice> loraNetDevice, Ptr<const Packet> packet, |
| 69 uint16_t protocol, const Address& sender); |
| 70 |
| 71 /** |
| 72 * Receive a packet from the PointToPointNetDevice |
| 73 */ |
| 74 bool ReceiveFromPointToPoint (Ptr<NetDevice> pointToPointNetDevice, |
| 75 Ptr<const Packet> packet, uint16_t protocol, |
| 76 const Address& sender); |
| 77 |
| 78 /** |
| 79 * Start the application |
| 80 */ |
| 81 void StartApplication (void); |
| 82 |
| 83 /** |
| 84 * Stop the application |
| 85 */ |
| 86 void StopApplication (void); |
| 87 |
| 88 private: |
| 89 Ptr<LoraNetDevice> m_loraNetDevice; //!< Pointer to the node's LoraNetDevice |
| 90 |
| 91 Ptr<PointToPointNetDevice> m_pointToPointNetDevice; //!< Pointer to the |
| 92 //!P2PNetDevice we use to |
| 93 //!communicate with the NS |
| 94 }; |
| 95 |
| 96 } //namespace ns3 |
| 97 |
| 98 #endif /* FORWARDER */ |
OLD | NEW |