Exemple #1
0
 static void findPacketsWithIntermediateNode(DVP dvp, bool result, Ip intermediateNodeIp)
 {
     // Zen will only check  paths w/o intermediateNode
     dvp.intermediateNode = intermediateNodeIp;
     findPackets(dvp, result);
     dvp.cleanConstraints();
 }
Exemple #2
0
 static void findPacketsWithCost(DVP dvp, bool result, int maxCost)
 {
     // Zen will only check paths under the maxCost
     dvp.maxCost = maxCost;
     findPackets(dvp, result);
     dvp.cleanConstraints();
 }
Exemple #3
0
        static void oneHopReachability(DVP dvp)
        {
            // 1. Evaluate
            Ip srcAddr = new Ip
            {
                Value = 1
            };

            Ip dstAddr = new Ip
            {
                Value = 2
            };

            ZenFunction <Ip, Ip, bool> f = Function <Ip, Ip, bool>(dvp.OneHopForward);
            var output = f.Evaluate(srcAddr, dstAddr);

            Console.WriteLine(output);

            // 2. Find
            var input = f.Find((src, dst, result) => And(And(And(src.GetField <Ip, uint>("Value") < 7,
                                                                 dst.GetField <Ip, uint>("Value") < 7), result == False()), src != dst));

            Console.WriteLine("Using powerful Zen Find!!!");

            Console.WriteLine(input);
            Console.WriteLine("printing single value");
            Console.WriteLine(input.Value);
        }
Exemple #4
0
        static void findPacketsWithFailedLinks(DVP dvp, bool result)
        {
            var failedLinks = new List <Tuple <int, int> >();

            failedLinks.Add(new Tuple <int, int>(0, 1));
            failedLinks.Add(new Tuple <int, int>(5, 6));

            findPackets(dvp, result, failedLinks);
            dvp.cleanConstraints();
        }
Exemple #5
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();
        }
Exemple #6
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();
        }
Exemple #7
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("]");
                }
            }
        }
Exemple #8
0
        static void findPackets(DVP dvp, bool desired_result, List <Tuple <int, int> > failedLinks = null)
        {
            if (failedLinks == null)
            {
                failedLinks = new List <Tuple <int, int> >();
            }

            Console.WriteLine("findPackets");

            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:");
            Console.WriteLine(failedLinks);
            var input = f.FindAll((pkt, failed_links, result) => And(
                                      And(
                                          And(
                                              And(
                                                  pkt.GetDstIp().GetField <Ip, uint>("Value") < 7,
                                                  pkt.GetSrcIp().GetField <Ip, uint>("Value") < 7
                                                  ),
                                              pkt.GetDstIp() != pkt.GetSrcIp()),
                                          result == desired_result),
                                      failed_links == failedLinks));

            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.WriteLine("\t\t" + x);
                }
            }
        }