49#define DEBUG(level,text) {if (1) {std::cout << NOW << " UwRangingTDMA(" << node_id << "): " << text << std::endl;}}
61 : TclClass(
"Module/UW/RANGING_TDMA")
81 ,node_id(count_nodes++)
93 std::cerr << NOW <<
" UwRangingTDMA() instances are " <<
count_nodes
94 <<
" but parameter tot_slots is set to " <<
tot_slots << std::endl;
101 for (
int ni = 0; ni <
n_nodes; ni++)
103 for (
int nj = ni + 1; nj <
n_nodes; nj++)
120 Packet *p = Packet::alloc();
121 hdr_cmn *ch = HDR_CMN(p);
122 hdr_mac *mach = HDR_MAC(p);
125 mach->set(MF_CONTROL, addr, BCAST_ADDR);
126 mach->macDA() = BCAST_ADDR;
146 (ch->size()) += rangh->
getSize();
168 hdr_cmn *ch = HDR_CMN(p);
174 if (!(ch->error())) {
182 for (
auto el : rangh->
times())
184 if (i == origin_node) {++i;}
193 }
else {incrXCtrlPktsRx();}
194 }
else {incrXCtrlPktsRx();}
207 MMac::Mac2PhyStartTx(p);
214 Tcl &tcl = Tcl::instance();
217 if (strcasecmp(argv[1],
"get_distance") == 0)
219 int n1 = atoi(argv[2]);
220 int n2 = atoi(argv[3]);
221 if (n1 >= 0 && n1 < n_nodes && n2 >= 0 && n2 <
n_nodes)
Class that represent the binding of the protocol with tcl.
UwRangingTDMAModuleClass()
Constructor of the TDMAGenericModule class.
TclObject * create(int, const char *const *)
Creates the TCL object needed for the tcl language interpretation.
Class that represents a UwRangingTDMA Node.
int node_id
id of the node (0 to n_nodes-1)
int n_nodes
number of nodes
virtual void Mac2PhyStartTx(Packet *p)
Method called when the Mac Layer start to transmit a Packet.
virtual void sendRange()
sends the ranging packet at the beginning of my slot
virtual void Phy2MacStartRx(const Packet *p)
Method called when the Phy Layer start to receive a Packet.
std::vector< std::vector< int > > owtt_map
of size [n_nodes][n_nodes] maps(nodeX,nodeY) -> owtt_vec index
static int count_nodes
counts the instantiated nodes, used for assigning node ids in default contructor
int slotidmax
maximum slot_id allowable in packet header
UwRangingTDMA()
Constructor of the UwRangingTDMA class.
virtual void Phy2MacEndRx(Packet *p)
Method called when the Phy Layer finish to receive a Packet.
virtual ~UwRangingTDMA()
Destructor of the UwRangingTDMA class.
std::vector< double > owtt_vec
vector of lenght D = n_nodes*(n_nodes-1)/2 + 1 where the one way travel times are stored
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
int slot_id
= node_id + k*n_nodes; slot_id value is written in the outgoing ranging packet then k is incremented
virtual void stateTxData()
Change transceiver status and and start to transmit if in my slot Used when there's spare time,...
Class that represents a TDMA Node.
UWTDMA_STATUS transceiver_status
Variable holding the status enum type.
int tot_slots
Number of slots in the frame (fair_mode)
int sea_trial_
Written log variable.
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
virtual void Phy2MacEndRx(Packet *p)
Method called when the Phy Layer finish to receive a Packet.
double slot_duration
Slot duration.
int slot_number
set the position of the node in the frame (fair_mode) (starting from 0 to tot_slots-1)
Header of the token bus protocol.
slotid_t & slotId()
Returns a reference to the nodeid_ variable.
size_t getSize() const
Returns the size of this header.
std::vector< uwrange_time_t > & times()
Returns a reference to the travel times array.
UwRangingTDMAModuleClass class_module_uwrangingtdma
Provides the definition of the class UwRangingTDMA.
packet_t PT_UWRANGING_TDMA
Common structures and variables in the protocol.
constexpr size_t SLOTIDMAX_HDR
#define HDR_RANGING_TDMA(p)
alias defined to access the hdr_ranging_tdma HEADER