예제 #1
0
파일: RC.cs 프로젝트: admsbk/tsst2
        public string getExternalPorts(int src, int trg, int connectN, int requieredCapacity)
        {
            string rtn = "";

            RoutingGraph ownTopology = RoutingGraph.MapTopology(manager.Topology, ConnectionController.VirtualPaths, requieredCapacity);
            SetupStore   ss          = new SetupStore(src, trg, ownTopology, connectN, requieredCapacity);
            int          iter        = 1;

            do
            {
                if (ss.ownTopology.EdgeCount != 0)
                {
                    ss = new SetupStore(src, trg, ownTopology, connectN, requieredCapacity);
                    if (this.findBestPath(ss) && this.askLRMs(ss))  //if true -> creating list vcivpi
                    {
                        rtn += getLastLink(ss) + "#";
                        int size = ss.path.Count;
                        ownTopology.RemoveEdge(ss.path[size - 1]);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }while(isExternalLink(ss, trg));

            return(rtn);
        }
예제 #2
0
파일: RC.cs 프로젝트: admsbk/tsst2
        public NetworkConnection getPathViaExternalLink(int src, int trg, int connectN, int requieredCapacity, string link)
        {
            RoutingGraph             ownTopology = RoutingGraph.MapTopology(manager.Topology, ConnectionController.VirtualPaths, requieredCapacity);
            List <RoutingGraph.Link> toRemove    = new List <RoutingGraph.Link>();
            string slot = link.Split(':')[1];

            foreach (var edge in ownTopology.Edges)
            {
                if (edge.tLink.Name != link.Split(':')[0] && edge.tLink.Name.Contains("External"))
                {
                    toRemove.Add(edge);
                }
            }
            foreach (var rm in toRemove)
            {
                ownTopology.RemoveEdge(rm);
            }

            SetupStore ss = new SetupStore(src, trg, ownTopology, connectN, requieredCapacity);


            if (ss.ownTopology.EdgeCount != 0)
            {
                if (this.findBestPath(ss) && this.askLRMs(ss, slot))  //if true -> creating list vcivpi
                {
                    return(this.parseToNetworConnection(ss));
                }
                else
                {
                    return(null);
                }
            }
            return(null);
        }
예제 #3
0
파일: RC.cs 프로젝트: admsbk/tsst2
        private bool isExternalLink(SetupStore ss, int target)
        {
            foreach (var edge in ss.ownTopology.Edges)
            {
                if (edge.Target.Id == target)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #4
0
파일: RC.cs 프로젝트: sopel30/tsst2
 public NetworkConnection assignRoute(int src, int trg, int connectN, int requieredCapacity)
 {
     RoutingGraph ownTopology = RoutingGraph.MapTopology(manager.Topology, ConnectionController.VirtualPaths, requieredCapacity);
     SetupStore ss = new SetupStore(src, trg, ownTopology, connectN, requieredCapacity);
     if (ss.ownTopology.EdgeCount != 0)
     {
         if (this.findBestPath(ss) && this.askLRMs(ss))  //if true -> creating list vcivpi
         {
             return this.parseToNetworConnection(ss);
         }
         else
             return null;
     }
     return null;
 }
예제 #5
0
파일: RC.cs 프로젝트: admsbk/tsst2
        public NetworkConnection assignRoute(int src, int trg, int connectN, int requieredCapacity)
        {
            RoutingGraph ownTopology = RoutingGraph.MapTopology(manager.Topology, ConnectionController.VirtualPaths, requieredCapacity);
            SetupStore   ss          = new SetupStore(src, trg, ownTopology, connectN, requieredCapacity);

            if (ss.ownTopology.EdgeCount != 0)
            {
                if (this.findBestPath(ss) && this.askLRMs(ss))  //if true -> creating list vcivpi
                {
                    return(this.parseToNetworConnection(ss));
                }
                else
                {
                    return(null);
                }
            }
            return(null);
        }
예제 #6
0
파일: RC.cs 프로젝트: sopel30/tsst2
        public bool askLRMs(SetupStore ss, string preferedSlot = "")
        {
            string VpiVci = "";
            /*
            if (!manager.Ping(ss.source))
                return false;*/
            foreach (var e in ss.path)
            {/*
                if (!manager.Ping(e.Target.Id))
                    return false;*/

                string[] srcrt;
                string[] trgrt;
                int i = 0;
                do
                {
                    string tmp1 = e.SourceRouting.Replace(".", ":");
                    string tmp2 = e.TargetRouting.Replace(".", ":");
                    srcrt = tmp1.Split(':'); // [0] -> Port, [1] -> Slot
                    trgrt = tmp2.Split(':');
                    if (preferedSlot != "")
                        srcrt[1] = trgrt[1] = preferedSlot;
                    else if (srcrt[1] == "" && trgrt[1] == "")
                    {
                        srcrt[1] =
                        trgrt[1] = rand();

                    }
                    i++;
                } while (
                    !lrm.isAvailable(e.Source.tNode.Name, e.Target.tNode.Name, Convert.ToInt32(srcrt[1])) ||
                    !lrm.isAvailable(e.Source.tNode.Name, e.Target.tNode.Name, Convert.ToInt32(trgrt[1]))
                    );
               // lrm.reserve(e.Source.tNode.Name, e.Target.tNode.Name, Convert.ToInt32(srcrt[1]));
               // lrm.reserve(e.Source.tNode.Name, e.Target.tNode.Name, Convert.ToInt32(trgrt[1]));

                e.SourceRouting = srcrt[0] + "." + srcrt[1];
                e.TargetRouting = trgrt[0] + "." + trgrt[1];
                ss.vcivpiList.Add(VpiVci);

            }
            return true;
        }
예제 #7
0
파일: RC.cs 프로젝트: admsbk/tsst2
        public bool askLRMs(SetupStore ss, string preferedSlot = "")
        {
            string VpiVci = "";

            /*
             * if (!manager.Ping(ss.source))
             *  return false;*/
            foreach (var e in ss.path)
            {/*
              * if (!manager.Ping(e.Target.Id))
              *     return false;*/
                string[] srcrt;
                string[] trgrt;
                int      i = 0;
                do
                {
                    string tmp1 = e.SourceRouting.Replace(".", ":");
                    string tmp2 = e.TargetRouting.Replace(".", ":");
                    srcrt = tmp1.Split(':'); // [0] -> Port, [1] -> Slot
                    trgrt = tmp2.Split(':');
                    if (preferedSlot != "")
                    {
                        srcrt[1] = trgrt[1] = preferedSlot;
                    }
                    else if (srcrt[1] == "" && trgrt[1] == "")
                    {
                        srcrt[1]     =
                            trgrt[1] = rand();
                    }
                    i++;
                } while (
                    !lrm.isAvailable(e.Source.tNode.Name, e.Target.tNode.Name, Convert.ToInt32(srcrt[1])) ||
                    !lrm.isAvailable(e.Source.tNode.Name, e.Target.tNode.Name, Convert.ToInt32(trgrt[1]))
                    );
                // lrm.reserve(e.Source.tNode.Name, e.Target.tNode.Name, Convert.ToInt32(srcrt[1]));
                // lrm.reserve(e.Source.tNode.Name, e.Target.tNode.Name, Convert.ToInt32(trgrt[1]));

                e.SourceRouting = srcrt[0] + "." + srcrt[1];
                e.TargetRouting = trgrt[0] + "." + trgrt[1];
                ss.vcivpiList.Add(VpiVci);
            }
            return(true);
        }
예제 #8
0
파일: RC.cs 프로젝트: admsbk/tsst2
        private NetworkConnection parseToNetworConnection(SetupStore ss)
        {
            NetworkConnection networkConnection = new NetworkConnection(ss.connectN);
            //  List<LinkConnection> links = new List<LinkConnection>();
            LinkConnection link;

            networkConnection.Capacity = ss.requieredCapacity;

            foreach (var e in ss.path)
            {
                link               = new LinkConnection();
                link.SourceId      = e.Source.tNode.Name;
                link.TargetId      = e.Target.tNode.Name;
                link.SourceRouting = e.SourceRouting;
                link.TargetRouting = e.TargetRouting;
                link.Link          = e.tLink;
                networkConnection.Path.Add(link);
            }
            return(networkConnection);
        }
예제 #9
0
파일: RC.cs 프로젝트: admsbk/tsst2
        bool findBestPath(SetupStore ss)
        {
            Dictionary <RoutingGraph.Link, double> edgeCost = new Dictionary <RoutingGraph.Link, double>(ss.ownTopology.EdgeCount);

            int index = 0;
            int max   = ss.ownTopology.EdgeCount;

            while (index < max)
            {       //free capisity < requierd
                if (ss.ownTopology.Edges.ElementAt(index).Capacity < ss.requieredCapacity)
                {
                    ss.ownTopology.RemoveEdge(ss.ownTopology.Edges.ElementAt(index));
                    max = ss.ownTopology.EdgeCount;
                }
                else
                {
                    index++;
                }
            }
            foreach (var e in ss.ownTopology.Edges)
            {
                edgeCost.Add(e, e.Capacity);
            }

            var dijkstra    = new DijkstraShortestPathAlgorithm <RoutingGraph.Node, RoutingGraph.Link>(ss.ownTopology, e => edgeCost[e]);
            var predecessor = new VertexPredecessorRecorderObserver <RoutingGraph.Node, RoutingGraph.Link>();

            predecessor.Attach(dijkstra);
            dijkstra.Compute(this.IDtoNode(ss.source, ss.ownTopology));
            IEnumerable <RoutingGraph.Link> path;

            if (predecessor.TryGetPath(this.IDtoNode(ss.target, ss.ownTopology), out path))
            {
                ss.path.AddRange(path);
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #10
0
파일: RC.cs 프로젝트: sopel30/tsst2
        private NetworkConnection parseToNetworConnection(SetupStore ss)
        {
            NetworkConnection networkConnection = new NetworkConnection(ss.connectN);
            //  List<LinkConnection> links = new List<LinkConnection>();
            LinkConnection link;
            networkConnection.Capacity = ss.requieredCapacity;

            foreach (var e in ss.path)
            {
                link = new LinkConnection();
                link.SourceId = e.Source.tNode.Name;
                link.TargetId = e.Target.tNode.Name;
                link.SourceRouting = e.SourceRouting;
                link.TargetRouting = e.TargetRouting;
                link.Link = e.tLink;
                networkConnection.Path.Add(link);
            }
            return networkConnection;
        }
예제 #11
0
파일: RC.cs 프로젝트: sopel30/tsst2
        private bool isExternalLink(SetupStore ss, int target)
        {
            foreach (var edge in ss.ownTopology.Edges)
                if (edge.Target.Id == target)
                    return true;

            return false;
        }
예제 #12
0
파일: RC.cs 프로젝트: sopel30/tsst2
 private string getLastLink(SetupStore ss)
 {
     return ss.path[ss.path.Count-1].tLink.Name;
 }
예제 #13
0
파일: RC.cs 프로젝트: sopel30/tsst2
        bool findBestPath(SetupStore ss)
        {
            Dictionary<RoutingGraph.Link, double> edgeCost = new Dictionary<RoutingGraph.Link, double>(ss.ownTopology.EdgeCount);

            int index = 0;
            int max = ss.ownTopology.EdgeCount;
            while (index < max)
            {       //free capisity < requierd
                if (ss.ownTopology.Edges.ElementAt(index).Capacity < ss.requieredCapacity)
                {
                    ss.ownTopology.RemoveEdge(ss.ownTopology.Edges.ElementAt(index));
                    max = ss.ownTopology.EdgeCount;
                }
                else
                    index++;
            }
            foreach (var e in ss.ownTopology.Edges)
            {
                edgeCost.Add(e, e.Capacity);

            }

            var dijkstra = new DijkstraShortestPathAlgorithm<RoutingGraph.Node, RoutingGraph.Link>(ss.ownTopology, e => edgeCost[e]);
            var predecessor = new VertexPredecessorRecorderObserver<RoutingGraph.Node, RoutingGraph.Link>();
            predecessor.Attach(dijkstra);
            dijkstra.Compute(this.IDtoNode(ss.source, ss.ownTopology));
            IEnumerable<RoutingGraph.Link> path;

            if (predecessor.TryGetPath(this.IDtoNode(ss.target, ss.ownTopology), out path))
            {
                ss.path.AddRange(path);
                return true;
            }
            else return false;
        }
예제 #14
0
파일: RC.cs 프로젝트: sopel30/tsst2
        public NetworkConnection getPathViaExternalLink(int src, int trg, int connectN, int requieredCapacity, string link)
        {
            RoutingGraph ownTopology = RoutingGraph.MapTopology(manager.Topology, ConnectionController.VirtualPaths, requieredCapacity);
            List<RoutingGraph.Link> toRemove = new List<RoutingGraph.Link>();
            string slot = link.Split(':')[1];
            foreach (var edge in ownTopology.Edges)
            {
                if (edge.tLink.Name != link.Split(':')[0] && edge.tLink.Name.Contains("External"))
                {

                    toRemove.Add(edge);
                }
            }
            foreach (var rm in toRemove)
            {
                ownTopology.RemoveEdge(rm);
            }

            SetupStore ss = new SetupStore(src, trg, ownTopology, connectN, requieredCapacity);

            if (ss.ownTopology.EdgeCount != 0)
            {
                if (this.findBestPath(ss) && this.askLRMs(ss, slot))  //if true -> creating list vcivpi
                {
                    return this.parseToNetworConnection(ss);
                }
                else
                    return null;
            }
            return null;
        }
예제 #15
0
파일: RC.cs 프로젝트: sopel30/tsst2
        public string getExternalPorts(int src, int trg, int connectN, int requieredCapacity)
        {
            string rtn = "";

            RoutingGraph ownTopology = RoutingGraph.MapTopology(manager.Topology, ConnectionController.VirtualPaths, requieredCapacity);
            SetupStore ss = new SetupStore(src, trg, ownTopology, connectN, requieredCapacity);
            int iter = 1;
            do{
                if (ss.ownTopology.EdgeCount != 0)
                {
                    ss = new SetupStore(src, trg, ownTopology, connectN, requieredCapacity);
                    if (this.findBestPath(ss) && this.askLRMs(ss))  //if true -> creating list vcivpi
                    {
                        rtn += getLastLink(ss)+"#";
                        int size = ss.path.Count;
                        ownTopology.RemoveEdge(ss.path[size - 1]);

                    }
                    else
                        return null;
                }
            }while(isExternalLink(ss, trg));

            return rtn;
        }
예제 #16
0
파일: RC.cs 프로젝트: admsbk/tsst2
 private string getLastLink(SetupStore ss)
 {
     return(ss.path[ss.path.Count - 1].tLink.Name);
 }