[PATCH 3/3] tests: Add a test of mesh path request TTL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Masashi Honma <masashi.honma@xxxxxxxxx>
---
 tests/hwsim/test_wmediumd.py | 95 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)

diff --git a/tests/hwsim/test_wmediumd.py b/tests/hwsim/test_wmediumd.py
index 9da54d3..cdc0ca3 100644
--- a/tests/hwsim/test_wmediumd.py
+++ b/tests/hwsim/test_wmediumd.py
@@ -34,6 +34,30 @@ ifaces :
 };
 """
 
+CFG3 = """
+ifaces :
+{
+    ids = ["%s", "%s", "%s", "%s", "%s" ];
+};
+
+model :
+{
+    type = "path_loss";
+    positions = (
+        (  0.0,   0.0),
+        ( 50.0,   0.0),
+        (100.0,   0.0),
+        (150.0,   0.0),
+        (200.0,   0.0)
+    );
+    tx_powers = (15.0, 15.0, 15.0, 15.0, 15.0);
+
+    model_name = "log_distance";
+    path_loss_exp = 3.5;
+    xg = 0.0;
+};
+"""
+
 def output_wmediumd_log(p, params, data):
     log_file = open(os.path.abspath(os.path.join(params['logdir'],
                                                  'wmediumd.log')), 'a')
@@ -170,3 +194,74 @@ def _test_wmediumd_path_simple(dev, apdev):
         dev[i].mesh_group_remove()
         check_mesh_group_removed(dev[i])
         dev[i].dump_monitor()
+
+def test_wmediumd_path_ttl(dev, apdev, params):
+    """test a mesh path request TTL"""
+    # 0 --- 1 --- 2 --- 3 --- 4
+    # Test the ttl of mesh path request work.
+    # If the ttl is shorter than path, the mesh path request should be dropped
+    fd, fn = tempfile.mkstemp()
+    try:
+        f = os.fdopen(fd, 'w')
+        f.write(CFG3 % (dev[0].own_addr(), dev[1].own_addr(), dev[2].own_addr(), dev[3].own_addr(), dev[4].own_addr()))
+        f.close()
+        p = start_wmediumd(fn, params)
+        try:
+            _test_wmediumd_path_ttl(dev, apdev, True)
+            _test_wmediumd_path_ttl(dev, apdev, False)
+        finally:
+            stop_wmediumd(p, params)
+    finally:
+        os.unlink(fn)
+
+def _test_wmediumd_path_ttl(dev, apdev, ok):
+    for i in range(0, 5):
+        check_mesh_support(dev[i])
+        add_open_mesh_network(dev[i], freq="2462", basic_rates="60 120 240")
+
+    # Check for mesh joined
+    for i in range(0, 5):
+        check_mesh_group_added(dev[i])
+
+        state = dev[i].get_status_field("wpa_state")
+        if state != "COMPLETED":
+            raise Exception("Unexpected wpa_state on dev" + str(i) + ": " + state)
+
+        mode = dev[i].get_status_field("mode")
+        if mode != "mesh":
+            raise Exception("Unexpected mode: " + mode)
+
+    # set mesh path request ttl
+    subprocess.check_call(["iw", "dev", dev[0].ifname, "set", "mesh_param", "mesh_element_ttl=" + ("4" if ok else "3")])
+
+    # Check for peer connected
+    for i in range(0, 5):
+        check_mesh_peer_connected(dev[i])
+    for i in range(1, 4):
+        check_mesh_peer_connected(dev[i])
+
+    # Test connectivity 0->4 and 0->4
+    hwsim_utils.test_connectivity(dev[0], dev[4], success_expected=ok)
+
+    # Check mpath table on 0
+    res, data = dev[0].cmd_execute(['iw', dev[0].ifname, 'mpath', 'dump'])
+    if res != 0:
+        raise Exception("iw command failed on dev0")
+    if ok:
+        if data.find(dev[1].own_addr() + ' ' +  dev[1].own_addr()) == -1 or \
+           data.find(dev[4].own_addr() + ' ' +  dev[1].own_addr()) == -1:
+            raise Exception("mpath not found on dev0:\n" + data)
+    else:
+        if data.find(dev[1].own_addr() + ' ' +  dev[1].own_addr()) == -1 or \
+           data.find(dev[4].own_addr() + ' 00:00:00:00:00:00') == -1:
+            raise Exception("mpath not found on dev0:\n" + data)
+    if data.find(dev[0].own_addr()) > -1 or \
+       data.find(dev[2].own_addr()) > -1 or \
+       data.find(dev[3].own_addr()) > -1:
+        raise Exception("invalid mpath found on dev0:\n" + data)
+
+    # remove mesh groups
+    for i in range(0, 5):
+        dev[i].mesh_group_remove()
+        check_mesh_group_removed(dev[i])
+        dev[i].dump_monitor()
-- 
2.7.4


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux