Esempio n. 1
0
File: LSDB.cs Progetto: tomaskk/OSPF
        public void UpdateLSDB()
        {
            AllNeighbourConnections.Clear();
            //update all neighbour list
            foreach (Router RouterX in Routers)
            {
                AllNeighbourConnections.Merge(RouterX.Neighbours);
            }

            foreach (Host HostX in Hosts)
            {
                AllNeighbourConnections.Merge(HostX.Neighbours);
            }
            //create graph
            g = new Graph();

            foreach (Host ht in Hosts)
            {
                String Name = ht.HostName;
                Dictionary <String, int> Edges = new Dictionary <String, int>();

                foreach (DataRow row in ht.Neighbours.Rows)
                {
                    Edges.Add(row["Destination"].ToString(), int.Parse(row["Metric cost"].ToString()));
                }
                g.Add_vertex(Name, Edges);
            }

            foreach (Router rt in Routers)
            {
                String Name = rt.RouterName;
                Dictionary <String, int> Edges = new Dictionary <String, int>();

                foreach (DataRow row in rt.Neighbours.Rows)
                {
                    Edges.Add(row["Destination"].ToString(), int.Parse(row["Metric cost"].ToString()));
                }
                g.Add_vertex(Name, Edges);
            }

            //update routing table
            foreach (Router RouterX in Routers)
            {
                RouterX.UpdateRoutingTable(this, false);
            }
        }
Esempio n. 2
0
File: LSDB.cs Progetto: tomaskk/OSPF
        public void ShowRoutes()
        {
            Console.WriteLine("All Full Routes To All Hosts: ");
            foreach (Router RouterX in Routers)
            {
                RouterX.UpdateRoutingTable(this, true);
            }

            Console.WriteLine("All Routing Tables: ");
            foreach (Router rt in Routers)
            {
                foreach (DataRow row in rt.RoutingTable.Rows)
                {
                    Console.WriteLine("Dest> {0}  > Next Hop> {1}  > Distance> {2}   <<<<< Router \"{3}\"", row["Destination"], row["Next Hop"], row["Distance"], rt.RouterName);
                }
                Console.WriteLine();
            }
        }