Beispiel #1
0
        /// <summary>
        /// Prepare MPLSPackage to send via UDP/TCP
        /// To send via UDP, use
        /// <example>ManagementMessage_(message).toBytes()</example>
        /// </summary>

        /// <param name="message">Prepared ManagementMessage ready to send</param>
        /// <returns>Package</returns>
        public static Package ManagementMessage_(ManagementMessage message)
        {
            Package package = new Package();

            package.Key  = "MANAGEMENTMESSAGE";
            package.data = message.toString();

            return(package);
        }
Beispiel #2
0
        public static void LogsSendRoutingTableRequest(ManagementMessage message, String Routername)
        {
            String log;

            log = $"({getActualTime()}) [ROUTING TABLE REQUEST SEND]";

            Console.WriteLine(log);
            WriteToFile(log, Routername);
        }
Beispiel #3
0
        public static void LogsReceiveRoutingTableRequest(ManagementMessage message)
        {
            String log;

            log = $"({getActualTime()}) [ROUTING TABLE REQUEST RECEIVE] FROM {message.getMessage()}";

            Console.WriteLine(log);
            WriteToFile(log, "Management");
        }
Beispiel #4
0
        public static void LogsSendRoutingTable(ManagementMessage message)
        {
            String log;

            log = $"({getActualTime()}) [ROUTING TABLE SEND] FOR {message.getMessage()}";

            Console.WriteLine(log);
            WriteToFile(log, "Management");
        }
        /*
         * //----------LABEL REQUEST------------
         * public static ManagementMessage LabelRequest(String hostDestinationName, IPEndPoint RequesterEndPoint)
         * {
         *  ManagementMessage message = new ManagementMessage();
         *  message.Key = "LABEL";
         *  message.Message = hostDestinationName;
         *  message.RequesterEndPoint = RequesterEndPoint;
         *
         *  return message;
         * }
         *
         * public bool isLabelRequest()
         * {
         *  if(this.Key=="LABEL")
         *  {
         *      return true;
         *  } else
         *  {
         *      return false;
         *  }
         * }
         *
         *
         * //-----CLOSE TUNEL REQUEST----------
         * public static ManagementMessage CloseTunelRequest(int labelTunelToClose, IPEndPoint RequesterEndPoint)
         * {
         *  ManagementMessage message = new ManagementMessage();
         *  message.Key = "CLOSETUNEL";
         *  message.Message = labelTunelToClose.ToString();
         *  message.RequesterEndPoint = RequesterEndPoint;
         *
         *  return message;
         * }
         *
         * public bool isCloseTunelRequest()
         * {
         *  if (this.Key == "CLOSETUNEL")
         *  {
         *      return true;
         *  }
         *  else
         *  {
         *      return false;
         *  }
         * }
         */

        //-------ROUTE LIST ----------------
        public static ManagementMessage RoutingTableRequest(String networkNodeName, IPEndPoint destination)
        {
            ManagementMessage message = new ManagementMessage();

            message.Key               = "ROUTETABLE";
            message.Message           = networkNodeName;
            message.RequesterEndPoint = destination;

            return(message);
        }
        public static ManagementMessage fromString(String stringMassage)
        {
            String[] data = stringMassage.Split(':');

            ManagementMessage massage = new ManagementMessage();

            try
            {
                massage.Key               = data[0];
                massage.Message           = data[1];
                massage.RequesterEndPoint = new IPEndPoint(IPAddress.Parse(data[2]), int.Parse(data[3]));
                Console.WriteLine(massage.RequesterEndPoint);
            }catch (Exception e)
            {
                Console.WriteLine(e);
            }


            return(massage);
        }
Beispiel #7
0
 /// <summary>
 /// Create ManagementMessage from opened package
 /// </summary>
 /// <param name="package">Opened Package</param>
 /// <returns>ManagementMessage object</returns>
 public static ManagementMessage ReceiveManagementMessage(Package package)
 {
     return(ManagementMessage.fromString(package.data));
 }
Beispiel #8
0
        /// <summary>
        /// Create ManagementMessage from bytes received from UDP/TCP client
        /// </summary>
        /// <param name="messageBytes">Bytes containing messageBytes</param>
        /// <returns>ManagementMessage object</returns>
        public static ManagementMessage ReceiveManagementMessage(byte[] messageBytes)
        {
            Package package = Package.fromBytes(messageBytes);

            return(ManagementMessage.fromString(package.data));
        }