static void Main(string[] args) { Console.ReadLine(); LabelSwitchingRouter lsr = new LabelSwitchingRouter(); InputManager inputManager = new InputManager(); inputManager.ProcessPackage += lsr.passToInModule; inputManager.waitForInput(); }
public static void SwapLabels(int portNumber, MPLSPacket mplsp) { if (mplsp.TTL > 0) { mplsp.TTL -= 1; int LabelIndex = 1; while (true) { byte LastLabel = mplsp.Labels[mplsp.Labels.Count() - 1]; int mplsListIndex = MPLSFibTable.ReturnIndex(portNumber, LastLabel, LabelIndex); if (mplsListIndex == -1) { ManagementAgent.ReturnLog("Unable to forward packet."); break; } else { List <int> outputLabels = MPLSFibTable.MplsFibTable[mplsListIndex].OutputLabel; if (outputLabels[0] == 0) { LabelIndex++; mplsp.Labels.RemoveAt(mplsp.Labels.Count() - 1); continue; } else { mplsp.Labels.RemoveAt(mplsp.Labels.Count() - 1); foreach (int labels in outputLabels) { mplsp.Labels.Add(Convert.ToByte(labels)); } IOPort exitPort = LabelSwitchingRouter.ReturnPort(MPLSFibTable.MplsFibTable[mplsListIndex].OutputPort); if (exitPort != null) { exitPort.Send(mplsp); } else { ManagementAgent.ReturnLog("Unable to forward packet."); } break; } } } } else { ManagementAgent.ReturnLog("TTL value equals 0. Packet disappeared."); } }
static void Main(string[] args) { Console.Title = ("Label Switching Router : " + Config.getProperty("SubnetworkAddress")); OutputManager.initialize(); InputManager inputManager = new InputManager(); LabelSwitchingRouter lsr = new LabelSwitchingRouter(); inputManager.ProcessPackage += lsr.PassToInModule; while (true) { inputManager.WaitForInput(); } //Thread t = new Thread(new ParameterizedThreadStart(listenForInput)); //t.Start(inputManager); }
static void Main(string[] args) { Console.WriteLine(); // Invoke this sample with an arbitrary set of command line arguments. string[] arguments = Environment.GetCommandLineArgs(); try { LSRConfig.LoadConfig(arguments[1]); } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadLine(); Environment.ExitCode = 0; } ManagementAgent.ReturnLog($"Router {LSRConfig.LSRNAME} is working."); LabelSwitchingRouter LSR = new LabelSwitchingRouter(); LSR.LoadData(); LSR.StartManagementAgent(); Console.ReadLine(); }