Beispiel #1
0
        static void findFailedLinksWithPacket(DVP dvp, bool result)
        {
            var packet = new SimplePacket
            {
                SrcIp = new Ip {
                    Value = 6
                },
                DstIp = new Ip {
                    Value = 1
                },
            };

            findLinks(dvp, result, packet);
            dvp.cleanConstraints();
        }
Beispiel #2
0
        static void evaluateReachability(DVP dvp, List <Tuple <int, int> > failedLinks = null)
        {
            if (failedLinks == null)
            {
                failedLinks = new List <Tuple <int, int> >();
            }

            ZenFunction <SimplePacket, IList <Tuple <int, int> >, bool> f = Function <SimplePacket, IList <Tuple <int, int> >, bool>(dvp.Forward);

            f.Compile();

            Console.WriteLine("Evaluating output");
            var correct_input = new SimplePacket
            {
                SrcIp = new Ip {
                    Value = 1
                },
                DstIp = new Ip {
                    Value = 2
                },
            };

            var wrong_input = new SimplePacket
            {
                SrcIp = new Ip {
                    Value = 0
                },
                DstIp = new Ip {
                    Value = 0
                },
            };

            Console.WriteLine("Evaluating correct input: \t" + correct_input);
            var output = f.Evaluate(correct_input, failedLinks);

            Console.WriteLine("\t Reachable? " + output);

            Console.WriteLine("Evaluating wrong input: \t" + wrong_input);
            output = f.Evaluate(wrong_input, failedLinks);
            Console.WriteLine("\t Reachable? " + output);
            Console.WriteLine();
        }
Beispiel #3
0
        static void findLinks(DVP dvp, bool desired_result, SimplePacket packet)
        {
            Console.WriteLine("findLinks");

            ZenFunction <SimplePacket, IList <Tuple <int, int> >, bool> f = Function <SimplePacket, IList <Tuple <int, int> >, bool>(dvp.Forward);

            f.Compile();

            // Console.WriteLine("Using FindAll");
            // Console.WriteLine("Number of packets that cannot be delivered in the network:");
            var input = f.FindAll((pkt, failed_links, result) => And(
                                      And(
                                          And(
                                              And(
                                                  pkt.GetDstIp().GetField <Ip, uint>("Value") == packet.DstIp.Value,
                                                  pkt.GetSrcIp().GetField <Ip, uint>("Value") == packet.SrcIp.Value
                                                  ),
                                              pkt.GetDstIp() != pkt.GetSrcIp()),
                                          result == desired_result),
                                      // For DVP, no route requires more then two links to fail (no multiple path routing)
                                      // Therefore, we limit length to 1 here
                                      failed_links.Length() == 1));

            Console.WriteLine("\tCount:\t" + input.Count());
            //Console.WriteLine();
            //Console.WriteLine(input);

            if (input.Count() != 0)
            {
                Console.WriteLine("\tPrinting inputs:");
                foreach (var x in input)
                {
                    Console.Write("\t\t" + x.Item1 + " with List [");
                    foreach (var i in x.Item2)
                    {
                        Console.Write(i + ", ");
                    }
                    Console.WriteLine("]");
                }
            }
        }