当前位置: 首页>>代码示例>>Python>>正文


Python Host.ip方法代码示例

本文整理汇总了Python中host.Host.ip方法的典型用法代码示例。如果您正苦于以下问题:Python Host.ip方法的具体用法?Python Host.ip怎么用?Python Host.ip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在host.Host的用法示例。


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

示例1: initialize

# 需要导入模块: from host import Host [as 别名]
# 或者: from host.Host import ip [as 别名]
	def initialize(self):
		if self.subnet:
			address_range = self.get_address_range(self.subnet)
			print('Size of network: ' + str(address_range.size()))
			self.alive_hosts = self.get_alive_hosts(address_range)

			for counter, ip in enumerate(self.alive_hosts):
				host = Host()
				host.ip = ip
				host.id += str(counter)
				self.host_list.append(host)

		else:
			host = Host()
			host.ip = self.address
			self.add_host(host)
开发者ID:logileifs,项目名称:NetCrawler,代码行数:18,代码来源:netcrawler.py

示例2: get_arp_cache

# 需要导入模块: from host import Host [as 别名]
# 或者: from host.Host import ip [as 别名]
	def get_arp_cache(self, host):
		"""Get ARP table from host"""

		results = Crawler.snmp.walk(host.ip, '.1.3.6.1.2.1.4.22.1.2.' + str(host.interface))

		if results is not None:
			for result in results:
				for name, val in result:
					print(str(name) + ' = ' + hex_to_mac(val))
					if str(name).find('1.3.6.1.2.1.4.22.1.2.' + str(host.interface)) != -1:
						new_host = Host()
						new_host.ip = str(name).split('1.3.6.1.2.1.4.22.1.2.' + str(host.interface) + '.',1)[1]
						#print('new host ip: ' + new_host.ip)
						new_host.mac = hex_to_mac(val)
						#print('new host mac: ' + new_host.mac)

						self.add_host(new_host)
开发者ID:logileifs,项目名称:NetCrawler,代码行数:19,代码来源:netcrawler.py

示例3: create_host

# 需要导入模块: from host import Host [as 别名]
# 或者: from host.Host import ip [as 别名]
	def create_host(self, ip_addr):
		"""Create a new host"""

		#print('CREATING NEW HOST WITH IP ' + str(ip_addr))

		if self.ip_exists(ip_addr):
			#print('\tIP ALREADY EXISTS')
			return self.get_host_by_ip(ip_addr)

		new_host = Host()
		new_host.id += str(self.host_counter)
		new_host.ip = ip_addr
		new_host.add_ip(ip_addr)

		self.host_counter += 1

		self.all_hosts.append(new_host)
		self.add_to_host_list(new_host)

		return new_host
开发者ID:logileifs,项目名称:NetCrawler,代码行数:22,代码来源:netcrawler2.py

示例4: get_neighbors

# 需要导入模块: from host import Host [as 别名]
# 或者: from host.Host import ip [as 别名]
	def get_neighbors(self, host):	#needs more testing
		"""Get list of host neighbors using Cisco Discovery Protocol"""

		print('Getting neighbors')
		neighbors = []
		host.visited = True

		results = Crawler.snmp.walk(host.ip, self.oid.neighbors2)

		if results is None:
			return []

		for result in results:
			for name, val in result:
				new_host = Host()
				new_host.ip = hex_to_ip(val)
				new_host.id = self.get_host_id((new_host.ip))
				if new_host.id is not None:
					neighbors.append(new_host.id)

		return neighbors
开发者ID:logileifs,项目名称:NetCrawler,代码行数:23,代码来源:netcrawler.py

示例5: Host

# 需要导入模块: from host import Host [as 别名]
# 或者: from host.Host import ip [as 别名]
elementos = []

# __      __      __
#|  |    |  |    |  |
#|  |----|  |----|  |
#|--|    |--|    |--|
# h0      r0      h1

rotas ={'10.0.0.0': '0', '10.1.1.0': '1'}



#Rede
#-hosts
h0 = Host("h0")
h0.ip = '10.0.0.1'
h0.setPapel('ircc')
h0
h1 = Host("h1")
h1.ip = '10.1.1.1'
h1.setPapel('ircc')
h1
#-roteadores
r0 = Router("r0", 2)
ipRouter = ['0', '10.0.0.2','1','10.1.1.2', '2' , '192.168.3.3']
r0.setIp(ipRouter)
r0
#-enlaces
e0 = Enlace(h0, r0.getPorta(0), "10M", "5s")
e1 = Enlace(h1, r0.getPorta(1), "10M", "5s")
#e1 = Enlace(h0, h1, "10M", "5s")
开发者ID:Evnsan,项目名称:MAC0448,代码行数:33,代码来源:test.py


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