public override void MacTask(Spectrum spectrum, int currentRegion) { if (this.IsMacPending) { this.runMac(spectrum, currentRegion); this.IsMacPending = false; this.IsTxPending = true; } }
private int getBinaryExponentialBackoff(Spectrum spectrum, int currentRegion) { int maxNumber = (int)Math.Pow(2, this.Retransmissions); if (maxNumber > spectrum.TotalRegions) { maxNumber = spectrum.TotalRegions; } int access = this.getRandomAccess(maxNumber, currentRegion); return access; }
private int getSalohaAccess(Spectrum spectrum, int currentRegion) { int access = this.getRandomAccess(spectrum, currentRegion); return access; }
private int getRandomAccess(Spectrum spectrum, int initialNumber = 1) { int access; Random randomNumber = new Random(int.Parse(Guid.NewGuid().ToString().Substring(0, 8), System.Globalization.NumberStyles.HexNumber)); access = randomNumber.Next(initialNumber, spectrum.TotalRegions + 1); return access; }
protected virtual void runMac(Spectrum spectrum, int currentRegion = 1) { int access = -1; if (this.Mac == MacTypes.RANDOM) { access = this.getRandomAccess(spectrum); } else if (this.Mac == MacTypes.ID) { access = this.Id; } else if (this.Mac == MacTypes.S_ALOHA) { access = this.getSalohaAccess(spectrum, currentRegion); } else if (this.Mac == MacTypes.S_ALOHA_BEB) { access = this.getBinaryExponentialBackoff(spectrum, currentRegion); } this.Access = access; }
public void RxTask(Spectrum spectrum, int currentRegion) { this.listen(spectrum, currentRegion); }
private int getTdmaGtAccess(Spectrum spectrum) { int access = -1; int indexT = 0; int indexF = 0; double maxValue = 0; int vLimit = this.EstimationMatrix.GetUpperBound(1); int hLimit = this.EstimationMatrix.GetUpperBound(0); for (int idxF = 0; idxF <= vLimit; idxF++) { for (int idxT = 0; idxT <= hLimit; idxT++) { if (this.EstimationMatrix[idxT, idxF] > maxValue) { maxValue = this.EstimationMatrix[idxT, idxF]; indexT = idxT; indexF = idxF; } } } access = this.getAccessFromIndexes(indexT, indexF); return access; }
protected override void listen(Spectrum spectrum, int currentRegion) { // complementary exploration if (this.ExplorationRegions != null) { if (this.ExplorationRegions.Contains(currentRegion)) { this.Explore(spectrum, currentRegion); } } base.listen(spectrum, currentRegion); }
protected override void listen(Spectrum spectrum, int currentRegion) { if (this.IsRxPending) { Message rxMessage = spectrum.Listen(currentRegion); if (rxMessage != null && rxMessage.Content != null) { this.processMessage(rxMessage); this.IsRxPending = true; //RR-Aloha always listen to messages to process the information frame } } }
private int getSalohaAccess(Spectrum spectrum, int currentRegion) { int access = this.getRandomAccess(spectrum, currentRegion); return(access); }
protected override void runMac(Spectrum spectrum, int currentRegion = 1) { this.Access = this.getTdmaGtAccess(spectrum); }
public override TXRESULT TryTx(Spectrum spectrum) { TXRESULT txResult; if (this.Access == -1) { txResult = TXRESULT.NOTX; } else { bool txCheckingResult = spectrum.CheckAndSetOccupancy(this.Access); if (txCheckingResult) { spectrum.SetMessage(this.generateMessage(), this.Access); txResult = TXRESULT.TXOK; if (this.Access == this.lastAcess) { this.applyBonusAndPenalties(BonusAndPenalties.RHO); } else { this.applyBonusAndPenalties(BonusAndPenalties.SIGMA); } } else { spectrum.SetCollision(this.Access); txResult = TXRESULT.COLLISION; if (this.Access == this.lastAcess) { this.applyBonusAndPenalties(BonusAndPenalties.ALFA); } else { this.applyBonusAndPenalties(BonusAndPenalties.BETA); } } } this.lastAcess = Access; return txResult; }
protected virtual void listen(Spectrum spectrum, int currentRegion) { if (this.IsRxPending) { Message rxMessage = spectrum.Listen(currentRegion); if (rxMessage != null && rxMessage.Content != null) { if (rxMessage.Destination == this.Id || rxMessage.Destination == 0) { this.processMessage(rxMessage); spectrum.ClearMessage(currentRegion); this.IsRxPending = false; } } } }
protected override void runMac(Spectrum spectrum, int currentRegion = 1) { int access = -1; access = this.getRrAlohaAccess(); this.Access = access; }
private void Explore(Spectrum spectrum, int region) { if (spectrum.CheckOccupancy(region)) //busy region { this.applyBonusAndPenalties(BonusAndPenalties.BETA, ExplorationType.EXPLORATION, region); } else //free region { this.applyBonusAndPenalties(BonusAndPenalties.SIGMA, ExplorationType.EXPLORATION, region); } this.updateSummatory(); }
public virtual TXRESULT TryTx(Spectrum spectrum) { TXRESULT txResult; if (this.Access <= 0) { txResult = TXRESULT.NOTX; } else { if (spectrum.CheckAndSetOccupancy(this.Access)) { spectrum.SetMessage(this.generateMessage(), this.Access); txResult = TXRESULT.TXOK; } else { spectrum.SetCollision(this.Access); txResult = TXRESULT.COLLISION; } } return txResult; }
public override void MacTask(Spectrum spectrum, int currentRegion) { if (this.IsMacPending) { this.runMac(spectrum, currentRegion); this.IsMacPending = false; this.IsTxPending = true; //Calculation of the regions to explore int numberOfExplorations = this.GetNumberOfExplorations(); this.ExplorationHistory.RemoveAt(0); this.ExplorationHistory.Add(numberOfExplorations); this.FillExplorations(numberOfExplorations); } }