Index: src/pgbr/model/load-sensing/point-to-point-load-sensor.h |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/src/pgbr/model/load-sensing/point-to-point-load-sensor.h |
@@ -0,0 +1,151 @@ |
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
+/* |
+ * Copyright (c) Waterford Institute of Technology, 2013, Julien Mineraud, BioFINT. |
+ * |
+ * This program is free software; you can redistribute it and/or modify |
+ * it under the terms of the GNU General Public License version 2 as |
+ * published by the Free Software Foundation; |
+ * |
+ * This program is distributed in the hope that it will be useful, |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+ * GNU General Public License for more details. |
+ * |
+ * You should have received a copy of the GNU General Public License |
+ * along with this program; if not, write to the Free Software |
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+ * |
+ * Author: Julien Mineraud <julien.mineraud@gmail.com> |
+ * |
+ * Acknowledgements: |
+ * This work has received support from Science Foundation Ireland via the |
+ * "A Biologically inspired framework supporting network management for |
+ * the Future Internet" starting investigator award (grant no. 09/SIRG/I1643). |
+ */ |
+ |
+#ifndef POINT_TO_POINT_LOAD_SENSOR_H_ |
+#define POINT_TO_POINT_LOAD_SENSOR_H_ |
+ |
+#include "ns3/timer.h" |
+#include "ns3/net-device.h" |
+#include "ns3/data-rate.h" |
+#include "net-device-load-sensor.h" |
+ |
+/*! |
+ * \namespace ns3::pgbr |
+ * Namespace regrouping all objects and functions to run PGBR. |
+ */ |
+namespace ns3 { |
+namespace pgbr { |
+ |
+/*! |
+ * \class PointToPointLoadSensor |
+ * This class is used to monitor the load on ns3::PointToPointNetDevice |
+ */ |
+class PointToPointLoadSensor : public NetDeviceLoadSensor |
+{ |
+public: |
+ /*! |
+ * \brief Static function that is required for each ns3::Object. |
+ * |
+ * \fn static TypeId GetTypeId (void) |
+ * \sa ns3::Object::GetTypeId () |
+ * \return the TypeId corresponding to the monitor |
+ */ |
+ static TypeId GetTypeId (void); |
+ |
+ /*! |
+ * The constructor |
+ */ |
+ PointToPointLoadSensor (); |
+ |
+ /*! |
+ * The destructor |
+ */ |
+ virtual ~PointToPointLoadSensor (); |
+ |
+ /*! |
+ * \brief Function is called when a packet has been monitored |
+ * |
+ * \fn void ReceivePacket (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet, uint16_t protocol, Address const &src, Address const &dst, NetDevice::PacketType packetType) |
+ * \param[in] incomingPort The netdevice on which the packet has been received |
+ * \param[in] packet The packet |
+ * \param[in] protocol the transport protocol used |
+ * \param[in] src The source address |
+ * \param[in] dst The destination address |
+ * \param[in] packetType The type of packet |
+ */ |
+ void ReceivePacket (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet, uint16_t protocol, |
+ Address const &src, Address const &dst, NetDevice::PacketType packetType); |
+ |
+ /*! |
+ * \brief Reset all statistics |
+ * |
+ * \fn void Reset (void) |
+ */ |
+ void Reset (void); |
+ |
+ /*! |
+ * \brief Get the current netDevice load |
+ * |
+ * \fn double_t GetNetworkDeviceLoad (void) |
+ * \return the current load |
+ */ |
+ double_t GetNetworkDeviceLoad (void); |
+ |
+ /*! |
+ * \brief Get the current netDevice traffic rate in bps |
+ * |
+ * \fn uint64_t GetNetworkDeviceTraffic (void) |
+ * \return the current traffic rate in bps |
+ */ |
+ uint64_t GetNetworkDeviceTraffic (void); |
+ |
+ /*! |
+ * \brief Enable manual load ( !!! used for hacks !!! ) |
+ * |
+ * \fn void EnableManualLoad (bool enableManualLoad) |
+ * \param[in] enableManualLoad flag the use manual load or not |
+ */ |
+ void EnableManualLoad (bool enableManualLoad); |
+ |
+ /*! |
+ * \brief Set manual load ( !!! used for hacks !!! ) |
+ * |
+ * \fn void SetManualLoad (double_t load) |
+ * \param[in] load the load |
+ */ |
+ void SetManualLoad (double_t load); |
+ |
+ /*! |
+ * \brief Set the net device to be monitored |
+ * |
+ * \fn void SetNetDevice (Ptr<NetDevice> netDevice) |
+ * \param[in] netDevice the net device |
+ */ |
+ void SetNetDevice (Ptr<NetDevice> netDevice); |
+ |
+private: |
+ |
+ /*! |
+ * \brief The traffic is monitored periodically on the interface. This function is called when the timer runs out. |
+ * |
+ * \fn void CheckWindowTimerExpired (void) |
+ */ |
+ void CheckWindowTimerExpired (void); |
+ |
+ double_t m_numBits; /*!< The number of bits that have been received on the interface */ |
+ double_t m_netDeviceLoad; /*!< The current load of the interface */ |
+ uint64_t m_traffic; /*!< The current bit rate of the interface */ |
+ double_t m_smoothExponentialFactor; /*!< The smooth exponential factor used to smooth load interpretation (useful if window time is very short) */ |
+ Time m_windowTime; /*!< The window time */ |
+ Timer m_checkWindowTimer; /*!< The timer to upload new loads information */ |
+ bool m_enableManualLoad; /*!< The flag to hack a manual load */ |
+ Ptr<NetDevice> m_netDevice; /*!< The net device that has its load monitored */ |
+ DataRate m_dataRate; /*!< The datarate of the ns3::PointToPointNetDevice */ |
+ |
+}; |
+ |
+}} // namespace pgbr, ns3 |
+ |
+#endif /* POINT_TO_POINT_LOAD_SENSOR_H_ */ |