public void fillingTable(string line, Socket socketsending, string key) { //Znaki oddzielające poszczególne części żądania klienta. char[] delimiterChars = { '#' }; //Podzielenie żądania na tablicę stringów. string[] words; words = line.Split(delimiterChars); switch (words[0]) { case "ADD": switch (Int32.Parse(words[1])) { //Dodawanie wpisu do BorderComutationTable case 1: BorderNodeCommutationTableRow newRow = new BorderNodeCommutationTableRow( words[2], Convert.ToInt16(words[3]), Convert.ToInt16(words[4]), Convert.ToInt16(words[5]), Convert.ToInt16(words[6]), Convert.ToInt16(words[7]), words[8], Convert.ToInt16(words[9]), Convert.ToInt16(words[10])); borderNodeCommutationTable.Table.Add(newRow); stateReceivedMessageFromNMS("BorderNodeCommutationTable", "ADD"); break; //Dodanie wpisu do EONTable case 2: EONTableRowIN eonIN = new EONTableRowIN(Convert.ToInt16(words[2]), Convert.ToInt16(words[3])); EONTableRowOut eonOut = new EONTableRowOut(Convert.ToInt16(words[4]), Convert.ToInt16(words[5])); bool eoninbool = eonTable.addRow(eonIN); bool eonoutbool = eonTable.addRow(eonOut); if (eoninbool == false || eonoutbool == false) { sendingMessageCommunication(OperationConfiguration.getSetting(key, mySettings), "ERROR", socketsending); } else { stateReceivedMessageFromNMS("EONTable", "ADD"); } break; //Dodanie wpisu do CommutationTable case 3: CommutationTableRow commuteRow = new CommutationTableRow(Convert.ToInt16(words[2]), Convert.ToInt16(words[3]), Convert.ToInt16(words[4]), Convert.ToInt16(words[5])); commutationTable.Table.Add(commuteRow); stateReceivedMessageFromNMS("CommutationTable", "ADD"); break; default: break; } break; case "DELETE": switch (Int32.Parse(words[1])) { //Dodawanie wpisu do BorderComutationTable case 1: BorderNodeCommutationTableRow newRow = new BorderNodeCommutationTableRow(); newRow = borderNodeCommutationTable.FindRow(words[2], Convert.ToInt16(words[3]), words[4]); borderNodeCommutationTable.Table.Remove(newRow); stateReceivedMessageFromNMS("BorderNodeCommutationTable", "DELETE"); break; //Dodanie wpisu do EONTable case 2: EONTableRowIN eonIN = new EONTableRowIN(Convert.ToInt16(words[2]), Convert.ToInt16(words[3])); EONTableRowOut eonOut = new EONTableRowOut(Convert.ToInt16(words[4]), Convert.ToInt16(words[5])); bool eoninbool = eonTable.deleteRow(eonIN); bool eonoutbool = eonTable.deleteRow(eonOut); if (eoninbool == false || eonoutbool == false) { sendingMessageCommunication(OperationConfiguration.getSetting(key, mySettings), "ERROR", socketsending); } else { stateReceivedMessageFromNMS("EONTable", "DELETE"); } break; //Dodanie wpisu do CommutationTable case 3: CommutationTableRow rowToDelete = new CommutationTableRow(); rowToDelete = commutationTable.FindRow(Convert.ToInt16(words[2]), Convert.ToInt16(words[3])); commutationTable.Table.Remove(rowToDelete); stateReceivedMessageFromNMS("CommutationTable", "DELETE"); break; default: break; } break; case "TOPOLOGY": switch (Int32.Parse(words[1])) { case 1: //Dodawanie wpisu do BorderComutationTable for (int i = 0; i < borderNodeCommutationTable.Table.Count; i++) { byte[] table_in_bytes = null; string builder = string.Empty; string port_in = string.Empty; string port_out = string.Empty; string Hops = string.Empty; string command = string.Empty; string band_out = string.Empty; string destination_IP = string.Empty; string Modulation = string.Empty; string BitRate = string.Empty; string IP_IN = string.Empty; string Frequency_out = string.Empty; command = "TOPOLOGY"; IP_IN = borderNodeCommutationTable.Table[i].IP_IN.ToString(); port_in = borderNodeCommutationTable.Table[i].port_in.ToString(); band_out = borderNodeCommutationTable.Table[i].band.ToString(); Frequency_out = borderNodeCommutationTable.Table[i].frequency.ToString(); Modulation = borderNodeCommutationTable.Table[i].modulationPerformance.ToString(); BitRate = borderNodeCommutationTable.Table[i].bitRate.ToString(); destination_IP = borderNodeCommutationTable.Table[i].IP_Destination.ToString(); port_out = borderNodeCommutationTable.Table[i].Port.ToString(); Hops = borderNodeCommutationTable.Table[i].hopsNumber.ToString(); builder = command + "#" + "1" + "#" + IP_IN + "#" + port_in + "#" + band_out + "#" + Frequency_out + "#" + Modulation + "#" + BitRate + "#" + destination_IP + "#" + port_out + "#" + Hops; sendingMessageCommunication(OperationConfiguration.getSetting(key, mySettings), builder, socketsending); } break; //Dodanie wpisu do EONTable case 2: for (int i = 0; i < eonTable.TableIN.Count; i++) { byte[] table_in_bytes = null; string builder = string.Empty; ; string command = string.Empty; string band_in = string.Empty; string frequency_out = string.Empty; string band_out = string.Empty; string frequency_in = string.Empty; command = "TOPOLOGY"; frequency_in = eonTable.TableIN[i].busyFrequency.ToString(); band_in = eonTable.TableIN[i].busyBandIN.ToString(); frequency_out = eonTable.TableOut[i].busyFrequency.ToString(); band_out = eonTable.TableOut[i].busyBandOUT.ToString(); builder = command + "#" + "2" + "#" + frequency_in + "#" + band_in + "#" + frequency_out + "#" + band_out; sendingMessageCommunication(OperationConfiguration.getSetting(key, mySettings), builder, socketsending); } break; //Dodanie wpisu do CommutationTable case 3: for (int i = 0; i < commutationTable.Table.Count; i++) { byte[] table_in_bytes = null; string command = string.Empty; string builder = string.Empty; string port_in = string.Empty; string port_out = string.Empty; string Frequency_in = string.Empty; string frequency_out = string.Empty; command = "TOPOLOGY"; port_in = commutationTable.Table[i].port_in.ToString(); frequency_out = commutationTable.Table[i].frequency_out.ToString(); Frequency_in = commutationTable.Table[i].frequency_in.ToString(); port_out = commutationTable.Table[i].port_out.ToString(); builder = command + "#" + "3" + "#" + Frequency_in + "#" + port_in + "#" + frequency_out + "#" + port_out; sendingMessageCommunication(OperationConfiguration.getSetting(key, mySettings), builder, socketsending); } break; default: break; } break; default: break; } // Console.ReadKey(); }
private void setRouting(string [] message) { string address = message[0]; if (message[1] == MessageNames.CONNECTION_TEARDOWN) { if (message[3] == "CC") { short frequency = Int16.Parse(message[10]); short port_In = Int16.Parse(message[5]); short port_Out = Int16.Parse(message[7]); CommutationTableRow rowToDelete = new CommutationTableRow(); rowToDelete = commutationTable.FindRow(Convert.ToInt16(message[10]), Convert.ToInt16(message[5])); commutationTable.Table.Remove(rowToDelete); string responseMessage = System.Configuration.ConfigurationManager.AppSettings["UDP" + numberOfRouter] + "#" + MessageNames.CONNECTION_TEARDOWN + "#OK" + "#" + "CC#"; SendingMessageCC(address, responseMessage); Console.WriteLine("[" + Timestamp.generateTimestampRCC() + "] Message delete from table {0} frequency {1} port_in {2} port_out {3}", "COMUTATION", frequency, port_In, port_Out); } else if (message[3] == "BORDERTABLE") { string responseMessage = System.Configuration.ConfigurationManager.AppSettings["UDP" + numberOfRouter] + "#" + MessageNames.CONNECTION_TEARDOWN + "#OK" + "#" + "CC#"; BorderNodeCommutationTableRow newRow = new BorderNodeCommutationTableRow(); //IP source--IP destination--czestotliwosc newRow = borderNodeCommutationTable.FindRow(message[4], message[6], Int16.Parse(message[7])); borderNodeCommutationTable.Table.Remove(newRow); // SendingMessageCC(address, responseMessage); Console.WriteLine("[" + Timestamp.generateTimestampRCC() + "] Message delete from table {0} frequency {1} address source: {2} address destination {3}", "BORDER_NODE_COMUTATION", message[7], message[4], message[6]); } } else if (message[1] == MessageNames.CONNECTION_REQUEST) { if (message[3] == "CC") { Console.WriteLine("[" + Timestamp.generateTimestampRCC() + "] Received message filling Commutation Table from CC " + message[0]); short frequency = Int16.Parse(message[10]); short port_In = Int16.Parse(message[5]); short port_Out = Int16.Parse(message[7]); CommutationTableRow commuteRow = new CommutationTableRow(frequency, port_In, frequency, port_Out); commutationTable.Table.Add(commuteRow); string responseMessage = System.Configuration.ConfigurationManager.AppSettings["UDP" + numberOfRouter] + "#" + MessageNames.CONNECTION_REQUEST + "#OK" + "#" + "CC#"; SendingMessageCC(address, responseMessage); Console.WriteLine("[" + Timestamp.generateTimestampRCC() + "] Message new registry to table {0} ", "COMUTATION_TABLE" + " Frequency: " + message[10] + " port_in: " + message[5] + " port_out: " + message[7]); } else if (message[3] == "BORDERTABLE") { Console.WriteLine("[" + Timestamp.generateTimestampRCC() + "] Received message filling BorderNodeCommutationTable from CC " + message[0]); string responseMessage = System.Configuration.ConfigurationManager.AppSettings["UDP" + numberOfRouter] + "#" + MessageNames.CONNECTION_REQUEST + "#OK" + "#" + "CC#"; BorderNodeCommutationTableRow newRow = new BorderNodeCommutationTableRow( message[4], Convert.ToInt16(message[5]), Convert.ToInt16(1), Convert.ToInt16(message[7]), Convert.ToInt16(7), Convert.ToInt16(1), message[6], Convert.ToInt16(2), Convert.ToInt16(1)); borderNodeCommutationTable.Table.Add(newRow); // SendingMessageCC(address, responseMessage); Console.WriteLine("[" + Timestamp.generateTimestampRCC() + "] Message new registry to table {0} ", "BORDER_NODE_COMUTATION " + "Frequency: " + message[7] + " port_in " + message[5]); } } }
public void fillingTable(string line) { //Znaki oddzielające poszczególne części żądania klienta. char[] delimiterChars = { '#' }; //Podzielenie żądania na tablicę stringów. string[] words; words = line.Split(delimiterChars); switch (words[0]) { case "ADD": switch (Int32.Parse(words[1])) { //Dodawanie wpisu do BorderComutationTable case 1: BorderNodeCommutationTableRow newRow = new BorderNodeCommutationTableRow( words[2], Convert.ToInt16(words[3]), Convert.ToInt16(words[4]), Convert.ToInt16(words[5]), Convert.ToInt16(words[6]), Convert.ToInt16(words[7]), words[8], Convert.ToInt16(words[9]), Convert.ToInt16(words[10])); borderNodeCommutationTable.Table.Add(newRow); stateReceivedMessageFromNMS("BorderNodeCommutationTable", "ADD"); break; //Dodanie wpisu do EONTable case 2: EONTableRowIN eonIN = new EONTableRowIN(Convert.ToInt16(words[2]), Convert.ToInt16(words[3])); EONTableRowOut eonOut = new EONTableRowOut(Convert.ToInt16(words[4]), Convert.ToInt16(words[5])); eonTable.addRow(eonIN); eonTable.addRow(eonOut); stateReceivedMessageFromNMS("EONTable", "ADD"); break; //Dodanie wpisu do CommutationTable case 3: CommutationTableRow commuteRow = new CommutationTableRow(Convert.ToInt16(words[2]), Convert.ToInt16(words[3]), Convert.ToInt16(words[4]), Convert.ToInt16(words[5])); commutationTable.Table.Add(commuteRow); stateReceivedMessageFromNMS("CommutationTable", "ADD"); break; default: break; } break; case "DELETE": switch (Int32.Parse(words[1])) { //Dodawanie wpisu do BorderComutationTable case 1: BorderNodeCommutationTableRow newRow = new BorderNodeCommutationTableRow(); newRow = borderNodeCommutationTable.FindRow(words[2], Convert.ToInt16(words[3]), words[4]); borderNodeCommutationTable.Table.Remove(newRow); stateReceivedMessageFromNMS("BorderNodeCommutationTable", "DELETE"); break; //Dodanie wpisu do EONTable case 2: EONTableRowIN eonIN = new EONTableRowIN(Convert.ToInt16(words[2]), Convert.ToInt16(words[3])); EONTableRowOut eonOut = new EONTableRowOut(Convert.ToInt16(words[4]), Convert.ToInt16(words[5])); eonTable.deleteRow(eonIN); eonTable.deleteRow(eonOut); stateReceivedMessageFromNMS("EONTable", "DELETE"); break; //Dodanie wpisu do CommutationTable case 3: CommutationTableRow rowToDelete = new CommutationTableRow(); rowToDelete = commutationTable.FindRow(Convert.ToInt16(words[2]), Convert.ToInt16(words[3])); commutationTable.Table.Remove(rowToDelete); stateReceivedMessageFromNMS("CommutationTable", "DELETE"); break; default: break; } break; default: break; } // Console.ReadKey(); }