コード例 #1
0
ファイル: VehicleTdmaGt.cs プロジェクト: AkashBaidya/SIMITS
 public override void MacTask(Spectrum spectrum, int currentRegion)
 {
     if (this.IsMacPending)
     {
         this.runMac(spectrum, currentRegion);
         this.IsMacPending = false;
         this.IsTxPending = true;
     }
 }
コード例 #2
0
ファイル: Vehicle.cs プロジェクト: AkashBaidya/SIMITS
 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;
 }
コード例 #3
0
ファイル: Vehicle.cs プロジェクト: AkashBaidya/SIMITS
 private int getSalohaAccess(Spectrum spectrum, int currentRegion)
 {
     int access = this.getRandomAccess(spectrum, currentRegion);
     return access;
 }
コード例 #4
0
ファイル: Vehicle.cs プロジェクト: AkashBaidya/SIMITS
 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;
 }
コード例 #5
0
ファイル: Vehicle.cs プロジェクト: AkashBaidya/SIMITS
        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;

        }
コード例 #6
0
ファイル: Vehicle.cs プロジェクト: AkashBaidya/SIMITS
 public void RxTask(Spectrum spectrum, int currentRegion)
 {
     this.listen(spectrum, currentRegion);
 }
コード例 #7
0
ファイル: VehicleTdmaGt.cs プロジェクト: AkashBaidya/SIMITS
        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;
        }
コード例 #8
0
ファイル: VehicleNccma.cs プロジェクト: AkashBaidya/SIMITS
        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);

        }
コード例 #9
0
ファイル: VehicleRrAloha.cs プロジェクト: AkashBaidya/SIMITS
 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
         }
     }
 }
コード例 #10
0
ファイル: Vehicle.cs プロジェクト: AkashBaidya/SIMITS
        private int getSalohaAccess(Spectrum spectrum, int currentRegion)
        {
            int access = this.getRandomAccess(spectrum, currentRegion);

            return(access);
        }
コード例 #11
0
ファイル: Vehicle.cs プロジェクト: AkashBaidya/SIMITS
 public void RxTask(Spectrum spectrum, int currentRegion)
 {
     this.listen(spectrum, currentRegion);
 }
コード例 #12
0
 protected override void runMac(Spectrum spectrum, int currentRegion = 1)
 {
     this.Access = this.getTdmaGtAccess(spectrum);
 }
コード例 #13
0
ファイル: VehicleTdmaGt.cs プロジェクト: AkashBaidya/SIMITS
 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;
 }
コード例 #14
0
ファイル: Vehicle.cs プロジェクト: AkashBaidya/SIMITS
 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;
             }
         }
     }
 }
コード例 #15
0
ファイル: VehicleRrAloha.cs プロジェクト: AkashBaidya/SIMITS
 protected override void runMac(Spectrum spectrum, int currentRegion = 1)
 {
     int access = -1;
     access = this.getRrAlohaAccess();
     this.Access = access;
 }
コード例 #16
0
ファイル: VehicleNccma.cs プロジェクト: AkashBaidya/SIMITS
 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();
 }
コード例 #17
0
ファイル: Vehicle.cs プロジェクト: AkashBaidya/SIMITS
 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;
 }
コード例 #18
0
ファイル: VehicleNccma.cs プロジェクト: AkashBaidya/SIMITS
        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);
            }
        }
コード例 #19
0
ファイル: VehicleTdmaGt.cs プロジェクト: AkashBaidya/SIMITS
 protected override void runMac(Spectrum spectrum, int currentRegion = 1)
 {
     this.Access = this.getTdmaGtAccess(spectrum);
 }