Exemple #1
0
        public void PassToInModule(object oSender, object received, int destPort)
        {
            try
            {
                InPort inPort;
                int    destinationPort;
                if (received.GetType() == typeof(Packet))
                {
                    Packet receivedPacket = (Packet)received;

                    MPLSPacket packet = SetLabelAndPort(receivedPacket, destPort);
                    destinationPort = GetPortNumber(packet);
                    inPort          = GetInPort(destinationPort);
                    //LogClass.WhiteLog("Passing MPLSPacket to inPort " + inPort.GetPortNumber());
                    MPLSPacket processedPacket = inPort.ProcessPacket(packet);
                    Commutate(processedPacket);
                }
                else if (received.GetType() == typeof(MPLSPack))
                {
                    MPLSPack receivedPack = (MPLSPack)received;
                    destinationPort = destPort;
                    inPort          = GetInPort(destinationPort);
                    //LogClass.WhiteLog("Passing MPLSPack to inPort " + destinationPort);
                    ThreadSafeList <MPLSPacket> processedPackets = inPort.ProcessPack(receivedPack, destPort);
                    foreach (MPLSPacket packet in processedPackets)
                    {
                        Commutate(packet);
                    }
                }
            }
            catch (Exception e)
            {
                LogClass.MagentaLog("Connection doesn't exist");
            }
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        public void RemoveEntry(int inport, int inlabel, int outport, int outlabel)
        {
            Entry entryToBeDeleted = FindToDelete(inport, inlabel, outport, outlabel);

            if (entryToBeDeleted != null)
            {
                routingTable.Remove(entryToBeDeleted);
                LogClass.MagentaLog("Deleted entry from FIB: inport " + entryToBeDeleted.InPort + " inlabel " + entryToBeDeleted.InLabel +
                                    " outport " + entryToBeDeleted.OutPort + " outlabel " + entryToBeDeleted.OutLabel + " removed from FIB.");
            }
            else
            {
                LogClass.WhiteLog("Entry with such input parameters doesn't exist in this FIB.");
            }
        }