コード例 #1
0
 public CloudCommunication(ClientNode clientNode, string instancePort, string nodeId, string nodeEmulationAddress, string nodeEmulationPort)
 {
     this.instanceAddress      = IPAddress.Parse("127.0.0.1");
     this.cloudPort            = 62572;
     this.instancePort         = Int32.Parse(instancePort);
     this.emulationNodeId      = nodeId;
     this.emulationNodeAddress = nodeEmulationAddress;
     this.emulationNodePort    = Int32.Parse(nodeEmulationPort);
     this.sendDone             = new ManualResetEvent(false);
     this.clientNode           = clientNode;
 }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.Clear();
            ClientNode clientNode = new ClientNode();

            if (args.Length != 5)
            {
                Console.WriteLine("Wrong parameters quantity. Shutting down.");
                return;
            }

            clientNode.contactList = clientNode.CreateDumbClientConfig(args[1]);

            clientNode.cloudCommunicator = new CloudCommunication(clientNode, args[0], args[1], args[2], args[3]);
            clientNode.subnetwork        = args[4];
            clientNode.cpcc = new CPCC(clientNode);


            Console.WriteLine("Starting client node with following parameters:");
            Console.WriteLine("Address on device: {0}:{1}", clientNode.cloudCommunicator.instanceAddress, clientNode.cloudCommunicator.instancePort);
            Console.WriteLine("Address in emulated network: {0}:{1}, subnetwork: {2}", clientNode.cloudCommunicator.emulationNodeAddress, clientNode.cloudCommunicator.emulationNodePort, clientNode.subnetwork);
            Console.WriteLine("Node identificator: {0}", clientNode.cloudCommunicator.emulationNodeId);


            try
            {
                Console.WriteLine("Client is up!");
                clientNode.cloudCommunicator.Start();
                Console.WriteLine("Type number of client for sending message, \"k\" and nunber to establish connection, \"c\" to close");
                bool isFinish = true;
                while (isFinish)
                {
                    char key = Console.ReadKey().KeyChar;
                    char connectionClientNumber = 'z';
                    if (key == 'k')
                    {
                        connectionClientNumber = Console.ReadKey().KeyChar;
                        key = connectionClientNumber;
                    }
                    ClientSenderConfig contact = clientNode.contactList.Find(x => x.key == key);

                    contact.demandedCapacity = Convert.ToInt32(2);

                    if (contact != null)
                    {
                        if (connectionClientNumber == 'z')
                        {
                            clientNode.cloudCommunicator.Send(new NetworkPackage(
                                                                  clientNode.cloudCommunicator.emulationNodeId,
                                                                  clientNode.cloudCommunicator.emulationNodeAddress,
                                                                  clientNode.cloudCommunicator.emulationNodePort,
                                                                  contact.receiverId,
                                                                  0.0,
                                                                  "Very important message"));
                            Console.WriteLine("/nMessage sent!");
                        }
                        else //string sendingClientId, string receivingClientId, int sendingClientPort, int capacity
                        {
                            if (!contact.isConnection)
                            {
                                Console.WriteLine();
                                Console.WriteLine("Type throughput (in Gb/s)");
                                string ghz = Console.ReadLine();
                                clientNode.cpcc.CallRequest(contact.receiverId, ghz);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
            }
            clientNode.cloudCommunicator.Stop();
            Console.WriteLine("Closing");
            Console.ReadKey();
        }
コード例 #3
0
ファイル: CPCC.cs プロジェクト: showmeyourlens/Comma
 public CPCC(ClientNode clientNode)
 {
     this.clientNode = clientNode;
     CPCC_Name       = "CPCC_" + clientNode.subnetwork + "_" + clientNode.cloudCommunicator.emulationNodeId;
 }