129 : TclClass(
"Module/UW/DACAP")
143 cout << NOW <<
" MMacDACAP(" <<
module->addr
144 << ") backoff expired, current state = "
145 << module->info[module->curr_state] << endl;
147 module->last_reason = REASON_BACKOFF_END;
148 module->exitBackoff();
153 cout << NOW <<
" MMacDACAP(" <<
module->addr
154 << ") next state = " << module->info[STATE_IDLE] << endl;
163 switch (module->curr_state) {
168 cout << NOW <<
" MMacDACAP(" <<
module->addr
169 << ") timer expire() current state = "
170 << module->info[module->curr_state]
171 << " Recontend Window expired, next state = "
172 << module->info[STATE_IDLE] << endl;
174 module->last_reason = REASON_WAIT_RECONTEND_END;
181 cout << NOW <<
" MMacDACAP(" <<
module->addr
182 << ") timer expire() current state = "
183 << module->info[module->curr_state]
184 << " handshake not completed, next state = "
185 << module->info[STATE_BACKOFF] << endl;
187 module->last_reason = REASON_NOCTS;
188 module->stateBackoff();
193 if (module->defer_data ==
false) {
196 cout << NOW <<
" MMacDACAP(" <<
module->addr
197 << ") timer expire() current state = "
198 << module->info[module->curr_state]
199 << " warning not received, next state = "
200 << module->info[STATE_SEND_DATA] << endl;
202 module->last_reason = REASON_NOWRN;
203 module->stateSendData();
207 cout << NOW <<
" MMacDACAP(" <<
module->addr
208 << ") timer expire() current state = "
209 << module->info[module->curr_state]
210 << " warning received, next state = "
211 << module->info[STATE_DEFER_DATA] << endl;
213 module->last_reason = REASON_WRN_RECEIVED;
214 module->stateDeferData();
221 cout << NOW <<
" MMacDACAP(" <<
module->addr
222 << ") timer expire() current state = "
223 << module->info[module->curr_state]
224 << " defer data complete, next state = "
225 << module->info[STATE_SEND_DATA] << endl;
227 module->last_reason = REASON_DEFER_END;
228 module->stateSendData();
235 cout << NOW <<
" MMacDACAP(" <<
module->addr
236 << ") timer expire() current state = "
237 << module->info[module->curr_state]
238 << " ack not received, next state = "
239 << module->info[STATE_BACKOFF] << endl;
241 module->last_reason = REASON_NOACK;
242 module->stateBackoff();
248 cout << NOW <<
" MMacDACAP(" <<
module->addr
249 << ") timer expire() current state = "
250 << module->info[module->curr_state]
251 << " backoff expired, next state = "
252 << module->info[STATE_IDLE] << endl;
254 module->last_reason = REASON_BACKOFF_END;
255 module->exitBackoff();
262 cout << NOW <<
" MMacDACAP(" <<
module->addr
263 << ") timer expire() current state = "
264 << module->info[module->curr_state]
265 << " data not received, next state = "
266 << module->info[STATE_IDLE] << endl;
268 module->last_reason = REASON_NODATA;
275 cout << NOW <<
" MMacDACAP(" <<
module->addr
276 << ") timer expire() current state = "
277 << module->info[module->curr_state]
278 << " send WRN Window ended, next state = "
279 << module->info[STATE_WAIT_DATA] << endl;
281 module->last_reason = REASON_WRN_END;
282 module->stateWaitData();
288 cout << NOW <<
" MMacDACAP(" <<
module->addr
289 << ") timer expire() current state = "
290 << module->info[module->curr_state]
291 << " , next state = " << module->info[STATE_WAIT_XWRN]
294 module->last_reason = REASON_XCTS_END;
295 module->stateWaitXWarning();
301 cout << NOW <<
" MMacDACAP(" <<
module->addr
302 << ") timer expire() current state = "
303 << module->info[module->curr_state]
304 << " , next state = " << module->info[STATE_WAIT_XDATA]
307 module->last_reason = REASON_WAIT_XWRN_END;
308 module->stateWaitXData();
312 module->last_reason = REASON_XDATA_END;
314 module->stateWaitXAck();
317 cout << NOW <<
" MMacDACAP(" <<
module->addr
318 << ") timer expire() current state = "
319 << module->info[module->curr_state]
320 << " , next state = " << module->info[STATE_WAIT_XACK]
326 cout << NOW <<
" MMacDACAP(" <<
module->addr
327 << ") timer expire() current state = "
328 << module->info[module->curr_state]
329 << " , next state = " << module->info[STATE_IDLE]
337 cout << NOW <<
" MMacDACAP(" <<
module->addr
338 << ") timer expire() current state = "
339 << module->info[module->curr_state]
340 << " , next state = " << module->info[STATE_IDLE] << endl;
342 module->last_reason = REASON_XACK_END;
347 cout << NOW <<
" MMacDACAP(" <<
module->addr
348 << ") timer expire() logical error, current state = "
349 << module->info[module->curr_state] << endl;
361 , backoff_timer(this)
379 , session_active(false)
380 , backoff_pending(false)
381 , warning_sent(false)
382 , backoff_freeze_mode(false)
383 , print_transitions(false)
384 , has_buffer_queue(false)
385 , multihop_mode(false)
408 bind(
"t_min", (
double *) &
t_min);
409 bind(
"T_W_min", (
double *) &
T_W_min);
410 bind(
"delta_D", (
double *) &
delta_D);
413 bind(
"CTS_size", (
int *) &
CTS_size);
414 bind(
"RTS_size", (
int *) &
RTS_size);
415 bind(
"WRN_size", (
int *) &
WRN_size);
416 bind(
"HDR_size", (
int *) &
HDR_size);
417 bind(
"ACK_size", (
int *) &
ACK_size);
420 bind(
"debug_", (
int *) &debug_);
424 bind(
"alpha_", (
double *) &
alpha_);
446 Tcl &tcl = Tcl::instance();
448 if (strcasecmp(argv[1],
"printTransitions") == 0) {
451 fout.open(
"/tmp/DACAPstateTransitions.txt", ios_base::app);
453 }
else if (strcasecmp(argv[1],
"setAckMode") == 0) {
456 }
else if (strcasecmp(argv[1],
"setNoAckMode") == 0) {
459 }
else if (strcasecmp(argv[1],
"setBackoffFreeze") == 0) {
462 }
else if (strcasecmp(argv[1],
"setBackoffNoFreeze") == 0) {
465 }
else if (strcasecmp(argv[1],
"setMultiHopMode") == 0) {
468 }
else if (strcasecmp(argv[1],
"getQueueSize") == 0) {
471 }
else if (strcasecmp(argv[1],
"getMeanDeferTime") == 0) {
474 }
else if (strcasecmp(argv[1],
"getTotalDeferTimes") == 0) {
477 }
else if (strcasecmp(argv[1],
"getWrnPktsTx") == 0) {
480 }
else if (strcasecmp(argv[1],
"getWrnPktsRx") == 0) {
483 }
else if (strcasecmp(argv[1],
"getRtsPktsTx") == 0) {
486 }
else if (strcasecmp(argv[1],
"getRtsPktsRx") == 0) {
489 }
else if (strcasecmp(argv[1],
"getCtsPktsTx") == 0) {
492 }
else if (strcasecmp(argv[1],
"getCtsPktsRx") == 0) {
495 }
else if (strcasecmp(argv[1],
"getUpLayersDataRx") == 0) {
499 }
else if (argc == 3) {
500 if (strcasecmp(argv[1],
"setMacAddr") == 0) {
501 addr = atoi(argv[2]);
503 cout <<
"DACAP MAC address of current node is " << addr << endl;
507 return MMac::command(argc, argv);
520 return Module::crLayCommand(m);
528 system(
"rm -f /tmp/DACAPstateTransitions.txt");
530 system(
"touch /tmp/DACAPstateTransitions.txt");
580 "RTS received for the same current DATA pkt";
598 Packet *temp_data_pkt;
602 temp_data_pkt = (
Q.front())->copy();
603 hdr_cmn *ch = HDR_CMN(temp_data_pkt);
606 temp_data_pkt = Packet::alloc();
607 hdr_cmn *ch = HDR_CMN(temp_data_pkt);
611 temp_data_pkt = Packet::alloc();
612 hdr_cmn *ch = HDR_CMN(temp_data_pkt);
615 temp_data_pkt = Packet::alloc();
616 hdr_cmn *ch = HDR_CMN(temp_data_pkt);
619 temp_data_pkt = Packet::alloc();
620 hdr_cmn *ch = HDR_CMN(temp_data_pkt);
623 temp_data_pkt = Packet::alloc();
624 hdr_cmn *ch = HDR_CMN(temp_data_pkt);
627 duration = Mac2PhyTxDuration(temp_data_pkt);
628 Packet::free(temp_data_pkt);
639 cout << NOW <<
" MMacDACAP(" << addr
640 <<
")::computeWaitTime() tx duration = " << t_data << endl;
664 }
else if ((distance /
prop_speed) > max(t_2, t_3)) {
681 timer.force_cancel();
703 timer.force_cancel();
709 cout << NOW <<
" MMacDACAP(" << addr
710 <<
")::freezeBackoff() error, backoff start time not set " << endl;
717 cout << NOW <<
" MMacDACAP(" << addr
718 <<
")::freezeBackoff() error, backoff elapsed time = "
726 cout << NOW <<
" MMacDACAP(" << addr
727 <<
")::freezeBackoff() elapsed time = " << elapsed_time
738 double random = RNG::defaultrng()->uniform_double();
740 while (random == 0) {
741 random = RNG::defaultrng()->uniform_double();
750 incrTotalBackoffTimes();
752 double random = RNG::defaultrng()->uniform_double();
755 while (random == 0) {
756 random = RNG::defaultrng()->uniform_double();
766 cout << NOW <<
" MMacDACAP(" << addr
767 <<
")::getBackoffTime() backoff time = " << random <<
" s "
796 incrDiscardedPktsTx();
805 hdr_cmn *ch = hdr_cmn::access(p);
807 hdr_mac *mach = HDR_MAC(p);
811 dacaph->
ts = Scheduler::instance().clock();
815 int curr_size = ch->size();
818 ch->timestamp() = dacaph->
ts;
852 mach->macSA() = addr;
874 cout << NOW <<
" MMacDACAP(" << addr
879 cout << NOW <<
" MMacDACAP(" << addr
900 cout << NOW <<
" MMacDACAP(" << addr
901 <<
")::Phy2MacEndTx() ack sent and backoff pending, "
912 cout << NOW <<
" MMacDACAP(" << addr
913 <<
")::Phy2MacEndTx() ack sent, from "
924 cout << NOW <<
" MMacDACAP(" << addr
934 cout << NOW <<
" MMacDACAP(" << addr
947 cout << NOW <<
" MMacDACAP(" << addr
948 <<
")::Phy2MacEndTx() logical error, current state = "
965 hdr_cmn *ch = HDR_CMN(p);
966 packet_t rx_pkt_type = ch->ptype();
974 hdr_mac *mach = HDR_MAC(p);
975 hdr_MPhy *ph = HDR_MPHY(p);
977 int source_mac = mach->macSA();
978 double tx_time = ph->txtime;
979 double rx_time = ph->rxtime;
980 double diff_time = rx_time - tx_time;
991 cout << NOW <<
" MMacDACAP(" << addr <<
")::Phy2MacEndRx() "
994 <<
", src addr = " << mach->macSA()
995 <<
" dest addr = " << mach->macDA()
996 <<
", estimated distance between nodes = " << distance <<
" m "
1052 cout << NOW <<
" MMacDACAP(" << addr
1053 <<
")::Phy2MacEndRx() dropping pkt, wrong state"
1071 cout << NOW <<
" MMacDACAP(" << addr
1072 <<
")::setBackoffNodes() mac addr involved = " <<
sleep_node_1
1081 Packet *ack_pkt = Packet::alloc();
1086 Mac2PhyStartTx(ack_pkt);
1093 Packet *data_pkt = (
Q.front())->copy();
1099 Mac2PhyStartTx(data_pkt);
1106 Packet *rts_pkt = Packet::alloc();
1125 Mac2PhyStartTx(rts_pkt);
1131 Packet *cts_pkt = Packet::alloc();
1137 Mac2PhyStartTx(cts_pkt);
1145 Packet *wrn_ptk = Packet::alloc();
1147 Mac2PhyStartTx(wrn_ptk);
1158 hdr_mac *mach = HDR_MAC(p);
1159 hdr_MPhy *ph = HDR_MPHY(p);
1161 int source_mac = mach->macSA();
1162 int dest_mac = mach->macDA();
1164 int pkt_data_sn = dacaph->
data_sn;
1165 double tx_time = ph->txtime;
1166 double rx_time = ph->rxtime;
1167 double diff_time = rx_time - tx_time;
1172 if (dest_mac == addr) {
1185 cout << NOW <<
" MMacDACAP(" << addr
1199 }
else if (pkt_type ==
CTS_PKT) {
1221 hdr_mac *mach = HDR_MAC(p);
1222 hdr_MPhy *ph = HDR_MPHY(p);
1224 int source_mac = mach->macSA();
1225 int dest_mac = mach->macDA();
1227 int pkt_data_sn = dacaph->
data_sn;
1228 double tx_time = ph->txtime;
1229 double rx_time = ph->rxtime;
1230 double diff_time = rx_time - tx_time;
1235 if (dest_mac == addr) {
1253 cout << NOW <<
" MMacDACAP(" << addr
1254 <<
")::rxStateBackoff() next state = "
1267 cout << NOW <<
" MMacDACAP(" << addr
1268 <<
")::rxStateBackoff() next state = "
1273 }
else if (pkt_type ==
CTS_PKT) {
1279 cout << NOW <<
" MMacDACAP(" << addr
1280 <<
")::rxStateBackoff() next state = "
1291 cout << NOW <<
" MMacDACAP(" << addr
1292 <<
")::rxStateBackoff() next state = "
1307 hdr_mac *mach = HDR_MAC(p);
1308 hdr_MPhy *ph = HDR_MPHY(p);
1310 int source_mac = mach->macSA();
1311 int dest_mac = mach->macDA();
1313 int pkt_data_sn = dacaph->
data_sn;
1314 double tx_time = ph->txtime;
1315 double rx_time = ph->rxtime;
1316 double diff_time = rx_time - tx_time;
1321 if ((dest_mac != addr) && (pkt_type ==
CTS_PKT)) {
1326 cout << NOW <<
" MMacDACAP(" << addr
1327 <<
")::rxStateWaitCTS() diff time = " << diff_time
1328 <<
" < t_min = " <<
t_min <<
" ; Defering data " << endl;
1336 cout << NOW <<
" MMacDACAP(" << addr
1337 <<
")::rxStateWaitCTS() diff time = " << diff_time
1338 <<
" < T_W_min = " <<
T_W_min <<
" ; Defering data "
1346 }
else if ((dest_mac != addr) && (pkt_type ==
RTS_PKT)) {
1351 cout << NOW <<
" MMacDACAP(" << addr
1352 <<
")::rxStateWaitCTS() diff time = " << diff_time
1354 <<
" ; Defering data " << endl;
1360 }
else if ((dest_mac == addr) && (source_mac ==
curr_dest_addr) &&
1370 cout << NOW <<
" MMacDACAP(" << addr
1385 hdr_mac *mach = HDR_MAC(p);
1386 hdr_MPhy *ph = HDR_MPHY(p);
1388 int source_mac = mach->macSA();
1389 int dest_mac = mach->macDA();
1391 int pkt_data_sn = dacaph->
data_sn;
1392 double tx_time = ph->txtime;
1393 double rx_time = ph->rxtime;
1394 double diff_time = rx_time - tx_time;
1410 cout << NOW <<
" MMacDACAP(" << addr
1422 cout << NOW <<
" MMacDACAP(" << addr
1423 <<
")::rxStateWaitACK() next state = "
1438 hdr_mac *mach = HDR_MAC(p);
1439 hdr_MPhy *ph = HDR_MPHY(p);
1441 int source_mac = mach->macSA();
1442 int dest_mac = mach->macDA();
1444 int pkt_data_sn = dacaph->
data_sn;
1445 double tx_time = ph->txtime;
1446 double rx_time = ph->rxtime;
1447 double diff_time = rx_time - tx_time;
1455 cout << NOW <<
" MMacDACAP(" << addr
1456 <<
")::rxStateWaitData() next state = "
1487 hdr_mac *mach = HDR_MAC(p);
1488 hdr_MPhy *ph = HDR_MPHY(p);
1490 int source_mac = mach->macSA();
1491 int dest_mac = mach->macDA();
1493 int pkt_data_sn = dacaph->
data_sn;
1494 double tx_time = ph->txtime;
1495 double rx_time = ph->rxtime;
1496 double diff_time = rx_time - tx_time;
1501 if ((dest_mac != addr) &&
1513 cout << NOW <<
" MMacDACAP(" << addr
1514 <<
")::rxStateWaitXCts() DATA or ACK received "
1515 <<
"from nodes involved. quitting sleep. next state = "
1523 }
else if (pkt_type ==
CTS_PKT) {
1528 cout << NOW <<
" MMacDACAP(" << addr
1529 <<
")::rxStateWaitXCts() next state = "
1539 cout << NOW <<
" MMacDACAP(" << addr
1540 <<
")::rxStateWaitXCts() next state = "
1555 hdr_mac *mach = HDR_MAC(p);
1556 hdr_MPhy *ph = HDR_MPHY(p);
1558 int source_mac = mach->macSA();
1559 int dest_mac = mach->macDA();
1561 int pkt_data_sn = dacaph->
data_sn;
1562 double tx_time = ph->txtime;
1563 double rx_time = ph->rxtime;
1564 double diff_time = rx_time - tx_time;
1569 if ((dest_mac != addr) &&
1581 cout << NOW <<
" MMacDACAP(" << addr
1582 <<
")::rxStateWaitXData() DATA or ACK received "
1583 <<
"from nodes involved. quitting sleep. next state = "
1597 cout << NOW <<
" MMacDACAP(" << addr
1598 <<
")::rxStateWaitXData() next state = "
1613 hdr_mac *mach = HDR_MAC(p);
1614 hdr_MPhy *ph = HDR_MPHY(p);
1616 int source_mac = mach->macSA();
1617 int dest_mac = mach->macDA();
1619 int pkt_data_sn = dacaph->
data_sn;
1620 double tx_time = ph->txtime;
1621 double rx_time = ph->rxtime;
1622 double diff_time = rx_time - tx_time;
1627 if ((dest_mac != addr) &&
1639 cout << NOW <<
" MMacDACAP(" << addr
1640 <<
")::rxStateWaitXAck() DATA or ACK received "
1641 <<
"from nodes involved. quitting sleep. next state = "
1658 hdr_mac *mach = HDR_MAC(p);
1659 hdr_MPhy *ph = HDR_MPHY(p);
1661 int source_mac = mach->macSA();
1662 int dest_mac = mach->macDA();
1664 int pkt_data_sn = dacaph->
data_sn;
1665 double tx_time = ph->txtime;
1666 double rx_time = ph->rxtime;
1667 double diff_time = rx_time - tx_time;
1672 if ((dest_mac != addr) &&
1684 cout << NOW <<
" MMacDACAP(" << addr
1685 <<
")::rxStateWaitXWarning() DATA or ACK received "
1686 <<
"from nodes involved. quitting sleep. next state = "
1699 cout << NOW <<
" MMacDACAP(" << addr
1700 <<
")::rxStateWaitXWarning() next state = "
1715 hdr_mac *mach = HDR_MAC(p);
1716 hdr_MPhy *ph = HDR_MPHY(p);
1718 int source_mac = mach->macSA();
1719 int dest_mac = mach->macDA();
1721 int pkt_data_sn = dacaph->
data_sn;
1722 double tx_time = ph->txtime;
1723 double rx_time = ph->rxtime;
1724 double diff_time = rx_time - tx_time;
1729 if ((dest_mac != addr) && (source_mac ==
CTS_PKT)) {
1734 cout << NOW <<
" MMacDACAP(" << addr
1735 <<
")::rxStateWaitWarning() diff time = " << diff_time
1736 <<
" < t_min = " <<
t_min <<
" ; Defering data " << endl;
1745 cout << NOW <<
" MMacDACAP(" << addr
1746 <<
")::rxStateWaitWarning() diff time = " << diff_time
1747 <<
" < T_W_min = " <<
T_W_min <<
" ; Defering data "
1754 }
else if ((dest_mac != addr) && (pkt_type ==
RTS_PKT)) {
1759 cout << NOW <<
" MMacDACAP(" << addr
1760 <<
")::rxStateWaitWarning() diff time = " << diff_time
1762 <<
" ; Defering data " << endl;
1769 }
else if ((dest_mac == addr) && (source_mac ==
curr_dest_addr) &&
1775 cout << NOW <<
" MMacDACAP(" << addr
1776 <<
")::rxStateWaitWarning() WRN received, defering data "
1791 hdr_mac *mach = HDR_MAC(p);
1792 hdr_MPhy *ph = HDR_MPHY(p);
1794 int source_mac = mach->macSA();
1795 int dest_mac = mach->macDA();
1797 int pkt_data_sn = dacaph->
data_sn;
1798 double tx_time = ph->txtime;
1799 double rx_time = ph->rxtime;
1800 double diff_time = rx_time - tx_time;
1808 cout << NOW <<
" MMacDACAP(" << addr
1809 <<
")::rxStateSendWarning() DATA received in "
1833 }
else if ((dest_mac != addr) && (pkt_type ==
RTS_PKT)) {
1838 cout << NOW <<
" MMacDACAP(" << addr
1839 <<
")::rxStateSendWarning() difference time = "
1841 <<
" sending a warning " << endl;
1847 }
else if ((dest_mac != addr) && (pkt_type ==
CTS_PKT)) {
1853 cout << NOW <<
" MMacDACAP(" << addr
1854 <<
")::rxStateSendWarning() difference time = "
1856 <<
" sending a warning " << endl;
1871 hdr_mac *mach = HDR_MAC(p);
1872 hdr_MPhy *ph = HDR_MPHY(p);
1874 int source_mac = mach->macSA();
1875 int dest_mac = mach->macDA();
1877 int pkt_data_sn = dacaph->
data_sn;
1878 double tx_time = ph->txtime;
1879 double rx_time = ph->rxtime;
1880 double diff_time = rx_time - tx_time;
1885 if (dest_mac == addr) {
1898 cout << NOW <<
" MMacDACAP(" << addr
1899 <<
")::rxStateRecontendWindow() next state = "
1912 cout << NOW <<
" MMacDACAP(" << addr
1913 <<
")::rxStateRecontendWindow() next state = "
1918 }
else if (pkt_type ==
CTS_PKT) {
1924 cout << NOW <<
" MMacDACAP(" << addr
1925 <<
")::rxStateRecontendWindow() next state = "
1936 cout << NOW <<
" MMacDACAP(" << addr
1937 <<
")::rxStateRecontendWindow() next state = "
1949 timer.force_cancel();
1973 incrDroppedPktsTx();
1978 cout << NOW <<
" MMacDACAP(" << addr
1979 <<
")::stateIdle() dropping pkt, max tx tries reached"
1992 timer.force_cancel();
2005 timer.force_cancel();
2014 cout << NOW <<
" MMacDACAP(" << addr
2015 <<
")::stateBackoff() starting a new backoff" << endl;
2032 cout << NOW <<
" MMacDACAP(" << addr
2033 <<
")::stateBackoff() error!!! backoff remaining not set!!!"
2039 cout << NOW <<
" MMacDACAP(" << addr
2040 <<
")::stateBackoff() continuing previous backoff, "
2056 timer.force_cancel();
2067 timer.force_cancel();
2079 timer.force_cancel();
2090 timer.force_cancel();
2106 timer.force_cancel();
2122 timer.force_cancel();
2139 timer.force_cancel();
2152 timer.force_cancel();
2166 timer.force_cancel();
2178 timer.force_cancel();
2186 cout << NOW <<
" MMacDACAP(" << addr
2187 <<
")::stateDeferData() defer delay = " << defer_delay << endl;
2193 timer.resched(defer_delay);
2199 timer.force_cancel();
2212 timer.force_cancel();
2226 timer.force_cancel();
2233 hdr_cmn *ch = hdr_cmn::access(data_pkt);
2236 ch->size() = ch->size() -
HDR_size;
2249 timer.force_cancel();
2260 timer.force_cancel();
2271 timer.force_cancel();
2277 timer.resched(delay);
2284 cout << NOW <<
" MMacDACAP(" << addr <<
")::printStateInfo() "
2290 fout << left << setw(10) << NOW <<
" MMacDACAP(" << addr
2291 <<
")::printStateInfo() "
2294 <<
". Backoff duration = " << delay
2297 fout << left << setw(10) << NOW <<
" MMacDACAP(" << addr
2298 <<
")::printStateInfo() "
2301 <<
". Defering delay = " << delay << endl;
2303 fout << left << setw(10) << NOW <<
" MMacDACAP(" << addr
2304 <<
")::printStateInfo() "
2307 <<
". Waiting delay = " << delay << endl;
2309 fout << left << setw(10) << NOW <<
" MMacDACAP(" << addr
2310 <<
")::printStateInfo() "
2320 std::string response;
2321 std::cout <<
"Press Enter to continue";
2322 std::getline(std::cin, response);
virtual void expire(Event *e)
Method called when the timer expire.
Class that represent the binding of the protocol with tcl.
TclObject * create(int, const char *const *)
DACAPModuleClass()
Constructor of the class.
virtual void expire(Event *e)
Method call when the timer expire.
Class that represents a DACAP node.
double wait_costant
Additive factor in the calculation of ACK timer.
ofstream fout
Object that handle the file where the state transitions is written (if the print_transitions option i...
DACAPBTimer backoff_timer
backoff timer
int op_mode
Indicates if the ACK_mode or no_ACK_mode is activated.
virtual int getWrnPktsRx()
virtual void stateWaitXCts()
The protocol is in WaitXCts state.
virtual void waitForUser()
Used for debug purposes.
virtual double getMeanDeferTime()
bool warning_sent
true if a WRN packet has been just sent
MMacDACAP()
Costructor of the MMacDACAP class.
virtual int getTotalDeferTimes()
int ACK_size
Size (in bytes) of the ACK packet.
bool print_transitions
true if the state-transitions of the protocol is printed on a file
virtual int getRtsPktsTx()
virtual void txRts()
Pass a RTS packet to transmit to the PHY layer.
virtual void incrWrnPktsRx()
Increases the counter of WRN packets received.
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
Packet * curr_data_pkt
Pointer to the current data packet.
virtual void stateDeferData()
The protocol is in the DeferData state.
int last_reason
last reason for the change of state
bool backoff_freeze_mode
true if the backoff-timer is freezed
int u_data_id
simulation-unique DATA packet ID
bool has_buffer_queue
true if the node has a buffer queue to store data packets
int WRN_size
Size (in bytes) of the WRN packet.
double alpha_
smoothing factor used for statistics using first order IIR filter
double max_tx_tries
Maximum transmission tries for one packet before discarding the packet.
virtual int getCtsPktsRx()
double max_prop_delay
One way maximum propagation delay (in seconds) in the network.
double session_distance
Distance between sender and receiver in the current session.
int last_data_id_tx
Unique ID of the last data packet transmitted.
int CTS_size
Size (in bytes) of the CTS packet.
static int u_pkt_id
simulation-unique packet ID
int txsn
serial number of the DATA packet transmitted
virtual int getQueueSize()
double backoff_remaining
Backoff time remaining (if the timer is freezed)
virtual void stateSendWarning()
The protocol is in the SendWarning state.
virtual void stateWaitXAck()
The protocol is in WaitXAck state.
int curr_dest_addr
MAC address of the current node involved in this session.
virtual void rxStateIdle(Packet *p)
The case of reception while the protocol is in IDLE state is handled.
virtual void incrRtsPktsTx()
Increases the counter of RTS packets transmitted.
int buffer_pkts
Dimension (in packets) of the buffer queue.
virtual double computeTxTime(int type)
Computes the time that is needed to transmit a packet, implementing a CrLayMessage for asking the PHY...
virtual void backoffStartTime()
Sets the start time of the backoff timer to NOW.
int prev_state
Previous state of the protocol.
virtual void Phy2MacStartRx(const Packet *p)
Method called when the Phy Layer start to receive a Packet.
virtual void rxStateWaitXData(Packet *p)
The case of reception while the protocol is in WaitXData state is handled.
virtual void rxStateWaitXCts(Packet *p)
The case of reception while the protocol is in WaitXCts state is handled.
std::queue< Packet * > Q
MAC queue used for packet scheduling.
int max_payload
Dimension of the maximum allowed data paylaod in bytes.
virtual void rxStateWaitWarning(Packet *p)
The case of reception while the protocol is in WaitWarning state is handled.
int sleep_node_2
MAC address of sleep_node 2.
double start_tx_time
Timestamp at which a packet is transmitted.
double delta_D
Value (in m) that indicates how far we want the CTS propagates over the sender before initiate the da...
int RTS_size
Size (in bytes) of the RTS packet.
bool TxActive
true if a transmission process is occuring
virtual void rxStateWaitXAck(Packet *p)
The case of reception while the protocol is in WaitXAck state is handled.
bool backoff_pending
true if the backoff-timer is active (i.e.
bool multihop_mode
true if the multihop mode is active to simulate a multihop scenario with routing
double backoff_start_time
Backoff starting time.
virtual void txAck()
Pass an ACK packet to transmit to the PHY layer.
virtual void deferEndTime(double duration)
Sets the end time of the defer summing the duration to the actual duration of defer.
virtual void refreshState(int state)
Refresh the state of the protocol.
virtual void setBackoffNodes(double node, double node_b)
Saves the MAC address of another couple of nodes that is the handshake procedure in order to access t...
int HDR_size
Size (in bytes) of the header added by DACAP.
virtual void rxStateSendWarning(Packet *p)
The case of reception while the protocol is in SendWarning state is handled.
double max_backoff_counter
Number of times a backoff is calculated.
virtual void queuePop(bool flag=true)
Pop the first element of the queue.
virtual void stateDataReceived(Packet *data_pkt)
The protocol is in the DataReceived state.
virtual void rxStateWaitData(Packet *p)
The case of reception while the protocol is in WaitDATA state is handled.
virtual double getRecontendTime()
Used in multihop mode.
int last_data_id_rx
Unique ID of the last data packet received.
virtual void rxStateBackoff(Packet *p)
The case of reception while the protocol is in BACKOFF state is handled.
virtual void initPkt(Packet *p, int pkt_type)
Initializes the packet with the correct MAC source address and destination address,...
bool RxActive
true if a reception process is occuring
virtual double getBackoffTime()
Calculate the backoff time if the node didn't received the ACK.
virtual int getWrnPktsTx()
virtual void recvFromUpperLayers(Packet *p)
Receive the packet from the upper layer (e.g.
virtual void incrCtsPktsRx()
Increases the counter of CTS packets received.
virtual void stateSendAck()
The protocol is in SendAck state.
bool session_active
true if a session is active (i.e.
virtual void rxStateWaitXWarning(Packet *p)
The case of reception while the protocol is in WaitXWarning state is handled.
virtual void stateWaitWarning()
The protocol is in WaitWarning state.
virtual void stateWaitXWarning()
The protocol is in WaitXWarning state.
virtual void incrWrnPktsTx()
Increases the counter of WRN packets transmitted.
virtual void stateCTSReceived()
The protocol is in the CTSReceived state.
int sleep_node_1
MAC address of sleep_node 1.
virtual void stateWaitData()
The protocol is in the WaitData state.
virtual void stateSendData()
The protocol is in the SendData state.
virtual void rxStateRecontendWindow(Packet *p)
The case of reception while the protocol is in RecontendWindow state is handled.
virtual void incrTotalDeferTimes()
Increases the number of times a transmission is deferred.
virtual void initInfo()
Initializes the protocol at the beginning of the simulation.
virtual void stateBackoff()
The protocol is in Backoff state.
virtual void rxStateWaitACK(Packet *p)
The case of reception while the protocol is in WaitACK state is handled.
double t_min
Minimum time needed to do an hand-shaking.
int curr_state
Current state of the protocol.
virtual void incrCtsPktsTx()
Increases the counter of CTS packets transmitted.
virtual void stateWaitCTS()
The protocol is in the WaitCTS state.
double backoff_duration
Backoff duration.
virtual void txWrn()
Pass a WRN packet to transmit to the PHY layer.
virtual int getCtsPktsTx()
virtual void freezeBackoff()
Freezes the Backoff timer.
virtual void Phy2MacEndTx(const Packet *p)
Method called when the PHY layer finish to transmit the packet.
double T_W_min
Minimum Warning Time in sencods.
virtual void rxStateWaitCTS(Packet *p)
The case of reception while the protocol is in WaitCTS state is handled.
DACAPTimer timer
ACK timer.
int getUpLayersDataPktsRx()
double delta_data
Dimension difference (in bytes) among data packets ( 0 if the packets have always the same dimension...
virtual void stateRecontendWindow()
The protocol is in RecontendWindow state.
virtual void incrRtsPktsRx()
Increases the counter of RTS packets received.
virtual void exitSleep()
This method erase the MAC address of the two nodes that have intiated a handshake procedure if this h...
virtual void exitBackoff()
The backoff timer is stopped.
virtual void Phy2MacEndRx(Packet *p)
Method called when the Phy Layer finish to receive a Packet.
virtual void txCts()
Pass a CTS packet to transmit to the PHY layer.
int backoff_counter
Number of times a backoff timer is set up.
virtual int crLayCommand(ClMessage *m)
Cross-Layer messages interpreter.
virtual int getRtsPktsRx()
bool defer_data
true if a node has to defer the transmission of a data packet
virtual ~MMacDACAP()
Destructor of the MMacDACAP class.
virtual void printStateInfo(double delay=0)
Prints a file with every state change for debug purposes.
static map< int, string > info
Relationship between the state and its textual description.
virtual double computeWaitTime(int mode, double distance)
Computes the T_w parameter, that is the minimum time that the sender has to wait between the receptio...
virtual void backoffEndTime()
calculates the End Time of the backoff timer
virtual void stateIdle()
The protocol is in the IDLE state.
virtual void txData()
Pass a DATA packet to transmit to the PHYl layer.
double backoff_tuner
Multiplicative factor in the calculation of backoff.
double backoff_first_start
Timestamp at which the backoff timer is started for the first time (if the timer has been freezed man...
virtual void stateWaitACK()
The protocol is in the WaitACK state.
virtual void stateSendRTS()
The protocol is in SendRTS state.
virtual void stateWaitXData()
The protocol is in WaitXData state.
virtual void stateSendCTS()
The protocol is in SendCTS state.
Definition of the header of DACAP packets.
int sn
sequence number of this packet
int dacap_type
sequence number of this packet
int tx_tries
Number of transmission tries of the packet.
int data_sn
Sequence number of the packet.
double ts
packet timestamp, i.e., its generation time)
packet_t orig_type
Original type of the packet.
static const double prop_speed
DACAPModuleClass class_module_dacap
@ REASON_SAME_RTS_RECEIVED
@ REASON_WAIT_RECONTEND_END
Provides the DACAP Class header description.
#define DACAP_DROP_REASON_UNKNOWN_TYPE
The type of the packet is unknown.
#define DACAP_DROP_REASON_BUFFER_FULL
The buffer of the node is full.