OLD | NEW |
(Empty) | |
| 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2010, Jens Mittag, Karlsruhe Institute of Technology |
| 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 * Authors: Jens Mittag <jens.mittag@kit.edu> |
| 19 */ |
| 20 |
| 21 #ifndef PHYSIM_WIFI_STATE_CHECKER_H_ |
| 22 #define PHYSIM_WIFI_STATE_CHECKER_H_ |
| 23 |
| 24 #include <set> |
| 25 #include <map> |
| 26 #include "ns3/nstime.h" |
| 27 #include "ns3/object.h" |
| 28 |
| 29 using namespace ns3; |
| 30 |
| 31 class PhySimWifiStateChecker : public Object |
| 32 { |
| 33 |
| 34 public: |
| 35 class Transition : public Object |
| 36 { |
| 37 public: |
| 38 Transition (uint32_t from, uint32_t to); |
| 39 virtual ~Transition (); |
| 40 uint32_t GetFrom (); |
| 41 uint32_t GetTo (); |
| 42 private: |
| 43 uint32_t m_from; |
| 44 uint32_t m_to; |
| 45 }; |
| 46 |
| 47 class ProhibitedPeriod : public Object |
| 48 { |
| 49 public: |
| 50 ProhibitedPeriod (Time start, Time end, uint32_t state); |
| 51 virtual ~ProhibitedPeriod (); |
| 52 Time GetStart (); |
| 53 Time GetEnd (); |
| 54 uint32_t GetState (); |
| 55 private: |
| 56 Time m_start; |
| 57 Time m_end; |
| 58 uint32_t m_state; |
| 59 }; |
| 60 |
| 61 class PeriodSet : public Object |
| 62 { |
| 63 public: |
| 64 void Add (Ptr<PhySimWifiStateChecker::ProhibitedPeriod> p); |
| 65 uint32_t Size () const; |
| 66 std::set<Ptr<PhySimWifiStateChecker::ProhibitedPeriod> >::iterator Begin (); |
| 67 std::set<Ptr<PhySimWifiStateChecker::ProhibitedPeriod> >::iterator End (); |
| 68 |
| 69 private: |
| 70 std::set<Ptr<PhySimWifiStateChecker::ProhibitedPeriod> > m_periods; |
| 71 }; |
| 72 |
| 73 PhySimWifiStateChecker (); |
| 74 virtual ~PhySimWifiStateChecker (); |
| 75 |
| 76 /** |
| 77 * Register a node for which the physical layer states and transitions will be
checked |
| 78 * \param node The ID of the node to be included in the checks |
| 79 */ |
| 80 void RegisterNodeId (uint32_t node); |
| 81 |
| 82 /** |
| 83 * Register a state that is allowed to occur / take place in the physical laye
r |
| 84 * \param state The integer value of the physical layer state |
| 85 * \param label The human-readable label for this state |
| 86 * \param default A flag that indicates whether this is the default state for
all nodes in the beginning |
| 87 */ |
| 88 void RegisterState (uint32_t state, std::string label = "", bool isDefault = f
alse); |
| 89 /** |
| 90 * Register a possible and valid state transition |
| 91 * \param from The source physical layer state of the transition |
| 92 * \param to The target physical layer state of the transition |
| 93 */ |
| 94 void RegisterStateTransition (uint32_t from, uint32_t to); |
| 95 /** |
| 96 * Registers the prohibition of specific states during a given time window |
| 97 * \param node The identifier of the node at which this event shall happen |
| 98 * \param state The state that shall start at this node and the given time sta
mp |
| 99 * \param start The starting time of the time window during which the above st
ate is prohibited |
| 100 * \param stop The end time of the time window during which the above state i
s prohibited |
| 101 */ |
| 102 void RegisterProhibitedStatePeriod (uint32_t node, uint32_t state, Time start,
Time end); |
| 103 |
| 104 void Reset (); |
| 105 |
| 106 /** |
| 107 * Notification about a specific state transition that happened during the sim
ulation. This function then checks whether |
| 108 * the new state is valid, by checking whether a transition from the current s
tate to the new state exists. Further, it will |
| 109 * record the expected duration of the new state, in order to make sure that t
he new state lasts at least as long as expected. |
| 110 * \param node The identifier of the node at which a state transit
ion was monitored |
| 111 * \param newState The identifier of the new physical layer state |
| 112 * \param expectedDuration The expected duration of the new state |
| 113 * \return Feedback whether the transition was allowed (true)
or not (false). |
| 114 */ |
| 115 bool PerformStateTransition (uint32_t node, uint32_t newState); |
| 116 |
| 117 bool CheckForProhibitions (uint32_t node, uint32_t oldState, uint32_t newState
); |
| 118 |
| 119 private: |
| 120 std::string GetLabel (uint32_t state); |
| 121 |
| 122 std::set<uint32_t> m_nodes; // The node IDs for whic
h to check |
| 123 std::map<uint32_t, uint32_t> m_nodeStates; // The current PhySimWif
i PHY state of all nodes |
| 124 std::set<Ptr<Transition> > m_transitions; // The registered transi
tions |
| 125 std::map<uint32_t, Ptr<PeriodSet> > m_prohibitions; // The per node list of
prohibited state periods |
| 126 |
| 127 std::set<uint32_t> m_states; // The list of allowed PHY state
s |
| 128 std::map<uint32_t, std::string> m_labels; // The human-readable labels for
each state |
| 129 |
| 130 uint32_t m_defaultState; |
| 131 |
| 132 }; |
| 133 |
| 134 #endif /* PHYSIM_WIFI_STATE_CHECKER_H_ */ |
OLD | NEW |