test_ping.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:netmon 作者: bullerian 项目源码 文件源码
def test_arp_ping(self):
        """test ARP ping - compare to arping utilite"""

        arp_ping = Ping(IFACE, ARP_NAME, TIMEOUT, False)

        for ip in list(ipaddress.ip_network(TEST_NETWORK).hosts())[:5]:
            try:
                # need arping installed
                with os.popen('arping -c {} -t {} {}'.format(COUNT,
                                                             TIMEOUT,
                                                             str(ip)), 'r'):
                    # get exit code
                    ec = os.wait()[1] & 0xFF00
                res = arp_ping.ping_host(str(ip))
            except PermissionException:
                print('Need root previlegies')

            if res[STATUS_INDEX] == ONLINE:
                self.assertTrue(ec == 0)
            else:
                self.assertFalse(ec == 0)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号