50 : TclClass(
"Module/UW/CSMA_ALOHA/TRIGGER/SINK")
70 module->stateDisableRx();
82 bind(
"debug_", (
double *) &debug_);
94 Tcl &tcl = Tcl::instance();
96 if (strcasecmp(argv[1],
"sinkRun") == 0) {
99 }
else if (strcasecmp(argv[1],
"getNTriggerSent") == 0) {
104 return MMac::command(argc, argv);
112 return Module::crLayCommand(m);
127 cout << NOW <<
"UwCsmaAloha_Trigger_SINK(" << addr
128 <<
") ----> Enabling Receive() timer_duration = "
139 cout << NOW <<
"UwCsmaAloha_Trigger_SINK(" << addr
140 <<
")----> Timer fired ----> Disabling Receving Data" << endl;
148 hdr_cmn *ch = hdr_cmn::access(p);
149 hdr_mac *mach = HDR_MAC(p);
152 mach->macSA() = addr;
153 mach->macDA() = dest_addr;
159 MMac::Mac2PhyStartTx(p);
166 cout << NOW <<
" UwCsmaAloha_Trigger_SINK(" << addr
167 <<
")::Phy2MacEndTx() end tx TRIGGER packet" << endl;
178 cout << NOW <<
" UwCsmaAloha_Trigger_SINK(" << addr
179 <<
")::Phy2MacStartRx() rx Packet " << endl;
182 cout << NOW <<
" UwCsmaAloha_Trigger_SINK(" << addr
183 <<
")::Phy2MacStartRx() Receiving disabled" << endl;
191 hdr_cmn *ch = HDR_CMN(p);
192 packet_t rx_pkt_type = ch->ptype();
193 hdr_mac *mach = HDR_MAC(p);
194 hdr_MPhy *ph = HDR_MPHY(p);
196 int dest_mac = mach->macDA();
200 cout << NOW <<
" UwCsmaAloha_Trigger_SINK(" << addr
201 <<
")::Phy2MacEndRx() dropping corrupted pkt " << endl;
207 if (dest_mac == addr || dest_mac == (
int) MAC_BROADCAST) {
213 cout <<
" UwCsmaAloha_Trigger_SINK(" << addr
214 <<
"):: Received a packet of wrong type " << endl;
224 cout << NOW <<
" UwCsmaAloha_Trigger_SINK(" << addr
225 <<
"):: Phy2MacEndRx ---> Not enabled to receive data "
236 cout << NOW <<
" UwCsmaAloha_Trigger_SINK(" << addr
237 <<
")::stateRxData() " << endl;
246 cout << NOW <<
" UwCsmaAloha_Trigger_SINK(" << addr
247 <<
")::stateRxPacketNotForMe() pkt for another address. Dropping "
261 std::cout << NOW <<
" UwCsmaAloha_Trigger_SINK(" << addr
262 <<
")::stateIdle() --> TRANSMITTING TRIGGER" << endl;
270 cout << NOW <<
"UwCsmaAloha_Trigger_SINK(" << addr
271 <<
")--->stateTxTRIGGER()" << endl;
273 Packet *p = Packet::alloc();
284 cout << NOW <<
"UwCsmaAloha_Trigger_SINK(" << addr
285 <<
")---> Transmitting TRIGGER" << endl;
290 cout << NOW <<
"UwCsmaAloha_Trigger_SINK(" << addr
291 <<
")----> Not transmitting TRIGGER, receiving active" << endl;
299 std::string response;
300 std::cout <<
"Press Enter to continue";
301 std::getline(std::cin, response);
Class that represents the binding with the tcl configuration script.
UwCsmaAloha_Trigger_SINKModuleClass()
Constructor of the class.
TclObject * create(int, const char *const *)
Creates the TCL object needed for the tcl language interpretation.
UwCsmaAloha_Trigger_SINK *UW_CS_ALOHA_TRIG_SINK_TIMER_STATUS timer_status
< Pointer to an object of type CsmaAloha
virtual void expire(Event *e)
Method called when the timer expire.
Class that describes a UwCsmaAloha_Trigger_SINK module.
virtual void Phy2MacEndTx(const Packet *p)
Method called when the PHY layers finishes to transmit packet.
UW_CS_ALOHA_TRIG_SINK_STATUS curr_state
Current state of the protocol.
void refreshReason(UW_CS_ALOHA_TRIG_SINK_REASON_STATUS reason)
Refresh the reason for the change of state.
virtual void recvFromUpperLayers(Packet *p)
Receives the packet from the upper layer (e.g.
int TRIGGER_size
Size of the TRIGGER packet.
virtual void Phy2MacStartRx(const Packet *p)
Method called when the PHY layer begins to receive a packet.
bool receiving_state_active
True if the sink is allowed to receive data packet.
@ UW_CS_ALOHA_TRIG_SINK_REASON_PKT_NOT_FOR_ME
@ UW_CS_ALOHA_TRIG_SINK_REASON_TX_TRIGGER
@ UW_CS_ALOHA_TRIG_SINK_REASON_DATA_RX
@ UW_CS_ALOHA_TRIG_SINK_REASON_START_RX
@ UW_CS_ALOHA_TRIG_SINK_REASON_PKT_ERROR
@ UW_CS_ALOHA_TRIG_SINK_REASON_NOT_SET
void incrTRIGGERPacketTx()
Increment the number of TRIGGER packets transmitted.
int getTriggerMsgSent()
Return the number of TRIGGER packets sent over the simulation.
ReceiveTimer receive_timer
timer of receive state
double tx_timer_duration
Duration of the timer in which one node is allowed to transmit.
@ UW_CS_ALOHA_TRIG_SINK_STATE_DISABLE_RX
@ UW_CS_ALOHA_TRIG_SINK_STATE_ENABLE_RX
@ UW_CS_ALOHA_TRIG_SINK_STATE_TX_TRIGGER
@ UW_CS_ALOHA_TRIG_SINK_STATE_IDLE
@ UW_CS_ALOHA_TRIG_SINK_STATE_DATA_RX
virtual void stateRxData(Packet *p)
The sink receives a DATA packet from a node.
virtual void initPkt(Packet *p, int dest_addr=0)
Init the headers of the packet in transmission.
virtual void stateRxPacketNotForMe(Packet *p)
The destination address of the packet is not equal to the sink's address.
virtual void txTRIGGER(Packet *p)
Transmit the TRIGGER packet.
@ UW_CS_ALOHA_TRIG_SINK_EXPIRED
virtual void waitForUser()
Used for debug purposes.
virtual void stateTxTRIGGER()
The sink transmit the TRIGGER packet to begin the neighbour discovery phase.
virtual void stateIdle()
State IDLE of the protocol.
int trigger_pkts_tx
Number of TRIGGER packet received.
UW_CS_ALOHA_TRIG_SINK_REASON_STATUS last_reason
Last reason of the state change of the protocol.
virtual ~UwCsmaAloha_Trigger_SINK()
Destructor of the UwCsmaAloha_Trigger_SINK class.
virtual int crLayCommand(ClMessage *m)
Cross-Layer messages interpreter.
void refreshState(UW_CS_ALOHA_TRIG_SINK_STATUS state)
Refresh the state of the protocol.
virtual void Mac2PhyStartTx(Packet *p)
Pass the packet to the PHY layer.
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
virtual void stateDisableRx()
The sink is not allowed to receive the packet from a certain node anymore.
virtual void Phy2MacEndRx(Packet *p)
Method called when the PHY layer finishes to receive a packet.
virtual void stateEnableRx()
State in which the sink is enabled to receive packets.
UwCsmaAloha_Trigger_SINK()
Constructor of the UwCsmaAloha_Trigger_SINK class.
UW_CS_ALOHA_TRIG_SINK_STATUS prev_state
Previous state of the protocol.
UwCsmaAloha_Trigger_SINKModuleClass class_module_uw_csma_aloha_trigger
Provides the declaration of UwCsmaAloha_Trigger_SINK class.
#define UW_CS_ALOHA_TRIG_SINK_DROP_REASON_ERROR
Packet corrupted.
#define UW_CS_ALOHA_TRIG_SINK_DROP_REASON_UNKNOWN_TYPE
The type of the packet is unknown.
#define UW_CS_ALOHA_TRIG_SINK_DROP_REASON_RECEIVING_NOT_ENABLED
The sink is not enabled to receive data.
#define UW_CS_ALOHA_TRIG_SINK_DROP_REASON_WRONG_RECEIVER
The packet is for another node.