public void NetworkTopologyOut(String SNPid) { ShortTopology shortTopology = new ShortTopology(); foreach (KeyValuePair <string, string> kvp in localTopology.clientsSNPPs) { shortTopology.clients.Add(kvp.Key, kvp.Value); } shortTopology.inputSNPP = localTopology.outputSNPPs[SNPid]; string networkTopologyString = shortTopology.ToString(); StringBuilder sb = new StringBuilder(); sb.Append("NetworkTopologyOut_" + subnetworknumber + "_"); sb.Append(networkTopologyString); Send(sb.ToString(), remoteRCsPorts[SNPid]); string domain = null; if (subnetworknumber.Equals("10")) { domain = "AS 1"; } else if (subnetworknumber.Equals("11")) { domain = "AS 2"; } WriteLine("Wysylam topologię do " + domain); }
public static void RoutingController() { routingController.setCCport(ccport); Thread initiallyExchangeTopologiesThread = new Thread(() => routingController.initiallyExchangeTopologies()); initiallyExchangeTopologiesThread.Start(); bool done = false; UdpClient listener = new UdpClient(Int32.Parse(rcport)); IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, Int32.Parse(rcport)); string received_data; byte[] receive_byte_array; try { while (!done) { receive_byte_array = listener.Receive(ref groupEP); received_data = Encoding.ASCII.GetString(receive_byte_array, 0, receive_byte_array.Length); string[] splitArray = received_data.Split('_'); if (splitArray[0].Equals("NetworkTopologyIn")) { routingController.NetworkTopologyOut(splitArray[1]); } else if (splitArray[0].Equals("NetworkTopologyOut")) { ShortTopology.ShortTopologyParse(splitArray[2], splitArray[1], routingController); string domain = null; if (splitArray[1].Equals("10")) { domain = "AS 1"; } else if (splitArray[1].Equals("11")) { domain = "AS 2"; } Control_Node.RoutingController.WriteLine("Otrzymano topologię " + domain); } else if (splitArray[0].Equals("RouteTableQuery")) { string[] splitArray2 = splitArray[1].Split('*'); string[] splitArray3 = splitArray2[0].Split(','); routingController.RouteQuery(splitArray3[0], splitArray3[1], splitArray3[2], splitArray2[1]); } else if (splitArray[0].Equals("BreakConnection")) { routingController.ConnectionBroken(splitArray[1], splitArray[2]); } else if (splitArray[0].Equals("RestoreConnection")) { routingController.ConnectionRestored(splitArray[1], splitArray[2]); } } } catch (Exception e) { Console.WriteLine(e.ToString()); } listener.Close(); }