• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python wpan.verify函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中wpan.verify函数的典型用法代码示例。如果您正苦于以下问题:Python verify函数的具体用法?Python verify怎么用?Python verify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了verify函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: verify_address

def verify_address(node_list, prefix):
    """
    This function verifies that all nodes in the `node_list` contain an IPv6 address with the given `prefix`.
    """
    for node in node_list:
        all_addrs = wpan.parse_list(node.get(wpan.WPAN_IP6_ALL_ADDRESSES))
        verify(any([addr.startswith(prefix[:-1]) for addr in all_addrs]))
开发者ID:nodish,项目名称:openthread,代码行数:7,代码来源:test-010-on-mesh-prefix-config-gateway.py


示例2: verify_no_prefix

def verify_no_prefix(node_list, prefix):
    """
    This function verifies that the `prefix` is NOT present on any node in the `node_list`.
    """
    for node in node_list:
        prefixes = wpan.parse_on_mesh_prefix_result(node.get(wpan.WPAN_THREAD_ON_MESH_PREFIXES))
        for p in prefixes:
            verify(not p.prefix == prefix)
开发者ID:abtink,项目名称:openthread,代码行数:8,代码来源:test-026-slaac-address-wpantund.py


示例3: check_address_prefix_removed

def check_address_prefix_removed():
    # Verify that address is removed from r2
    verify(r2.find_ip6_address_with_prefix(IP6_PREFIX_1) == '')
    # Verify that the related prefix is also removed on all nodes
    for node in all_nodes:
        prefixes = wpan.parse_on_mesh_prefix_result(node.get(wpan.WPAN_THREAD_ON_MESH_PREFIXES))
        for p in prefixes:
            verify(p.prefix != IP6_PREFIX_1)
开发者ID:abtink,项目名称:openthread,代码行数:8,代码来源:test-014-ip6-address-add.py


示例4: send_mcast

def send_mcast(src_node, src_addr, mcast_addr, recving_nodes, non_recving_nodes=[], msg_len=30, mcast_hops=5):
    """
    Send a multicast message with given `len` from `src_node` using `src_addr` to the multicast address `mcast_addr`.
    Verify that the message is received on all nodes in `recving_nodes` list and that it is not received on all
    nodes in `non_recving_nodes` list.
    """
    sender = src_node.prepare_tx(src_addr, mcast_addr, msg_len, mcast_hops=mcast_hops)
    recvers = [node.prepare_rx(sender) for node in recving_nodes]
    listeners = [node.preapre_listener(sender.dst_port, timeout=0.5) for node in non_recving_nodes]

    wpan.Node.perform_async_tx_rx()

    verify(sender.was_successful)
    for recvr in recvers:
        verify(recvr.was_successful)
    for lsnr in listeners:
        # `all_rx_msg` contains a list of (msg_content, (src_addr, src_port)).
        verify(len(lsnr.all_rx_msg) == 0 or
            all([msg[1][0] != sender.src_addr and msg[1][1] != sender.src_port for msg in lsnr.all_rx_msg]))
开发者ID:abtink,项目名称:openthread,代码行数:19,代码来源:test-023-multicast-traffic.py


示例5: check_c2_is_associated

def check_c2_is_associated():
    verify(c2.is_associated())
开发者ID:abtink,项目名称:openthread,代码行数:2,代码来源:test-603-channel-manager-announce-recovery.py


示例6: check_addresses_and_prefixes

def check_addresses_and_prefixes():
    # Verify that the addresses are present in "IPv6:AllAddresses" wpantund property on the corresponding node.
    verify(r2.find_ip6_address_with_prefix(IP6_PREFIX_1)   == IP6_ADDR_1)
    verify(fed1.find_ip6_address_with_prefix(IP6_PREFIX_2) == IP6_ADDR_2)
    verify(sed2.find_ip6_address_with_prefix(IP6_PREFIX_3) == IP6_ADDR_3)

    # Verify that all prefixes are present in network data on all nodes (with correct flags).
    for prefix in [IP6_PREFIX_1, IP6_PREFIX_2, IP6_PREFIX_3]:
        for node in all_nodes:
            prefixes = wpan.parse_on_mesh_prefix_result(node.get(wpan.WPAN_THREAD_ON_MESH_PREFIXES))
            for p in prefixes:
                if p.prefix == prefix:
                    verify(p.prefix_len == '64')
                    verify(p.is_stable())
                    verify(p.is_on_mesh() == True)
                    verify(p.is_preferred() == True)
                    verify(p.is_def_route() == False)
                    verify(p.is_slaac() == False)
                    verify(p.is_dhcp() == False)
                    verify(p.is_config() == False)
                    verify(p.priority == "med")
                    break
            else: # `for` loop finished without finding the prefix.
                raise wpan.VerifyError('Did not find prefix {} on node {}'.format(prefix, node))

    # Verify that IPv6 address of `sed2` is present on `r2` (its parent) "Thread:ChildTable:Addresses".
    addr_str = r2.get(wpan.WPAN_THREAD_CHILD_TABLE_ADDRESSES)
    # search for index on address in the `addr_str` and ensure it is non-negative.
    verify(addr_str.find(IP6_ADDR_3) >= 0)
开发者ID:abtink,项目名称:openthread,代码行数:29,代码来源:test-014-ip6-address-add.py


示例7: verify_prefix

# Wait for on-mesh prefix to be updated
time.sleep(0.5)
verify_prefix(all_nodes, prefix1, stable=True, on_mesh=True, slaac=True)
verify_address(all_nodes, prefix1)

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Test `add-prefix` and `remove-prefix`

r1.add_prefix(prefix4, 48, priority="1", stable=False, on_mesh=True, slaac=False, dhcp=True, configure=False,
    default_route=True, preferred=False)
verify_prefix([r1], prefix4, 48, priority="high", stable=False, on_mesh=True, slaac=False, dhcp=True, configure=False,
    default_route=True, preferred=False)

# Remove prefix and verify that it is removed from list
r1.remove_prefix(prefix4, 48)
time.sleep(0.5)
verify(r1.get(wpan.WPAN_THREAD_ON_MESH_PREFIXES).find(prefix4) < 0)

r1.add_prefix(prefix4, 48, priority="-1", stable=True, on_mesh=False, slaac=True, dhcp=False, configure=True,
    default_route=False, preferred=True)
verify_prefix([r1], prefix4, 48, priority="low", stable=True, on_mesh=False, slaac=True, dhcp=False, configure=True,
    default_route=False, preferred=True)


#-----------------------------------------------------------------------------------------------------------------------
# Test finished

wpan.Node.finalize_all_nodes()

print '\'{}\' passed.'.format(test_name)
开发者ID:nodish,项目名称:openthread,代码行数:30,代码来源:test-010-on-mesh-prefix-config-gateway.py


示例8: check_r3_router_table

def check_r3_router_table():
    router_table = wpan.parse_router_table_result(r3.get(wpan.WPAN_THREAD_ROUTER_TABLE))
    verify(len(router_table) == 4)
    for entry in router_table:
        if entry.rloc16 == r1_rloc:
            # r3 should be directly connected to r1.
            verify(entry.is_link_established())
            verify(entry.ext_address == r1_ext_addr)
        elif entry.rloc16 == r2_rloc:
            # r3 should be directly connected to r2.
            verify(entry.is_link_established())
            verify(entry.ext_address == r2_ext_addr)
        elif entry.rloc16 == r3_rloc:
            pass
        elif entry.rloc16 == r4_rloc:
            # r3 should be directly connected to r4.
            verify(entry.is_link_established());
            verify(entry.ext_address == r4_ext_addr)
        else:
            raise(wpan.VerifyError("unknown entry in the router table of r3"))
开发者ID:abtink,项目名称:openthread,代码行数:20,代码来源:test-020-router-table.py


示例9: network

node2 = wpan.Node()

#-----------------------------------------------------------------------------------------------------------------------
# Init all nodes

wpan.Node.init_all_nodes()

#-----------------------------------------------------------------------------------------------------------------------
# Build network topology

# Two-node network (node1 leader/router, node2 sleepy-end-device)

node1.form('test-PAN')
node2.join_node(node1, node_type=wpan.JOIN_TYPE_SLEEPY_END_DEVICE)

verify(node2.get(wpan.WPAN_STATE) == wpan.STATE_ASSOCIATED)
verify(node2.get(wpan.WPAN_NAME) == node1.get(wpan.WPAN_NAME))
verify(node2.get(wpan.WPAN_PANID) == node1.get(wpan.WPAN_PANID))
verify(node2.get(wpan.WPAN_XPANID) == node1.get(wpan.WPAN_XPANID))



#-----------------------------------------------------------------------------------------------------------------------
# Test implementation

# Get the link local addresses
ll1 = node1.get(wpan.WPAN_IP6_LINK_LOCAL_ADDRESS)[1:-1]
ll2 = node2.get(wpan.WPAN_IP6_LINK_LOCAL_ADDRESS)[1:-1]

# Get the mesh-local addresses
ml1 = node1.get(wpan.WPAN_IP6_MESH_LOCAL_ADDRESS)[1:-1]
开发者ID:pvanhorn,项目名称:openthread,代码行数:31,代码来源:test-007-traffic-router-sleepy.py


示例10: verify

node = wpan.Node()

#-----------------------------------------------------------------------------------------------------------------------
# Init all nodes

wpan.Node.init_all_nodes()

#-----------------------------------------------------------------------------------------------------------------------
# Build network topology

node.form("permit-join-test")

#-----------------------------------------------------------------------------------------------------------------------
# Test implementation

verify(node.get(wpan.WPAN_NETWORK_ALLOW_JOIN) == 'false')

node.permit_join()
verify(node.get(wpan.WPAN_NETWORK_ALLOW_JOIN) == 'true')

node.permit_join('0')
verify(node.get(wpan.WPAN_NETWORK_ALLOW_JOIN) == 'false')

node.permit_join(port='1234')
verify(node.get(wpan.WPAN_NETWORK_ALLOW_JOIN) == 'true')

node.permit_join('0')
verify(node.get(wpan.WPAN_NETWORK_ALLOW_JOIN) == 'false')

# check the timeout
node.permit_join('1')
开发者ID:abtink,项目名称:openthread,代码行数:31,代码来源:test-008-permit-join.py


示例11: verify

#-----------------------------------------------------------------------------------------------------------------------
# Init all nodes

wpan.Node.init_all_nodes()

#-----------------------------------------------------------------------------------------------------------------------
# Test implementation

# default values after reset
DEFAULT_KEY = '[00112233445566778899AABBCCDDEEFF]'
DEFAULT_NAME = '"OpenThread"'
DEFAULT_PANID = '0xFFFF'
DEFAULT_XPANID = '0xDEAD00BEEF00CAFE'

verify(node.get(wpan.WPAN_STATE) == wpan.STATE_OFFLINE)
verify(node.get(wpan.WPAN_KEY) == DEFAULT_KEY)
verify(node.get(wpan.WPAN_NAME) == DEFAULT_NAME)
verify(node.get(wpan.WPAN_PANID) == DEFAULT_PANID)
verify(node.get(wpan.WPAN_XPANID) == DEFAULT_XPANID)

# Form a network

node.form('asha')
verify(node.get(wpan.WPAN_STATE) == wpan.STATE_ASSOCIATED)
verify(node.get(wpan.WPAN_NODE_TYPE) == wpan.NODE_TYPE_LEADER)
verify(node.get(wpan.WPAN_NAME) == '"asha"')
verify(node.get(wpan.WPAN_KEY) != DEFAULT_KEY)
verify(node.get(wpan.WPAN_PANID) != DEFAULT_PANID)
verify(node.get(wpan.WPAN_XPANID) != DEFAULT_XPANID)
开发者ID:nodish,项目名称:openthread,代码行数:29,代码来源:test-002-form.py


示例12: verify

# Creating `wpan.Nodes` instances

node1 = wpan.Node()
node2 = wpan.Node()

#-----------------------------------------------------------------------------------------------------------------------
# Init all nodes

wpan.Node.init_all_nodes()

#-----------------------------------------------------------------------------------------------------------------------
# Test implementation

# Form a network on node1
node1.form('PAN-aB71n')
verify(node1.get(wpan.WPAN_STATE) == wpan.STATE_ASSOCIATED)
verify(node1.get(wpan.WPAN_NODE_TYPE) == wpan.NODE_TYPE_LEADER)

# Join from node2 as a router
node2.join_node(node1, node_type=wpan.JOIN_TYPE_ROUTER)
verify(node2.get(wpan.WPAN_STATE) == wpan.STATE_ASSOCIATED)
verify(node2.get(wpan.WPAN_NAME) == node1.get(wpan.WPAN_NAME))
verify(node2.get(wpan.WPAN_PANID) == node1.get(wpan.WPAN_PANID))
verify(node2.get(wpan.WPAN_XPANID) == node1.get(wpan.WPAN_XPANID))
verify(node2.get(wpan.WPAN_KEY) == node1.get(wpan.WPAN_KEY))

node2.leave()

# Join from node2 as an end-device
node2.join_node(node1, node_type=wpan.JOIN_TYPE_END_DEVICE)
verify(node2.get(wpan.WPAN_STATE) == wpan.STATE_ASSOCIATED)
开发者ID:pvanhorn,项目名称:openthread,代码行数:31,代码来源:test-003-join.py


示例13: verify_channel

# Test implementation

# Reset c2 and keep it in detached state
c2.set('Daemon:AutoAssociateAfterReset', 'false')
c2.reset();

# Switch the rest of network to channel 26
router.set(wpan.WPAN_CHANNEL_MANAGER_NEW_CHANNEL, '26')
verify_channel([router, c1], 26)

# Now re-enable c2 and verify that it does attach to router and is on channel 26
# c2 would go through the ML Announce recovery.

c2.set('Daemon:AutoAssociateAfterReset', 'true')
c2.reset();
verify(int(c2.get(wpan.WPAN_CHANNEL), 0) == 11)

# wait for 20s for c2 to be attached/associated
def check_c2_is_associated():
    verify(c2.is_associated())

wpan.verify_within(check_c2_is_associated, 20)

# Check that c2 is now on channel 26.
verify(int(c2.get(wpan.WPAN_CHANNEL), 0) == 26)

#-----------------------------------------------------------------------------------------------------------------------
# Test finished

wpan.Node.finalize_all_nodes()
开发者ID:abtink,项目名称:openthread,代码行数:30,代码来源:test-603-channel-manager-announce-recovery.py


示例14: range

for router in routers[1:]:
    router.join_node(routers[0], wpan.JOIN_TYPE_ROUTER)

for num in range(1, NUM_ROUTERS):
    ed[num].join_node(routers[num], wpan.JOIN_TYPE_END_DEVICE)

for num in range(NUM_CHILDREN):
    children[num].join_node(routers[0], wpan.JOIN_TYPE_SLEEPY_END_DEVICE)
    children[num].set(wpan.WPAN_POLL_INTERVAL,'300')

#-----------------------------------------------------------------------------------------------------------------------
# Test implementation

for router in routers[1:]:
    verify(router.get(wpan.WPAN_NODE_TYPE) == wpan.NODE_TYPE_ROUTER)

# Get and parse the neighbor table on routers[0].
neighbor_table = wpan.parse_neighbor_table_result(routers[0].get(wpan.WPAN_THREAD_NEIGHBOR_TABLE))

verify(len(neighbor_table) == NUM_ROUTERS - 1 + NUM_CHILDREN)

# Verify that all children are seen in the neighbor table
for child in children:
    ext_addr = child.get(wpan.WPAN_EXT_ADDRESS)[1:-1]
    for entry in neighbor_table:
        if entry.ext_address == ext_addr:
            break;
    else:
        raise wpan.VerifyError('Failed to find a child entry for extended address {} in table'.format(ext_addr))
开发者ID:abtink,项目名称:openthread,代码行数:29,代码来源:test-016-neighbor-table.py


示例15: check_c2_is_removed_from_r2_child_table

def check_c2_is_removed_from_r2_child_table():
    child_table = wpan.parse_list(r2.get(wpan.WPAN_THREAD_CHILD_TABLE))
    verify(len(child_table) == 0)
开发者ID:abtink,项目名称:openthread,代码行数:3,代码来源:test-021-address-cache-table.py


示例16: check_r1_router_table

def check_r1_router_table():
    router_table = wpan.parse_router_table_result(r1.get(wpan.WPAN_THREAD_ROUTER_TABLE))
    verify(len(router_table) == 3)
    for entry in router_table:
        if entry.rloc16 == r3_rloc:
            verify(entry.next_hop != INVALID_ROUTER_ID)
开发者ID:abtink,项目名称:openthread,代码行数:6,代码来源:test-021-address-cache-table.py


示例17: verify

r3.whitelist_node(r2)
r3.join_node(r2, wpan.JOIN_TYPE_ROUTER)

c3.whitelist_node(r3)
r3.whitelist_node(c3)
c3.join_node(r3, wpan.JOIN_TYPE_END_DEVICE)

#-----------------------------------------------------------------------------------------------------------------------
# Test implementation
#

ROUTER_TABLE_WAIT_TIME = 30 / speedup + 5

INVALID_ROUTER_ID = 63

verify(r1.get(wpan.WPAN_NODE_TYPE) == wpan.NODE_TYPE_LEADER)
verify(r2.get(wpan.WPAN_NODE_TYPE) == wpan.NODE_TYPE_ROUTER)
verify(r3.get(wpan.WPAN_NODE_TYPE) == wpan.NODE_TYPE_ROUTER)
verify(c1.get(wpan.WPAN_NODE_TYPE) == wpan.NODE_TYPE_END_DEVICE)
verify(c2.get(wpan.WPAN_NODE_TYPE) == wpan.NODE_TYPE_SLEEPY_END_DEVICE)
verify(c3.get(wpan.WPAN_NODE_TYPE) == wpan.NODE_TYPE_END_DEVICE)

r2_rloc = int(r2.get(wpan.WPAN_THREAD_RLOC16), 16)
r3_rloc = int(r3.get(wpan.WPAN_THREAD_RLOC16), 16)
c3_rloc = int(c3.get(wpan.WPAN_THREAD_RLOC16), 16)

# Wait till we have a valid "next hop" route on r1 towards r3
def check_r1_router_table():
    router_table = wpan.parse_router_table_result(r1.get(wpan.WPAN_THREAD_ROUTER_TABLE))
    verify(len(router_table) == 3)
    for entry in router_table:
开发者ID:abtink,项目名称:openthread,代码行数:31,代码来源:test-021-address-cache-table.py


示例18: verify

#-----------------------------------------------------------------------------------------------------------------------
# Test implementation

NUM_MSGS = 3
MSG_LENS = [40, 100, 400, 800, 1000]

# Send from the first router in the chain to the last one.

src = routers[0].get(wpan.WPAN_IP6_MESH_LOCAL_ADDRESS)[1:-1]
dst = routers[-1].get(wpan.WPAN_IP6_MESH_LOCAL_ADDRESS)[1:-1]

for msg_length in MSG_LENS:
    sender = routers[0].prepare_tx(src, dst, msg_length, NUM_MSGS)
    recver = routers[-1].prepare_rx(sender)
    wpan.Node.perform_async_tx_rx()
    verify(sender.was_successful)
    verify(recver.was_successful)

# Send from the SED child of the last router to the SED child of the first router.

src = sed_children[-1].get(wpan.WPAN_IP6_MESH_LOCAL_ADDRESS)[1:-1]
dst = sed_children[0].get(wpan.WPAN_IP6_MESH_LOCAL_ADDRESS)[1:-1]

for msg_length in MSG_LENS:
    sender = sed_children[-1].prepare_tx(src, dst, msg_length, NUM_MSGS)
    recver = sed_children[0].prepare_rx(sender)
    wpan.Node.perform_async_tx_rx()
    verify(sender.was_successful)
    verify(recver.was_successful)

# Send from the FED child of the first router to the FED child of the last router.
开发者ID:abtink,项目名称:openthread,代码行数:31,代码来源:test-012-multi-hop-traffic.py


示例19: check_r2_neighbor_table

def check_r2_neighbor_table():
    verify(r2.is_associated())
    verify_neighbor_table(r2, [r1])
开发者ID:abtink,项目名称:openthread,代码行数:3,代码来源:test-028-router-leader-reset-recovery.py


示例20: int

#-----------------------------------------------------------------------------------------------------------------------
# Build network topology

node.form('channel-manager', channel=24)

#-----------------------------------------------------------------------------------------------------------------------
# Test implementation

all_channls_mask   = int('0x7fff800', 0)
chan_12_to_15_mask = int('0x000f000', 0)
chan_15_to_17_mask = int('0x0038000', 0)

# Set supported channel mask to be all channels
node.set(wpan.WPAN_CHANNEL_MANAGER_SUPPORTED_CHANNEL_MASK, str(all_channls_mask))
verify(int(node.get(wpan.WPAN_CHANNEL_MANAGER_SUPPORTED_CHANNEL_MASK), 0) == all_channls_mask)

# Sleep for 4 second with speedup factor of 10,000 this is more than 11 hours.
time.sleep(4)

verify(int(node.get(wpan.WPAN_CHANNEL_MONITOR_SAMPLE_COUNT), 0) > 970)

# Verify the initial value of `NEW_CHANNEL` (should be zero if there has been no channel change so far).

verify(int(node.get(wpan.WPAN_CHANNEL_MANAGER_NEW_CHANNEL), 0) == 0)

# Issue a channel-select with quality check enabled, and verify that no action is taken.

node.set(wpan.WPAN_CHANNEL_MANAGER_CHANNEL_SELECT, 'false')
verify(int(node.get(wpan.WPAN_CHANNEL_MANAGER_NEW_CHANNEL), 0) == 0)
开发者ID:pvanhorn,项目名称:openthread,代码行数:29,代码来源:test-602-channel-manager-channel-select.py



注:本文中的wpan.verify函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python wpasupplicant.WpaSupplicant类代码示例发布时间:2022-05-26
下一篇:
Python utils.get_admin_site_name函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap