Example #1
0
        /// <summary>
        /// Initializes the protocol.
        /// </summary>
        /// <param name="protocolType">Type of the protocol.</param>
        public void InitializeProtocol(NetSimProtocolType protocolType)
        {
            // if client is already intialized - then this is a reset
            if (this.IsInitialized)
            {
                // clear pending messages in connections
                this.Connections.Values.ToList().ForEach(
                    c =>
                {
                    c.PendingMessages.Clear();
                    c.TransmittedMessages.Clear();
                });
            }

            // (re)set step counter
            this.StepCounter = 0;

            // (re)set the client data
            this.clientData = new StringBuilder();

            // create protocoll instance
            this.RoutingProtocol = RoutingProtocolFactory.CreateInstance(protocolType, this);

            // (re)set input queue
            this.InputQueue = new Queue <NetSimMessage>();

            // initialize protocol
            this.RoutingProtocol.Initialize();

            // client is initialized
            this.IsInitialized = true;
        }
Example #2
0
        /// <summary>
        /// Creates the instance.
        /// </summary>
        /// <param name="protocolType">Type of the protocol.</param>
        /// <param name="client">The client.</param>
        /// <returns>The created routing protocol instance.</returns>
        public static NetSimRoutingProtocol CreateInstance(NetSimProtocolType protocolType, NetSimClient client)
        {
            switch (protocolType)
            {
            case NetSimProtocolType.DSDV:
                return(new DsdvRoutingProtocol(client));
            }

            return(null);
        }
Example #3
0
        /// <summary>
        /// Initializes the protocol.
        /// </summary>
        /// <param name="initProtocol">The initialize protocol.</param>
        public void InitializeProtocol(NetSimProtocolType initProtocol)
        {
            this.StepCounter = 0;
            this.Protocol    = initProtocol;

            foreach (var client in this.Clients)
            {
                client.InitializeProtocol(initProtocol);
            }

            this.OnUpdated();
            this.IsInitialized = true;
        }