public void FindPath(NetworkPackage networkPackage) { //TimeStamp.WriteLine("{0} >> Received ROUTE TABLE QUERY REQUEST from {1}", RC_Name, networkPackage.sendingClientId); connectionMessage = networkPackage.message; /* * Big brain time - Wielkie sprawdzanie jak dojść do takiego klienta. Na razie oba są w domenie wiec do RC_A_1 i RC_A_2 * Zapisać LRM połączenia między podsieciami */ try { RCContact contact1 = contacts.Find(x => String.Equals(x.contactName, networkPackage.message.Split(' ')[0])); RCContact contact2 = contacts.Find(x => String.Equals(x.contactName, networkPackage.message.Split(' ')[1])); RCPath path = new RCPath(); path.from = contact1.subjectToAsk; path.to = contact2.subjectToAsk; path.CCConnectionId = Int32.Parse(networkPackage.message.Split(' ')[4]); //Console.WriteLine(networkPackage.message); graph.Dijkstra(path.from, path.to, path); if (path.status == ConnectionStatus.InProgress) { paths.Add(path); Console.WriteLine("{0} {1} :: found path between {2} and {3}, length: {4}", TimeStamp.TAB, RC_Name, path.from, path.to, path.length); } else { Console.WriteLine("{0} {1} did not found path between {2} and {3}", TimeStamp.TAB, RC_Name, path.from, path.to); } foundPathMessage = contact1.contactName + " " + contact2.subjectToAsk + " " + contact2.contactName + " " + contact1.subjectToAsk + " " + path.length; NetworkPackage response = new NetworkPackage( "CC_" + domain.emulationNodeId, "LRMs", Command.Used_Slots_Request, String.Join(" ", path.LRMids) ); domain.Send(response); } catch (Exception e) { Console.WriteLine(e.Message); } }
public void PathSet(NetworkPackage networkPackage) { //TimeStamp.WriteLine("{0} >> Received PATH SET from {1}", CC_Name, networkPackage.sendingClientId); RCPath currentPath = domain.domainRC.paths.Find(x => x.status == ConnectionStatus.InProgress); Connection c = connections.Find(x => x.status == ConnectionStatus.InProgress); c.confirmationsNeeded--; if (c.confirmationsNeeded > 0) { Console.WriteLine("{0} {1} :: {2} more SET PATH RESPONSE needed", TimeStamp.TAB, CC_Name, c.confirmationsNeeded); } else { TimeStamp.WriteLine("{0} >> LINK CONNECTION REQUEST sent to {1}", CC_Name, "LRMs"); c.confirmationsNeeded = 2; NetworkPackage message = new NetworkPackage( CC_Name, "LRMs", Command.Link_Connection_Request, String.Join(" ", currentPath.LRMids) + ":" + currentPath.startCrack + " " + currentPath.endCrack ); domain.Send(message); } }
public void CallRequest(NetworkPackage networkPackage) { //TimeStamp.WriteLine("{0} >> Received CALL REQUEST REQUEST from {1}", NCC_Name, networkPackage.sendingClientId); if (true) { TimeStamp.WriteLine("NCC_" + domain.emulationNodeId + " >> DIRECTORY REQUEST sent to D_" + domain.emulationNodeId); TimeStamp.WriteLine("D_" + domain.emulationNodeId + " >> DIRECTORY RESPONSE sent to NCC_" + domain.emulationNodeId); } TimeStamp.WriteLine("NCC_" + domain.emulationNodeId + " >> CAC REQUEST sent to PC_" + domain.emulationNodeId); TimeStamp.WriteLine("PC_" + domain.emulationNodeId + " >> CAC RESPONSE sent to NCC_" + domain.emulationNodeId); destinationCPCC = "CPCC_A_1_" + networkPackage.message.Split(' ')[0]; requestingCPCC = networkPackage.sendingClientId; currentBandwidth = networkPackage.message.Split(' ')[1]; currentCall = String.Format("{0} {1}", networkPackage.sendingClientId.Split('_')[3], networkPackage.message); domain.Send(new NetworkPackage( NCC_Name, destinationCPCC, Command.Call_Accept_Request, currentCall )); TimeStamp.WriteLine("{0} >> CALL ACCEPT REQUEST sent to {1}", NCC_Name, destinationCPCC); }