public static TimedReport FindTimedReport(Link_Param_Abs_Type param, int interval, List<TimedReport> list) { foreach (TimedReport tr in list) { if (tr.ParamType == param && tr.interval == interval) return tr; } return null; }
public static TimedReport FindTimedReport(Link_Param_Abs_Type param, int interval, List <TimedReport> list) { foreach (TimedReport tr in list) { if (tr.ParamType == param && tr.interval == interval) { return(tr); } } return(null); }
public static ushort GetValueForParam(Link_Param_Abs_Type type) { switch (type) { case Link_Param_Abs_Type.P80211_RSSI: return(Link_Param_802_11.GetRSSI_0); case Link_Param_Abs_Type.GEN_Sig_Strenth: return(Link_Param_Gen.SignalStrength_1); case Link_Param_Abs_Type.GEN_Data_Rate: return(Link_Param_Gen.DataRate_0); case Link_Param_Abs_Type.GEN_Packet_Error_Rate: return(Link_Param_Gen.PacketErrorRate_4); default: throw new NotImplementedException(); } }
public static void PeriodicReport(Object stateInfo) { Console.WriteLine("Periodic report called"); Link_Param_Abs_Type lpat = (Link_Param_Abs_Type)stateInfo; Console.WriteLine("Reporting param type " + lpat); switch (lpat) { case Link_Param_Abs_Type.GEN_Sig_Strenth: Program.toMihf.Send(MessageBuilders.Link_Parameters_Report_Indication_MsgBuilder( new ID(new OctetString(GenericInfo.myID)), new ID(new OctetString(GenericInfo.mihfID)), GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.Dot11Bssid, GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.dot11Ssid.SSID, Link_Param_Abs_Type.GEN_Sig_Strenth, Link_Param_Gen.SignalStrength_1).ByteValue); break; case Link_Param_Abs_Type.GEN_Data_Rate: Program.toMihf.Send(MessageBuilders.Link_Parameters_Report_Indication_MsgBuilder( new ID(new OctetString(GenericInfo.myID)), new ID(new OctetString(GenericInfo.mihfID)), GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.Dot11Bssid, GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.dot11Ssid.SSID, Link_Param_Abs_Type.GEN_Data_Rate, Link_Param_Gen.DataRate_0).ByteValue); break; case Link_Param_Abs_Type.GEN_Packet_Error_Rate: Program.toMihf.Send(MessageBuilders.Link_Parameters_Report_Indication_MsgBuilder( new ID(new OctetString(GenericInfo.myID)), new ID(new OctetString(GenericInfo.mihfID)), GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.Dot11Bssid, GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.dot11Ssid.SSID, Link_Param_Abs_Type.GEN_Packet_Error_Rate, Link_Param_Gen.PacketErrorRate_4).ByteValue); break; //TODO other params } }
public static void CheckThresholds(Link_Param_Abs_Type type, int value) { foreach (ActiveThreshold a in OneShotThresholds) { if (a.Param_Type == type) { if (a.CheckIfCrossed(value)) { Program.toMihf.Send(MessageBuilders.Link_Parameters_Report_Indication_MsgBuilder( new ID(new OctetString(GenericInfo.myID)), new ID(new OctetString(GenericInfo.mihfID)), GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.Dot11Bssid, GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.dot11Ssid.SSID, type, GenericInfo.GetValueForParam(type)).ByteValue); OneShotThresholds.Remove(a); } } } foreach (ActiveThreshold a in ActiveThresholds) { if (a.Param_Type == type) { if (a.CheckIfCrossed(value)) { Program.toMihf.Send(MessageBuilders.Link_Parameters_Report_Indication_MsgBuilder( new ID(new OctetString(GenericInfo.myID)), new ID(new OctetString(GenericInfo.mihfID)), GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.Dot11Bssid, GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.dot11Ssid.SSID, type, GenericInfo.GetValueForParam(type)).ByteValue); } } } }
public static ushort GetValueForParam(Link_Param_Abs_Type type) { switch (type) { case Link_Param_Abs_Type.P80211_RSSI: return Link_Param_802_11.GetRSSI_0; case Link_Param_Abs_Type.GEN_Sig_Strenth: return Link_Param_Gen.SignalStrength_1; case Link_Param_Abs_Type.GEN_Data_Rate: return Link_Param_Gen.DataRate_0; case Link_Param_Abs_Type.GEN_Packet_Error_Rate: return Link_Param_Gen.PacketErrorRate_4; default: throw new NotImplementedException(); } }
public TimedReport(Link_Param_Abs_Type paramtype, int interval) { this.ParamType = paramtype; this.Timer = new Timer(Reports.PeriodicReport, paramtype, interval, interval); this.Interval = interval; }
public ActiveThreshold(Threshold t, Link_Param_Abs_Type lpat) { this.Threshold = t; this.Param_Type = lpat; }
/// <summary> /// Returns an exact Link_Param_Type (integer-value-wise) according to a Link_Param_Abs_Type. /// </summary> /// <param name="lpat">The Link_Param_Type from the global enum.</param> /// <returns>A Link_ParamType which corresponds to the Link_Param_Abs_Type.</returns> public static Link_Param_Type FromAbsType(Link_Param_Abs_Type lpat) { switch (lpat) { case Link_Param_Abs_Type.GEN_Data_Rate: return new Link_Param_Type(Link_Param_Types.LINK_PARAM_GEN, (ushort)LINK_PARAM_GEN_SUBTYPES.DataRate); case Link_Param_Abs_Type.GEN_Sig_Strenth: return new Link_Param_Type(Link_Param_Types.LINK_PARAM_GEN, (ushort)LINK_PARAM_GEN_SUBTYPES.SignalStrength); case Link_Param_Abs_Type.GEN_Packet_Error_Rate: return new Link_Param_Type(Link_Param_Types.LINK_PARAM_GEN, (ushort)LINK_PARAM_GEN_SUBTYPES.PacketErrorRate); default: throw new NotImplementedException(); } }
public static void CheckThresholds(Link_Param_Abs_Type type, int value) { foreach (ActiveThreshold a in OneShotThresholds) { if (a.Param_Type==type) if (a.CheckIfCrossed(value)) { Program.toMihf.Send(MessageBuilders.Link_Parameters_Report_Indication_MsgBuilder( new ID(new OctetString(GenericInfo.myID)), new ID(new OctetString(GenericInfo.mihfID)), GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.Dot11Bssid, GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.dot11Ssid.SSID, type, GenericInfo.GetValueForParam(type)).ByteValue); OneShotThresholds.Remove(a); } } foreach (ActiveThreshold a in ActiveThresholds) { if (a.Param_Type == type) if (a.CheckIfCrossed(value)) Program.toMihf.Send(MessageBuilders.Link_Parameters_Report_Indication_MsgBuilder( new ID(new OctetString(GenericInfo.myID)), new ID(new OctetString(GenericInfo.mihfID)), GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.Dot11Bssid, GenericInfo.WlanInterfaceInstance.CurrentConnection.wlanAssociationAttributes.dot11Ssid.SSID, type, GenericInfo.GetValueForParam(type)).ByteValue); } }
/// <summary> /// Generates a Link_Parameters_Report.Indication message, reporting the specified value of the specified parameter type. /// </summary> /// <param name="src">The source MIHF ID</param> /// <param name="dst">The destination MIHF ID</param> /// <param name="APMac">The Physical Address of the Access Point (corresponding to the active link)</param> /// <param name="networkSSID">The SSID for the active link</param> /// <param name="paramType">The type of parameter to report</param> /// <param name="value">The value of the parameter</param> /// <returns>A Link_Parameters_Report.Indication message ready to be sent.</returns> public static Message Link_Parameters_Report_Indication_MsgBuilder(ID src, ID dst, PhysicalAddress APMac, byte[] networkSSID, Link_Param_Abs_Type paramType, ushort value ) { Message m = new Message(); m.MIHHeader = new MIHHeader(); m.MIHHeader.MID = new MessageID(MessageID.ServiceIdentifier.EVENT_SERVICE, MessageID.OperationCode.INDICATION, 5); m.MIHHeader.VersionValue = 1; Link_Tuple_Id linkIdentifier = new Link_Tuple_Id( new Link_Id(Link_Type.Wireless_IEEE80211, new Link_Addr(Link_Addr.Address_Type.MAC_ADDR, Utilities.PhysicalAddressToString(APMac))), new Link_Addr(Link_Addr.Address_Type.OTHER_L2_ADDR, new String(Encoding.ASCII.GetChars(networkSSID)))); Link_Param_Rpt lpr = new Link_Param_Rpt( new Link_Param( Link_Param_Type.FromAbsType(paramType), (ushort)value, 0 /*TODO 0=LinkParamVal (choice)*/), null); List<byte[]> lprList = new List<byte[]>(); lprList.Add(lpr.ByteValue); m.Payload = new Payload(src, dst, Serialization.SerializeToTLV(TLV_VALUES.TLV_LINK_IDENTIFIER, linkIdentifier.ByteValue), Serialization.SerializeToTLV(TLV_VALUES.TLV_LINK_PARAM_REPORT_LIST, Serialization.EncodingList(lprList.ToArray()))); m.MIHHeader.PayloadLength = (ushort)m.Payload.PayloadValue.Length; return m; }