[31] | 1 | /************************************************************************************ |
---|
| 2 | * Copyright (C) 2008 by Politehnica University of Bucharest and Rutgers University |
---|
| 3 | * All rights reserved. |
---|
| 4 | * Refer to LICENSE for terms and conditions of use. |
---|
| 5 | ***********************************************************************************/ |
---|
| 6 | //Petroaca - shadowing propagation model class ; it receives the parameters from the transmitter and it calculates the received power |
---|
| 7 | package vnsim.network.propagation; |
---|
| 8 | |
---|
| 9 | |
---|
| 10 | import java.util.*; |
---|
| 11 | |
---|
| 12 | import vnsim.map.object.Globals; |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | public class Shadowing |
---|
| 16 | { |
---|
| 17 | //distance at which the reference power received is calcualted |
---|
| 18 | private static double referenceDistance=Globals.REFERENCE_DISTANCE; |
---|
| 19 | |
---|
| 20 | private static double pathLossExp=Globals.PATH_LOSS_EXPONENT_URBAN; |
---|
| 21 | |
---|
| 22 | private static double shadowingDeviation=Globals.SHADOWING_DEVIATION; |
---|
| 23 | |
---|
| 24 | private static long seed=Globals.RANDOM_SEED; |
---|
| 25 | |
---|
| 26 | private static Random randVar=new Random(seed); |
---|
| 27 | |
---|
| 28 | //returns the received power of the frame in DBm |
---|
| 29 | public static double getPr(double Pt,double R,boolean withObstruction) |
---|
| 30 | { |
---|
| 31 | if(Pt<=0.0 || R<=0.0) |
---|
| 32 | return -1; |
---|
| 33 | |
---|
| 34 | if(withObstruction) |
---|
| 35 | pathLossExp=Globals.PATH_LOSS_EXPONENT_URBAN; |
---|
| 36 | else |
---|
| 37 | pathLossExp=Globals.PATH_LOSS_EXPONENT_FREE; |
---|
| 38 | |
---|
| 39 | //calculate the receiving power at reference distance |
---|
| 40 | double Pr0=FreeSpace.getPr(Pt,referenceDistance); |
---|
| 41 | |
---|
| 42 | //calculate average power loss predicted by path loss model |
---|
| 43 | double averageP= -10.0 * pathLossExp * Math.log10(R/referenceDistance); |
---|
| 44 | |
---|
| 45 | //get the power loss by adding a random variable |
---|
| 46 | double powerLoss= averageP + randVar.nextDouble()*shadowingDeviation; |
---|
| 47 | |
---|
| 48 | //calculate the received power |
---|
| 49 | double Pr= Pr0 * Math.pow(10.0, powerLoss/10.0); |
---|
| 50 | |
---|
| 51 | return Pr; |
---|
| 52 | |
---|
| 53 | } |
---|
| 54 | } |
---|