public void LocalTopologyIn(bool delete, SNP localTopologyUpdate) { Link link = links.Find(x => x.FirstSNPP.Address == localTopologyUpdate.Address || x.SecondSNPP.Address == localTopologyUpdate.Address); SNPP snpp = null; if (link.FirstSNPP.Address == localTopologyUpdate.Address) { snpp = link.FirstSNPP; } else { snpp = link.SecondSNPP; } if (delete) { snpp.Capacity += localTopologyUpdate.OccupiedCapacity; LogClass.GreenLog("[RC]Received Topology: Added " + localTopologyUpdate.OccupiedCapacity + "Mbit/s to SNPP " + localTopologyUpdate.Address + "."); } else { snpp.Capacity -= localTopologyUpdate.OccupiedCapacity; LogClass.MagentaLog("[RC]Received Topology: Removed " + localTopologyUpdate.OccupiedCapacity + "Mbit/s from SNPP " + localTopologyUpdate.Address + "."); } LogClass.WhiteLog("[RC] " + snpp.Capacity + "Mbit/s left on " + snpp.Address); }
public static bool SendConnectionRequest(SNP pathBegin, SNP pathEnd, SubnetworkAddress subnetworkAddress) { Tuple <SNP, SNP> connTuple = new Tuple <SNP, SNP>(pathBegin, pathEnd); bool hasValue = SocketsByAddress.TryGetValue(subnetworkAddress, out childSubSocket); if (hasValue) { if (pathBegin.Deleting) { childSubSocket.SendObject(DELETE_CONNECTION_REQUEST, connTuple); } else { childSubSocket.SendObject(CONNECTION_REQUEST_FROM_CC, connTuple); } while (!(acked || nacked)) { Thread.Sleep(30); } if (acked) { if (pathBegin.Deleting) { LogClass.MagentaLog("Subnetwork " + subnetworkAddress.subnetAddress + " deleted connection between: " + pathBegin.Address + " and " + pathEnd.Address); } else { LogClass.GreenLog("Subnetwork " + subnetworkAddress.subnetAddress + " set connection between: " + pathBegin.Address + " and " + pathEnd.Address); } acked = false; return(true); } else if (nacked) { if (pathBegin.Deleting) { LogClass.Log("Subnetwork " + subnetworkAddress.subnetAddress + " can't delete the connection between: " + pathBegin.Address + " and " + pathEnd.Address); } else { LogClass.Log("Subnetwork " + subnetworkAddress.subnetAddress + " can't set up the connection between: " + pathBegin.Address + " and " + pathEnd.Address); } nacked = false; return(false); } } else { LogClass.Log("Can't find subnetwork: " + subnetworkAddress.ToString()); } return(false); }
public void AddEntry(int inport, int inlabel, int outport, int outlabel, int newlabel, int removelabel, String address) { if (!routingTable.Contains(FindInputDestination(inport, inlabel, address))) { routingTable.Add(new Entry(inport, inlabel, outport, outlabel, newlabel, removelabel, address)); LogClass.GreenLog("Added new entry in FIB: inport " + inport + " inlabel " + inlabel + " outport " + outport + " outlabel " + outlabel + " | destinationAddress: " + address); } else { LogClass.WhiteLog("Entry with such input parameters already exists. Delete it before adding new one."); } }