Exemple #1
0
    def setUp(self):
        # testing the serrver
        # print("Booting Server")
        self.srv = serverhub.ServerHub()
        self.srv.run()
        time.sleep(0.05)

        # print("Booting client")
        self.clientUAS = udpxciever.Udpxciever("127.0.0.1", 16250)
        self.clientGCS = udpxciever.Udpxciever("127.0.0.1", 16250)
        self.clientUAS.start()
        self.clientGCS.start()
        time.sleep(0.01)
    def setUp(self):
        # start a server
        self.srv = serverhub.ServerHub("127.0.0.1", 16250)
        self.srv.run()
        self.network_id = os.urandom(32)

        #and some external clients
        self.ExtGCS = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.ExtGCS.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        #self.ExtGCS.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 60)
        #self.ExtGCS.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 60)
        self.ExtGCS.settimeout(0.5)
        self.ExtUAS = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.ExtUAS.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        #self.ExtUAS.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 60)
        #self.ExtUAS.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 60)
        self.ExtUAS.settimeout(0.5)

        #and the clients themselves
        self.GCSClient = clienthub.Clienthub(
            ("127.0.0.1", 14550), ("127.0.0.1", 16250), self.network_id, 33)
        self.UASClient = clienthub.Clienthub(
            ("127.0.0.1", 14560), ("127.0.0.1", 16250), self.network_id, 2)
        time.sleep(0.05)
Exemple #3
0
    UASPercent = int((100 * len(UASRx)) / len(GCSTx))

    #Did we get all the packets back? If not, give stats
    if GCSPercent == 100 and UASPercent == 100:
        print("Pass")
    else:
        print("Got GCS " + str(len(GCSRx)) + "/" + str(len(UASTx)) +
              " packets")
        print("Got UAS " + str(len(UASRx)) + "/" + str(len(GCSTx)) +
              " packets")
        print("Got UAS=" + str(UASPercent) + "%, GCS=" + str(GCSPercent) + "%")


if __name__ == '__main__':
    # start a server
    srv = serverhub.ServerHub("127.0.0.1", 16250)
    srv.run()
    network_id = os.urandom(32)
    print("Server is up and running at 127.0.0.1:16250")

    # start a clienthub at each end
    GCSClient = clienthub.Clienthub(("127.0.0.1", 14650), ("127.0.0.1", 16250),
                                    network_id, 32)
    UASClient = clienthub.Clienthub(("127.0.0.1", 14550), ("127.0.0.1", 16250),
                                    network_id, 1)
    GCSClient.addinterface("127.0.0.1")
    UASClient.addinterface("127.0.0.1")
    GCSClient.start()
    print("GCS client is up and running at 127.0.0.1:14650")
    UASClient.start()
    print("UAS client is up and running at 127.0.0.1:14550")
# in this repo
from TelemXnet import serverhub

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip",
                        help="The IP of the network adapter to run on",
                        default="127.0.0.1")
    parser.add_argument("--port",
                        help="The server port",
                        type=int,
                        default=16250)
    args = parser.parse_args()

    srv = serverhub.ServerHub(args.ip, args.port)

    #start the server
    srv.run()
    print("Server running")

    # while waiting for a ctrl+c, sleep
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        pass

    # then close it all down
    srv.close()
    print("Closed Server")