45 {JammerStatus::IDLE,
"Idle State"},
46 {JammerStatus::BUSY,
"PHY is transmitting"}};
58 : TclClass(
"Module/UW/JAMMER")
94 Tcl &tcl = Tcl::instance();
96 if (strcasecmp(argv[1],
"getDataQueueSize") == 0) {
97 tcl.resultf(
"%d",
Q_data.size());
100 }
else if (strcasecmp(argv[1],
"getJamSent") == 0) {
104 }
else if (strcasecmp(argv[1],
"getJamDiscarded") == 0) {
108 }
else if (strcasecmp(argv[1],
"getDataDiscarded") == 0) {
114 }
else if (argc == 3) {
115 if (strcasecmp(argv[1],
"setMacAddr") == 0) {
116 const char *str = argv[2];
118 int mac_addr = std::strtol(str, &end_ptr, 10);
120 if (str != end_ptr) {
130 return MMac::command(argc, argv);
138 return MMac::crLayCommand(m);
147 std::cout << NOW <<
"Uwjammer(" << addr <<
")::RECV_FROM_U_LAYERS_"
157 std::cout << NOW <<
"Uwjammer(" << addr <<
")::DROP_FULL_QUEUE"
182 mach->macSA() = addr;
193 std::cout << NOW <<
"Uwjammer(" << addr <<
")::BUSY_STATE" << std::endl;
197 MMac::Mac2PhyStartTx(p);
203 MMac::Phy2MacEndTx(p);
206 std::cout << NOW <<
"Uwjammer(" << addr
207 <<
")::JAM_TRANSMITTED_AND_IDLE_STATE" << std::endl;
216 if ((
int)
Q_data.size() > 0)
224 std::cout << NOW <<
"Uwjammer(" << addr
225 <<
")::DROP_DATA_PACKET_RECEIVED" << std::endl;
Class that represents the binding with the tcl configuration script.
UwjammerModule_Class()
Constructor of the class.
TclObject * create(int, const char *const *)
Creates the TCL object needed for the tcl language interpretation.
Class that describes a Uwjammer module.
int getJamSent() const
Returns the number of packets sent during the simulation.
int getJamDiscarded() const
Returns the number of packets discarded during the simulation because the buffer is full.
size_t n_data_discarded
Number of packets received and discarded.
JammerStatus curr_state
Current state of the protocol.
virtual void txJam()
Transmits the jam packet (calling Mac2PhyStartTx) and increment the counter of transmitted jam packet...
size_t n_jam_sent
Number of packets sent.
int buffer_data_pkts
Size of the buffer in number of packets.
std::queue< Packet * > Q_data
Queue of DATA in number of packets.
int getDataDiscarded() const
Returns the number of packets received and discarded during the simulation.
virtual void Phy2MacEndRx(Packet *p) override
Method called when the Phy Layer finish to receive a Packet.
virtual int crLayCommand(ClMessage *m) override
Cross-Layer messages interpreter.
uint node_id
Unique Node ID.
virtual void stateIdle()
IDLE state, check if there is at least one more packet to transmit.
virtual int command(int argc, const char *const *argv) override
TCL command interpreter.
static constexpr const int MAX_BUFFER_SIZE
Maximum size of the queue in number of packets.
size_t n_jam_discarded
Number of packets discarded because the buffer is full.
virtual void recvFromUpperLayers(Packet *p) override
Receives the packet from the upper layer (e.g.
Packet * curr_data_pkt
Pointer to the current DATA packet.
static const std::map< JammerStatus, std::string > status_info
Textual info of the state.
virtual void Mac2PhyStartTx(Packet *p)
Pass the packet to the PHY layer.
Uwjammer()
Constructor of the class.
virtual void Phy2MacEndTx(const Packet *p) override
Method called when the PHY layer finish to transmit the packet.
virtual void refreshState(JammerStatus state)
Refresh the state of the protocol.
Header of the JAMMER message.
uint & id_node()
Reference to id_node variable.
UwjammerModule_Class class_module_uwjammer
Provides the description of Uwjammer Class.
#define UWJAMMER_DROP_REASON_JAMMER_PROTOCOL
Protocol rules.
#define UWJAMMER_DROP_REASON_BUFFER_FULL
Buffer is full.
Header of a jammer packet.
#define HDR_JAMMER(p)
alias defined to access the JAMMER HEADER