예제 #1
0
        settings.s_to_c_mb_list = []

        # client introduce server to client middleboxes
        for i in range(number_of_middleboxes):
            mbid = bytearray(os.urandom(64))
            permission = bytearray(1)
            permission[0] = random.randint(0, 1)
            mb = {'middlebox_id': mbid, 'middlebox_permission': permission}
            settings.s_to_c_mb_list.append(mb)

        time1 = time.time()
        for i in range(number_of_connections):
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            sock.connect((server_ip, server_port))

            # now use sock to establish TLS 1.3 connection with the remote server
            connection = TLSConnection(sock)
            connection.handshakeClientCert(settings=settings)
            # send page request to server
            request = bytearray()
            request.append((amt >> 16) & 0xff)
            request.append((amt >> 8) & 0xff)
            request.append(amt & 0xff)
            connection.sendall(request)
            # read page from server
            response = connection.recv(amt)
            connection.close()

        time2 = time.time()
        page_load_time = (time2 - time1) / number_of_connections
        print 'page load time is ' + str(page_load_time) + ' second'
예제 #2
0
        settings.csibekey = bytearray(32)
        settings.c_to_s_mb_list = []
        settings.s_to_c_mb_list = []

        # client introduce server to client middleboxes
        for i in range(number_of_middleboxes):
            mbid = bytearray(os.urandom(64))
            permission = bytearray(1)
            permission[0] = random.randint(0, 1)
            mb = {'middlebox_id': mbid, 'middlebox_permission': permission}
            settings.s_to_c_mb_list.append(mb)

        #print settings
        print len(settings.c_to_s_mb_list)
        print len(settings.s_to_c_mb_list)

        connection.handshakeClientCert(settings=settings)

        handshake_msg_size = connection._recordLayer._recordSocket.data_sent + connection._recordLayer._recordSocket.data_received
        print 'handshake message size is: ' + str(
            handshake_msg_size) + ' bytes'
        # test data transfer
        # s = 'hello world ' * 100000
        # connection.sendall(s)

        count = 0
        for i in range(10):
            connection.sendall('hello world' * 1000)
            data = connection.recv(20000)
            count += len(data)
            print 'received ' + str(count) + ' bytes data'