40#include <mphy_pktheader.h>
57 TclObject*
create(
int,
const char*
const*)
69 power_stat_node_(MAC_BROADCAST),
71 signaling_period_(10),
73 signaling_timer_(this)
82 Tcl& tcl = Tcl::instance();
85 if(strcasecmp(argv[1],
"signalingON") == 0)
90 else if(strcasecmp(argv[1],
"signalingOFF") == 0)
95 else if(strcasecmp(argv[1],
"getSignalsSent") == 0)
103 if(strcasecmp(argv[1],
"setAlpha") == 0)
108 else if(strcasecmp(argv[1],
"setManualLowerlId") == 0)
120 assert(module->signaling_active_);
123 std::cout << NOW <<
" expired! " << std::endl;
130 hdr_cmn *ch = HDR_CMN(p);
131 if (ch->direction() == hdr_cmn::UP)
169 std::cout << NOW <<
" UwMultiStackControllerPhyMaster::resetCheckAndSignal " << std::endl;
179 ClMsgPhy2MacAddr msg;
181 mac_addr = msg.getAddr();
185 double upper_threshold;
186 double lower_threshold;
199 std::cout << NOW <<
" ControllerPhyMaster("<< mac_addr
201 <<
" best layer id = " <<
lower_id_active_ <<
" upper_threshold = " << upper_threshold
202 <<
" lower_threshold = " << lower_threshold << std::endl;
215 int my_mac_addr = -1;
216 ClMsgPhy2MacAddr msg;
218 my_mac_addr = msg.getAddr();
220 Packet *p = Packet::alloc();
221 hdr_cmn* ch = hdr_cmn::access(p);
224 hdr_mac* mach = HDR_MAC(p);
227 mach->macSA() = my_mac_addr;
230 std::cout << NOW <<
" ControllerPhyMaster::signalsBestPhy()" << std::endl;
239 if (m->type() == CLMSG_PHY2MAC_ENDTX)
241 hdr_cmn* ch = hdr_cmn::access(
static_cast<ClMsgPhy2MacEndTx *
>(m)->pkt);
245 else if (m->type() == CLMSG_PHY2MAC_STARTRX)
247 hdr_cmn* ch = hdr_cmn::access(
static_cast<ClMsgPhy2MacStartRx *
>(m)->pkt);
257 ClMsgPhy2MacAddr msg;
259 mac_addr = msg.getAddr();
261 hdr_mac* mach = HDR_MAC(p);
262 hdr_MPhy* ph = HDR_MPHY(p);
278 std::cout << NOW <<
" ControllerPhyMaster("<< mac_addr <<
279 ")::updateMasterStatistics(Packet *p, int idSrc), Pr = " << ph->Pr <<
" idSrc = " << idSrc
280 <<
" lower_id_active_ = " <<
lower_id_active_ <<
" power_statistics_ = " << power_statistics_to_print << std::endl;
287 std::cout << NOW <<
" ControllerPhyMaster("<< mac_addr <<
288 ")::updateMasterStatistics(Packet *p, int idSrc), Pr = " << ph->Pr <<
" idSrc = " << idSrc
289 <<
" lower_id_active_ = " <<
lower_id_active_ <<
" power_statistics_ = " << power_statistics_to_print << std::endl;
Class that represents the binding with the tcl configuration script.
TclObject * create(int, const char *const *)
Creates the TCL object needed for the tcl language interpretation.
UwMultiStackControllerPhyMasterClass()
Constructor of the class.
virtual void expire(Event *e)
Class used to represents the UwMultiStackControllerPhyMaster layer of a node.
int getLongerRangeLayer(int layer_id)
Return the previous layer in order which can achieve longer range with lower bitrete.
int getShorterRangeLayer(int layer_id)
Return the next layer in order which can achieve shorter range with higer bitrete.
virtual void resetCheckAndSignal()
If signaling is active and signaling timer expires, check the average power thresholds at each packet...
double power_statistics_
ID of the last PHY layer used.
virtual int checkBestLayer()
Check the average power thresholds.
virtual int getBestLayer(Packet *p)
Return the best layer to forward the packet when the system works in AUTOMATIC_MODE.
UwMultiStackSignalingTimer signaling_timer_
Number of signaling packets sent.
double alpha_
Address of the node which the master is collecting the average power.
int power_stat_node_
Average received power from the closest node according to the IIR filter.
virtual void checkAndSignal()
If signaling is active, check the average power thresholds at each packet received.
int last_layer_used_
If true master is in signaling mode, otherwise not.
virtual void signalsBestPhy()
Signals the best phy.
UwMultiStackControllerPhyMaster()
Constructor of UwMultiPhy class.
virtual int command(int, const char *const *)
TCL command interpreter.
int signaling_sent_
Period to check the best layer if no interactions occurs.
virtual void updateMasterStatistics(Packet *p, int idSrc)
It implements the slave choice rule to choose the lower layer when the system works in AUTOMATIC_MODE...
int recvSyncClMsg(ClMessage *m)
Cross-Layer messages synchronous interpreter.
virtual void recv(Packet *p, int idSrc)
It manages each packet reception, either from the upper and the lower layer.
virtual void recv(Packet *p, int idSrc)
It manages each packet reception, either from the upper and the lower layer.
virtual int recvSyncClMsg(ClMessage *m)
Cross-Layer messages synchronous interpreter.
virtual int command(int, const char *const *)
TCL command interpreter.
int debug_
Flag to activate debug verbosity.
@ UW_AUTOMATIC_SWITCH
State to switch-mode automatically.
int lower_id_active_
<Current switch mode (either AUTOMATIC or MANUAL).
virtual bool getThreshold(int i, int j, double &thres_ij)
get the threshold value for the transition from layer i to layer j, checking first whether the layers...
packet_t PT_MULTI_ST_SIGNALING
UwMultiStackControllerPhyMasterClass class_uwmulti_stack_controller_phy_master
Definition of UwMultiStackControllerPhyMaster class. This controller can switch from TWO layers thank...