Exemplo n.º 1
0
        public int getDevicePort(string device)
        {
            RouterConnection rc = new RouterConnection();

            rc.getConnectedRouters();
            return(rc.getDevicePort(device));
        }
Exemplo n.º 2
0
        public string getPath()
        {
            string           device = directory.getEdgeNode(source);
            int              port   = getDevicePort(device);
            RouterConnection rc     = new RouterConnection();
            string           path   = rc.sendToRouter(port, source, destination, connectionId);

            return("");
        }
Exemplo n.º 3
0
        public string getPath()
        {
            string           device = directory.getEdgeNode(source);
            int              port   = getDevicePort(device);
            RouterConnection rc     = new RouterConnection();
            string           path   = rc.sendToRouter(port, source, destination, connectionId);

            while (!checkIfPathComplete(path))
            {
                string lastNode = getLastPathElement(path);
                string nextNCC  = directory.getAdjacentSubnetwork(lastNode);
                string adjacentSubnetworkPath = SendCallCoordinationRequest(lastNode, destination, throughput, Int32.Parse(nextNCC));
                path += adjacentSubnetworkPath;
            }
            return(path);
        }
Exemplo n.º 4
0
        private void run()
        {
            int byteREc = socket.Receive(bytes);

            data = Encoding.ASCII.GetString(bytes, 0, byteREc);
            Console.WriteLine(data);
            if (data.IndexOf("CALL_REQUEST") > -1) // NCC receives from client a request to setup a connection with another client
            {
                CallRequest callRequest = new CallRequest(data, connectionId);
                string      r           = callRequest.processCallRequest();
                byte[]      response    = Encoding.UTF8.GetBytes(r);
                socket.Send(response);
            }
            else if (data.IndexOf("CALL_COORDINATION_REQUEST") > -1) // NCC receives from adjacent CALL COORDINATION REQUEST to setup a connection between two clients
            {
                CallCoordinationRequest callCoordinationRequest = new CallCoordinationRequest(data, connectionId);
                string path = callCoordinationRequest.getPath();
                if (path != "")
                {
                    byte[] response = callCoordinationRequest.getCallCoordinationResponse(path);
                    socket.Send(response);
                }
                else
                {
                    string msg     = "CONNECTION FAILED";
                    byte[] message = Encoding.UTF8.GetBytes(msg);
                    socket.Send(message);
                }
            }
            else if (data.IndexOf("CONNECT") > -1) // NCC receives from a router a HELLO message with its name and listening port
            {
                string[]         smsg             = data.Split(' ');
                RouterConnection routerConnection = new RouterConnection();
                routerConnection.setRouterDetails(smsg[2], smsg[4]);
                routerConnection.getConnectedRouters();
                routerConnection.updateConnectedRouters();
            }
            else if (data.Contains("RESOURCE_ALLOCATION_COORDINATION")) // NCC receives from adjacent NCC a request to allocate resources for a connection
            {
                ResourceAllocationCoordination rac = new ResourceAllocationCoordination();
            }
        }