Example #1
0
        public static void SetRangeWirelessFunction(this WirelessMedium wirelesMedium, int range = 0)
        {
            var function = new RangeMediumFunction();

            function.Range = range;
            wirelesMedium.SetMediumFunction(function);
        }
        public static void SetLossRangeWirelessFunction(this WirelessMedium wirelessMedium, int lossRange = 0, float txRatio = 0, float rxRatio = 0)
        {
            var function = new RangeLossMediumFunction();

            function.LossRange = lossRange;
            function.TxRatio   = txRatio;
            function.RxRatio   = rxRatio;
            wirelessMedium.SetMediumFunction(function);
        }
        public static void SetPacketHookFromScript(this WirelessMedium medium, IRadio radio, string script)
        {
            if (string.IsNullOrEmpty(script))
            {
                throw new RecoverableException("Cannot initialize packet interception hook because no script was provided");
            }
            var runner = new PacketInterceptionPythonEngine(radio, script: script);

            medium.AttachHookToRadio(radio, runner.Hook);
        }
        public static void SetPacketHookFromFile(this WirelessMedium medium, IRadio radio, string filename)
        {
            if (string.IsNullOrEmpty(filename))
            {
                throw new RecoverableException("Cannot initialize packet interception hook because no file was provided");
            }
            if (!File.Exists(filename))
            {
                throw new RecoverableException($"Cannot create the hook because file {filename} does not exist");
            }
            var runner = new PacketInterceptionPythonEngine(radio, filename: filename);

            medium.AttachHookToRadio(radio, runner.Hook);
        }
        public static void SetPacketHookFromFile(this WirelessMedium medium, IRadio radio, ReadFilePath filename)
        {
            var runner = new PacketInterceptionPythonEngine(radio, filename: filename);

            medium.AttachHookToRadio(radio, runner.Hook);
        }