//===================================================================== public double getRetransmitionRate() { if (MACOfAnotherPeer == null) { return(-1); } try { RFpeer tempPeer = (RFpeer)_RFpeers[MACOfAnotherPeer]; short Recounter = tempPeer.RetransmitionCounter; long counter = tempPeer.TransmitCounter; if (counter == 0) { return(0); } double ret = 100 * Recounter / counter; if (ret > 100) { ret = 100; } return(ret); } catch (Exception) { //MessageBox.Show("getRetransmitionRate" + ex.Message); } return(-1); }
//[MethodImpl(MethodImplOptions.Synchronized)] //===================================================================== /// <summary> /// Update RF decie peers in this peer /// </summary> public void UpdateRFPeers() { if (Medium._objects == null) { return; } try { double dist = 0; foreach (RFDevice devi in Medium._objects) { if (devi.getMACAddress().Equals(this.getMACAddress())) { continue; } dist = GetSTADist(this.x, this.y, devi.x, devi.y); if (dist <= Medium.ListenDistance * 2) { RFpeer _peer = new RFpeer() { Distance = dist, BSSID = devi.BSSID, MAC = devi.getMACAddress(), Freq = devi.Freq, Stand80211 = devi.Stand80211, BandWidth = GetBestIntersectionBandwith(devi.BandWithSupport), // devi.BandWidth, Channel = devi.getOperateChannel(), RSSI = GetRSSI(devi.x, devi.y), isPassive = devi.Passive, }; if (_RFpeers.Contains(_peer.MAC)) { _RFpeers[_peer.MAC] = _peer; } else { _RFpeers.Add(_peer.MAC, _peer); } } } } catch (Exception ex) { AddToLog("Update RFpeers :" + ex.Message); } }
//********************************************************************* /// <summary> /// /// </summary> /// <param name="MAC"></param> /// <returns></returns> protected short GetTXRate(string MAC) { short retVale = 0; if (!_RFpeers.Contains(MAC)) { UpdateRFPeers(); } if (_RFpeers.Contains(MAC)) { RFpeer _peer = (RFpeer)_RFpeers[MAC]; if (_peer.Freq == Frequency._5200GHz) { if (_peer.BandWidth == Bandwidth._20MHz) { retVale = getRateOn5_2RSSI20M(_peer.RSSI); } else if (_peer.BandWidth == Bandwidth._40Mhz) { retVale = getRateOn5_2RSSI40M(_peer.RSSI); } } else if (_peer.Freq == Frequency._2400GHz) { if (_peer.BandWidth == Bandwidth._20MHz) { retVale = getRateOn2_4RSSI20M(_peer.RSSI); } else if (_peer.BandWidth == Bandwidth._40Mhz) { retVale = getRateOn2_4RSSI40M(_peer.RSSI); } } //if (_peer.BandWidth == Bandwidth._40Mhz) // retVale*=2; } return(retVale); }
//===================================================================== public double GetNoiseOnSameChannel() { //short devisesCounter = 0; //UpdateRFPeers(); int points = 0; double val = 0; foreach (DictionaryEntry device in _RFpeers) { RFpeer dev = (RFpeer)((DictionaryEntry)device).Value; if (dev.Channel == getOperateChannel()) { // formula for wolfram: plot [y= -15*log_2(x),{y,16,-95},{x,60,0}] // http://www.wolframalpha.com/input/?i=plot+%5By%3D+-15*log_2%28x%29%2C%7By%2C16%2C-95%7D%2C%7Bx%2C60%2C0%7D%5D+ val += Medium.ListenDistance - dev.Distance; points++; } } return(val / points); }
//===================================================================== /// <summary> /// Independ on RSSI return Noize level /// </summary> /// <param name="MAC">Macc address</param> /// <returns>Return NOIZE level</returns> protected double GetNoiseRSSI(string MAC) { double retVale = 0; if (!_RFpeers.Contains(MAC)) { UpdateRFPeers(); } if (_RFpeers.Contains(MAC)) { RFpeer _peer = (RFpeer)_RFpeers[MAC]; //TODO :: Need optimize // formula for wolfram: plot [y=x^2 +150x +(75^2) ,{y,0,100},{x,-60,-100}] // http://www.wolframalpha.com/input/?i=plot+%5By%3Dx%5E2+%2B150x+%2B%2875%5E2%29+%2C%7By%2C0%2C100%7D%2C%7Bx%2C-60%2C-100%7D%5D+ double NoiseRssi = Math.Pow(_peer.RSSI, 2) + 150 * _peer.RSSI + Math.Pow(75, 2); if (_peer.RSSI <= -75) { if (NoiseRssi > 100) { retVale = 100; } else { retVale = NoiseRssi; } } else { retVale = 0; } } guiNoiseRssi = retVale; return(retVale); }
//[MethodImpl(MethodImplOptions.Synchronized)] //===================================================================== /// <summary> /// Update RF decie peers in this peer /// </summary> public void UpdateRFPeers() { if (Medium._objects == null) return; try { double dist = 0; foreach (RFDevice devi in Medium._objects) { if(devi.getMACAddress().Equals(this.getMACAddress())) continue; dist = GetSTADist(this.x, this.y, devi.x, devi.y); if (dist <= Medium.ListenDistance*2) { RFpeer _peer = new RFpeer() { Distance = dist, BSSID = devi.BSSID, MAC = devi.getMACAddress(), Freq = devi.Freq, Stand80211 = devi.Stand80211, BandWidth = GetBestIntersectionBandwith(devi.BandWithSupport),// devi.BandWidth, Channel = devi.getOperateChannel(), RSSI = GetRSSI(devi.x, devi.y), isPassive = devi.Passive, }; if (_RFpeers.Contains(_peer.MAC)) _RFpeers[_peer.MAC] = _peer; else _RFpeers.Add(_peer.MAC, _peer); } } } catch (Exception ex) { AddToLog("Update RFpeers :" + ex.Message); } }