-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameState.cc
998 lines (855 loc) · 21.6 KB
/
GameState.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
/*
* GameState.cc
*
* Created on: 03.06.2020
* Author: Kevin Küchler
*
* The GameState class hold all information about the current game state
*
* bool initiator Defines if the current node is the initiator
* of this game or not.
*
* bool endOfGame Defines if the game has ended for this node.
* The game end either if the unchangedCounter
* hits a certain threshold N or if all child
* nodes have sent an EndOfGame frame to this
* node.
*
* bool discovery Defines if this node has already done a
* neighbor discovery or not. Every node should
* at least do one neighbor discovery to tell
* nearby nodes it is here
*
* uint64_t gameID The gameID is used to identify the current
* running game. Thus is it possible to construct
* multiple broadcast trees within the same
* network without colliding with other games.
* The gameID field in the protocol header is
* just 48 bit large but is held internally in
* a 64 bit integer.
*
* uint32_t unchangedCounter This counter is incremented when no changes
* have been made after receiving a packet. Even
* if the node changed its parent and the cost
* of the connection is the same as before.
*
* double maxTxPower The maximum transmission power of a nodes
* refers to the current maximum transmission
* power in dBm to reach all child nodes that
* are registered at this node.
*
* double costOfCurrentConn The cost of current connection determines
* how much transmission power is needed to
* reach the parent node of this node. The
* transmitter will only send with this TX
* power set, if this nodes want to reach its
* parent node.
*
* vector childList The child list hold all child nodes that are
* registered at this node. The child list is
* always a subset of the neighbor list. It is
* used to send the cycle test packet and later
* the application data packets.
*
* vector neighbors The neighbor list contains all other nodes
* this node has ever received a packet from.
* It is used to find possible (new) parents.
*/
#include "float.h"
#include "ns3/integer.h"
#include "GameState.h"
#include "ns3/core-module.h"
#include "ns3/wifi-utils.h"
#include "SendEvent.h"
#include "LockEvent.h"
#include "ParentPathCheckEvent.h"
namespace ns3
{
NS_LOG_COMPONENT_DEFINE("GameState");
/*
* Implementation EEBTPNode
*/
EEBTPNode::EEBTPNode(Mac48Address addr, double power)
{
this->address = addr;
this->finished = false;
this->highest_maxTxPower = power;
this->second_maxTxPower = power;
this->noise = 0;
this->rxPower = 0;
this->reachPower = FLT_MAX;
this->connCounter = 0;
this->rpChanged = false;
this->pChanged = false;
this->hasRpProblem = false;
}
EEBTPNode::~EEBTPNode()
{
}
double EEBTPNode::getHighestMaxTxPower()
{
return this->highest_maxTxPower;
}
void EEBTPNode::setHighestMaxTxPower(double maxTxPower)
{
this->highest_maxTxPower = maxTxPower;
}
double EEBTPNode::getSecondHighestMaxTxPower()
{
return this->second_maxTxPower;
}
void EEBTPNode::setSecondHighestMaxTxPower(double maxTxPower)
{
this->second_maxTxPower = maxTxPower;
}
double EEBTPNode::getReachPower()
{
return this->reachPower;
}
void EEBTPNode::setReachPower(double reachPower)
{
if (this->reachPower < reachPower + 0.0000001 && this->reachPower > reachPower - 0.0000001)
this->rpChanged = true;
this->reachPower = reachPower;
}
double EEBTPNode::getNoise()
{
return this->noise;
}
void EEBTPNode::updateRxInfo(double rxPower, double noise)
{
this->noise = noise;
this->rxPower = rxPower;
}
bool EEBTPNode::hasReachPowerProblem()
{
return this->hasRpProblem;
}
void EEBTPNode::hasReachPowerProblem(bool b)
{
this->hasRpProblem = b;
}
Mac48Address EEBTPNode::getAddress()
{
return this->address;
}
Mac48Address EEBTPNode::getParentAddress()
{
return this->parent;
}
void EEBTPNode::setParentAddress(Mac48Address addr)
{
this->parent = addr;
}
bool EEBTPNode::hasFinished()
{
return this->finished;
}
void EEBTPNode::setFinished(bool f)
{
this->finished = f;
}
bool EEBTPNode::isOnPath(Mac48Address addr)
{
for (uint i = 0; i < this->srcPath.size(); i++)
{
Mac48Address node = this->srcPath[i];
if (node == addr)
return true;
}
return false;
}
std::vector<Mac48Address> EEBTPNode::getSrcPath()
{
return this->srcPath;
}
void EEBTPNode::setSrcPath(std::vector<Mac48Address> path)
{
this->pChanged = false;
if (path.size() == this->srcPath.size())
{
for (uint i = 0; i < path.size(); i++)
if (path[i] != this->srcPath[i])
{
this->pChanged = true;
break;
}
}
else
this->pChanged = true;
this->srcPath.clear();
for (uint i = 0; i < path.size(); i++)
{
this->srcPath.push_back(path[i]);
}
}
bool EEBTPNode::reachPowerChanged()
{
return this->rpChanged;
}
void EEBTPNode::resetReachPowerChanged()
{
this->rpChanged = false;
}
bool EEBTPNode::pathChanged()
{
return this->pChanged;
}
void EEBTPNode::resetPathChanged()
{
this->pChanged = false;
}
uint32_t EEBTPNode::getConnCounter()
{
return this->connCounter;
}
void EEBTPNode::incrementConnCounter()
{
this->connCounter++;
}
void EEBTPNode::resetConnCounter()
{
this->connCounter = 0;
}
/*
* Implementation GameState
*/
GameState::GameState() : GameState(false, 0)
{
}
GameState::GameState(bool initiator, uint64_t gid)
{
this->endOfGame = false;
this->initiator = initiator;
this->doIncrementAfterConfirm = false;
this->rejectionCounter = 0;
this->parentUnchangedCounter = 0;
this->needCycleCheck = false;
this->gameID = gid;
this->unchangedCounter = 0;
this->highestTxPower = WToDbm(0);
this->secondTxPower = WToDbm(0);
this->costOfCurrentConn = FLT_MAX;
this->locked = false;
this->childsLocked = 0;
this->parentIsWaitingForLock = false;
this->newParentIsWaitingForLock = false;
this->lockedByNode = Mac48Address::GetBroadcast();
this->emptyPathOnConnect = false;
this->adh = Create<ApplicationDataHandler>();
}
GameState::~GameState()
{
this->blacklist.clear();
this->childList.clear();
this->frameTypeCache.clear();
this->locks.clear();
this->neighbors.clear();
this->srcPath.clear();
this->adh = 0;
this->contactedParent = 0;
this->lockOriginator = 0;
this->neighborDiscoveryEvent = 0;
this->newParentLockOriginator = 0;
this->parent = 0;
this->ppcEvent = 0;
}
TypeId GameState::GetTypeId()
{
static TypeId tid = TypeId("ns3::GameState")
.SetParent<Object>()
.AddConstructor<GameState>()
.AddAttribute("initiator", "Indicates if the node with this state is the initiator of the game",
BooleanValue(false),
MakeBooleanAccessor(&GameState::initiator),
MakeBooleanChecker())
.AddAttribute("gameID", "The gameID this packet corresponds to",
IntegerValue(0),
MakeIntegerAccessor(&GameState::gameID),
MakeIntegerChecker<int>());
return tid;
}
TypeId GameState::GetInstanceTypeId() const
{
return GetTypeId();
}
//Returns true if this node is the initiator of this game
bool GameState::isInitiator()
{
return this->initiator;
}
//Return the game ID of the current game
uint64_t GameState::getGameID()
{
return this->gameID;
}
bool GameState::needsCycleCheck()
{
return this->needCycleCheck;
}
void GameState::setCycleCheckNeeded(bool cc)
{
this->needCycleCheck = cc;
}
Mac48Address GameState::getMyAddress()
{
return this->myAddress;
}
void GameState::setMyAddress(Mac48Address addr)
{
this->myAddress = addr;
}
/*
* Finish game
* - Finish the game of a node and saves the time
* - Checks if the game already finished
* - Get the time when the game was finished
*/
void GameState::finishGame()
{
this->endOfGame = true;
this->finishTime = Now();
}
bool GameState::gameFinished()
{
return this->endOfGame;
}
Time GameState::getTimeFinished()
{
return this->finishTime;
}
/*
* Sequence numbers
* - Get the last seen sequence number of a sender and a specific frame type
* - Check whether the given sequence number is higher then the last seen
* sequence number of a sender and a specific frame type
* - Update the cache for a sender and a specific frame type with a newer sequence number
*/
uint16_t GameState::getLastSeqNo(Mac48Address sender, uint8_t ft)
{
return this->frameTypeCache[sender][ft];
}
bool GameState::checkLastFrameType(Mac48Address sender, uint8_t ft, uint16_t seqNo)
{
if (this->frameTypeCache[sender][ft] < seqNo)
return true;
return false;
}
void GameState::updateLastFrameType(Mac48Address sender, uint8_t ft, uint16_t seqNo)
{
this->frameTypeCache[sender][ft] = seqNo;
}
/*
* Unchanged counter - Counts the rounds without any changes
* - Get the current counter
* - Increment the counter by one
* - Reset the counter to zero
*/
uint32_t GameState::getUnchangedCounter()
{
return this->unchangedCounter;
}
void GameState::incrementUnchangedCounter()
{
if (!this->locked)
{
this->unchangedCounter++;
NS_LOG_DEBUG("\tUnchanged counter incremented: " << this->unchangedCounter);
}
}
void GameState::resetUnchangedCounter()
{
this->unchangedCounter = 0;
NS_LOG_DEBUG("\tUnchanged counter reset");
}
/*
* Parent handling
* - Get the current parent
* - Set a new parent
* - Get the node we want to connect to (contactedNode)
* - Set the node we want to connect to
*/
Ptr<EEBTPNode> GameState::getParent()
{
return this->parent;
}
void GameState::setParent(Ptr<EEBTPNode> p)
{
//For mutex mode: If we changed our parent (p != this->parent), our old parent is not waiting for us anymore
if (p != this->parent)
this->parentIsWaitingForLock = false;
this->parent = p;
}
Ptr<EEBTPNode> GameState::getContactedParent()
{
return this->contactedParent;
}
void GameState::setContactedParent(Ptr<EEBTPNode> p)
{
this->contactedParent = p;
}
/*
* LastParentStack
*/
bool GameState::hasLastParents()
{
return !this->lastParents.empty();
}
Ptr<EEBTPNode> GameState::popLastParent()
{
if (!this->lastParents.empty())
{
Ptr<EEBTPNode> node = *(this->lastParents.end() - 1);
node->resetConnCounter();
this->lastParents.erase(this->lastParents.end() - 1);
return node;
}
else
return 0;
}
Ptr<EEBTPNode> GameState::getLastParent()
{
if (!this->lastParents.empty())
return *(this->lastParents.end() - 1);
else
return 0;
}
void GameState::pushLastParent(Ptr<EEBTPNode> lastParent)
{
for (std::vector<Ptr<EEBTPNode>>::iterator it = this->lastParents.begin(); it != this->lastParents.end(); it++)
{
if ((*it) == lastParent || (*it)->getAddress() == lastParent->getAddress())
{
(*it)->incrementConnCounter();
this->lastParents.erase(it);
break;
}
}
this->lastParents.push_back(lastParent);
}
void GameState::clearLastParents()
{
for (Ptr<EEBTPNode> node : this->lastParents)
node->resetConnCounter();
this->lastParents.clear();
}
/*
* Cost of current connection
*/
double GameState::getCostOfCurrentConn()
{
if (this->parent != 0)
{
//Difference between the maxTxPower of our parent and the reach power to our parent
//If the difference is 0, we are (one of) the nodes that are the farthest away
return (DbmToW(this->parent->getHighestMaxTxPower()) - DbmToW(this->parent->getReachPower()));
}
return 0;
}
/*
* Calculated maximum transmission power
*/
double GameState::getHighestTxPower()
{
return this->highestTxPower;
}
double GameState::getSecondHighestTxPower()
{
return this->secondTxPower;
}
void GameState::findHighestTxPowers()
{
double maxTx = WToDbm(0);
double sMaxTx = WToDbm(0);
for (uint i = 0; i < this->childList.size(); i++)
{
Ptr<EEBTPNode> child = this->childList[i];
double reachPower = child->getReachPower();
//If this child has a higher reach power than the last highest one
if (reachPower > maxTx)
{
sMaxTx = maxTx;
maxTx = reachPower;
}
//else if we already have a highest child but this child is higher than our second highest but lower than our highest child
else if (sMaxTx < maxTx && reachPower > sMaxTx && reachPower < maxTx)
sMaxTx = reachPower;
}
this->highestTxPower = maxTx;
this->secondTxPower = sMaxTx;
}
/*
* NeighborList
*/
bool GameState::isNeighbor(Mac48Address n)
{
for (Ptr<EEBTPNode> p : this->neighbors)
{
if (p->getAddress() == n)
return true;
}
return false;
}
void GameState::addNeighbor(Mac48Address n)
{
this->neighbors.push_back(Create<EEBTPNode>(n, FLT_MIN));
}
Ptr<EEBTPNode> GameState::getNeighbor(Mac48Address n)
{
for (uint i = 0; i < this->neighbors.size(); i++)
{
Ptr<EEBTPNode> node = this->neighbors[i];
if (node->getAddress() == n)
return node;
}
return 0;
}
Ptr<EEBTPNode> GameState::getNeighbor(uint32_t index)
{
if (index < this->neighbors.size())
return this->neighbors[index];
else
return 0;
}
void GameState::removeNeighbor(Ptr<EEBTPNode> n)
{
uint i = 0;
for (; i < this->neighbors.size(); i++)
{
if (this->neighbors[i] == n)
break;
}
if (i < this->neighbors.size())
neighbors.erase(this->neighbors.begin() + i, this->neighbors.begin() + (i + 1));
}
uint32_t GameState::getNNeighbors()
{
return this->neighbors.size();
}
/*
* Searches in the local maintained neighbor list for the
* neighbor with the lowest cost of new connection who
* is NOT blacklisted.
*/
Ptr<EEBTPNode> GameState::getCheapestNeighbor()
{
double cost = FLT_MAX;
double threshold = DbmToW(1.0);
Ptr<EEBTPNode> neighbor = this->parent;
//Cost of current connection (connCost) is 0 if we are (one of) the nodes that are the farthest away
double connCost = this->getCostOfCurrentConn();
//Only if we are (one of) the nodes that are the farthest away, it is useful to switch (else no savings)
if (connCost <= 0.0001 && connCost >= -0.0001)
{
//If we have a parent and we are one of the nodes that are the farthest away, our cost are the energy saved by leaving our parent
if (this->parent != 0)
cost = DbmToW(this->parent->getHighestMaxTxPower()) - DbmToW(this->parent->getSecondHighestMaxTxPower());
NS_LOG_DEBUG("\tCurrent connection cost: " << WToDbm(cost));
for (uint i = 0; i < this->neighbors.size(); i++)
{
Ptr<EEBTPNode> node = this->neighbors[i];
//TODO: Find better way to submit maxAllowedTxPower
if (this->isBlacklisted(node->getAddress(), node->getParentAddress()))
{
NS_LOG_DEBUG("\t[" << node->getAddress() << "] is blacklisted!");
}
else if (this->isChild(node))
{
NS_LOG_DEBUG("\t[" << node->getAddress() << "] is a child of mine");
}
else if (node->getReachPower() > 23.0)
{
NS_LOG_DEBUG("\t[" << node->getAddress() << "] is out of my range: rP = " << node->getReachPower() << "dBm, noise = " << node->getNoise() << "dBm");
}
else if (node == this->parent)
{
NS_LOG_DEBUG("\t[" << node->getAddress() << "] is my parent");
}
else if (node->isOnPath(this->myAddress))
{
NS_LOG_DEBUG("\t[" << node->getAddress() << "] uses me to reach the source node");
}
else if (node->getConnCounter() > 5)
{
NS_LOG_DEBUG("\t[" << node->getAddress() << "]'s connection counter exceeds the maximum");
}
else
{
//Cost of the new connection is the difference between the node's highest tx power and the reach power to this node
double costOfNewConn = DbmToW(node->getReachPower()) - DbmToW(node->getHighestMaxTxPower());
costOfNewConn += threshold;
NS_LOG_DEBUG("\t[" << node->getAddress() << "] => " << WToDbm(costOfNewConn) << "dBm");
if (costOfNewConn <= cost)
{
neighbor = node;
cost = costOfNewConn;
}
}
}
}
return neighbor;
}
/*
* ChildList
*/
bool GameState::hasChilds()
{
return this->childList.size() != 0;
}
bool GameState::isChild(Mac48Address c)
{
for (Ptr<EEBTPNode> n : this->childList)
if (c == n->getAddress())
return true;
return false;
}
bool GameState::isChild(Ptr<EEBTPNode> c)
{
for (Ptr<EEBTPNode> n : this->childList)
if (c == n)
return true;
return false;
}
void GameState::addChild(Ptr<EEBTPNode> c)
{
if (!this->isChild(c))
this->childList.push_back(c);
this->findHighestTxPowers();
}
void GameState::removeChild(Ptr<EEBTPNode> c)
{
uint i = 0;
for (; i < this->childList.size(); i++)
{
if (this->childList[i] == c)
break;
}
if (i < this->childList.size())
childList.erase(this->childList.begin() + i, this->childList.begin() + (i + 1));
this->findHighestTxPowers();
}
int GameState::getNChilds()
{
return this->childList.size();
}
Ptr<EEBTPNode> GameState::getChild(int index)
{
return this->childList[index];
}
bool GameState::allChildsFinished()
{
bool allFinished = true;
for (uint i = 0; i < this->childList.size(); i++)
{
Ptr<EEBTPNode> child = this->childList[i];
if (!child->hasFinished())
{
allFinished = false;
break;
}
}
return allFinished;
}
/*
* Blacklist management
*/
bool GameState::isBlacklisted(Mac48Address node, Mac48Address parent)
{
return (this->blacklist[node] == parent) && parent != Mac48Address("00:00:00:00:00:00");
}
bool GameState::isBlacklisted(Ptr<EEBTPNode> node)
{
return this->isBlacklisted(node->getAddress(), node->getParentAddress());
}
void GameState::updateBlacklist(Ptr<EEBTPNode> node)
{
this->blacklist[node->getAddress()] = node->getParentAddress();
}
void GameState::resetBlacklist()
{
this->blacklist.clear();
for (Ptr<EEBTPNode> node : this->neighbors)
node->resetConnCounter();
}
/*
* This flag is used to increment the unchanged counter
* if we switched the parent but the actual needed transmission
* power remains unchanged
*/
bool GameState::doIncrAfterConfirm()
{
return this->doIncrementAfterConfirm;
}
void GameState::setDoIncrAfterConfirm(bool v)
{
this->doIncrementAfterConfirm = v;
}
/*
* Events
*/
Ptr<SendEvent> GameState::getNeighborDiscoveryEvent()
{
return this->neighborDiscoveryEvent;
}
void GameState::setNeighborDiscoveryEvent(Ptr<SendEvent> evt)
{
this->resetNeighborDiscoveryEvent();
this->neighborDiscoveryEvent = evt;
}
void GameState::resetNeighborDiscoveryEvent()
{
if (this->neighborDiscoveryEvent != 0)
this->neighborDiscoveryEvent->Cancel();
this->neighborDiscoveryEvent = 0;
}
/*
* Mutex
*/
bool GameState::isLocked()
{
return this->locked;
}
bool GameState::isLocked(Ptr<EEBTPNode> node)
{
for (std::vector<Ptr<EEBTPNode>>::iterator it = this->locks.begin(); it != this->locks.end(); ++it)
{
if ((*it)->getAddress() == node->getAddress())
return true;
}
return false;
}
void GameState::lock(bool l)
{
this->locked = l;
}
void GameState::lock(Ptr<EEBTPNode> node, bool l)
{
if (l)
{
if (!this->isLocked(node))
this->locks.push_back(node);
}
else
{
uint i = 0;
for (std::vector<Ptr<EEBTPNode>>::iterator it = this->locks.begin(); it != this->locks.end(); ++it)
{
if ((*it)->getAddress() == node->getAddress())
break;
i++;
}
if (i < this->locks.size())
this->locks.erase(this->locks.begin() + i);
}
}
int GameState::getNChildsLocked()
{
return this->locks.size();
}
void GameState::resetChildLocks()
{
this->locks.clear();
}
Mac48Address GameState::getLockedBy()
{
return this->lockedByNode;
}
void GameState::setLockedBy(Mac48Address addr)
{
this->lockedByNode = addr;
}
bool GameState::isParentWaitingForLock()
{
return this->parentIsWaitingForLock;
}
void GameState::setParentWaitingForLock(bool b)
{
this->parentIsWaitingForLock = b;
}
Ptr<EEBTPNode> GameState::getParentWaitingLockOriginator()
{
return this->lockOriginator;
}
void GameState::setParentWaitingLockOriginator(Ptr<EEBTPNode> originator)
{
this->lockOriginator = originator;
}
bool GameState::isNewParentWaitingForLock()
{
return this->newParentIsWaitingForLock;
}
void GameState::setNewParentWaitingForLock(bool b)
{
this->newParentIsWaitingForLock = b;
}
Ptr<EEBTPNode> GameState::getNewParentWaitingLockOriginator()
{
return this->newParentLockOriginator;
}
void GameState::setNewParentWaitingLockOriginator(Ptr<EEBTPNode> originator)
{
this->newParentLockOriginator = originator;
}
/*
* Application data handler
*/
Ptr<ApplicationDataHandler> GameState::getApplicationDataHandler()
{
return this->adh;
}
uint32_t GameState::getRejectionCounter()
{
return this->rejectionCounter;
}
void GameState::setRejectionCounter(uint32_t rj)
{
this->rejectionCounter = rj;
}
void GameState::incrementRejectionCounter()
{
this->rejectionCounter++;
}
void GameState::resetRejectionCounter()
{
this->rejectionCounter = 0;
}
/*
* Path-To-Source
*/
Time GameState::getLastParentUpdate()
{
return this->lastParentUpdate;
}
void GameState::setLastParentUpdate(Time t)
{
this->lastParentUpdate = t;
}
uint32_t GameState::getParentUnchangedCounter()
{
return this->parentUnchangedCounter;
}
void GameState::resetParentUnchangedCounter()
{
this->parentUnchangedCounter = 0;
}
void GameState::incrementParentUnchangedCounter()
{
this->parentUnchangedCounter++;
}
Ptr<ParentPathCheckEvent> GameState::getPPCEvent()
{
return this->ppcEvent;
}
void GameState::setPPCEvent(Ptr<ParentPathCheckEvent> e)
{
this->ppcEvent = e;
}
bool GameState::hadEmptyPathOnConnect()
{
return this->emptyPathOnConnect;
}
void GameState::setEmptyPathOnConnect(bool b)
{
this->emptyPathOnConnect = b;
}
}