1# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5from autotest_lib.client.common_lib.cros.network import ping_runner
6from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes
7from autotest_lib.server.cros.network import hostap_config
8from autotest_lib.server.cros.network import wifi_cell_test_base
9
10
11class network_WiFi_RxFrag(wifi_cell_test_base.WiFiCellTestBase):
12    """Test that the DUT can reassemble packet fragments."""
13    version = 1
14
15
16    def run_once(self):
17        """Test body.
18
19        When fragthreshold is set, packets larger than the threshold are
20        broken up by the AP and sent in fragments. The DUT needs to reassemble
21        these fragments to reconstruct the original packets before processing
22        them.
23
24        """
25        configuration = hostap_config.HostapConfig(
26                frequency=2437,
27                mode=hostap_config.HostapConfig.MODE_11G,
28                frag_threshold=256)
29        self.context.configure(configuration)
30        self.context.router.start_capture(configuration.frequency)
31        assoc_params = xmlrpc_datatypes.AssociationParameters()
32        assoc_params.ssid = self.context.router.get_ssid()
33        self.context.assert_connect_wifi(assoc_params)
34        build_config = lambda size: ping_runner.PingConfig(
35                self.context.client.wifi_ip, size=size)
36        self.context.assert_ping_from_server(ping_config=build_config(256))
37        self.context.assert_ping_from_server(ping_config=build_config(512))
38        self.context.assert_ping_from_server(ping_config=build_config(1024))
39        self.context.assert_ping_from_server(ping_config=build_config(1500))
40        self.context.client.shill.disconnect(assoc_params.ssid)
41        self.context.router.deconfig()
42