我真诚地道歉,即使我用Google搜索并扫描了stackoverflow存档以获取我的答案..但即使在尝试了一些解决方法后,我仍然遇到同样的问题..
我有一个ubuntu主机。我正在调用我的python脚本。作为该脚本的一部分,它将登录到另一个远程ubuntu主机(scapy 2.2.0正在运行)并运行我的scapy函数以在一个众所周知的端口上生成单播pkt
这是scapy功能:
def send_scapy(self,port='vintf10',num_frames=10,scale_macs=0):
'''
Generates L2 frames(incl Payload) with both Src & Dest MAC == Unicast
num_frames for each SRC-MAC is sent out. Returns a list of SRC_MAC generated for further verifying in Flow & L2 Tables of VEM
'''
src_mac_list = []
for i in range(num_frames):
oui = [ 0x00, 0x11, 0x22,
random.randint(0x00, 0x7f),
random.randint(0x00, 0xff),
random.randint(0x00, 0xff) ]
src_mac = ':'.join(map(lambda x: "%02x" % x, oui))
src_mac_list.append(src_mac)
try:
payload = 'REMOTE REMOTE REMOTE REMOTE REMOTE'
brcd_log.info ("Payload of the to-be-generated frames = \n%s" % payload)
brcd_log.info (" SRC MAC LIST == %s" % src_mac_list)
for i in range(len(src_mac_list)):
print "MAC == %s" % src_mac_list[i]
#sendp(Ether(dst='00:16:17:18:19:20',src=src_mac_list[i])/IP()/payload,iface=port,count = 1)
pkt = Ether(dst='00:16:17:18:19:20',src=src_mac_list[i])/IP()
print "PKT == %s" % pkt
sendp(pkt,iface=port,count = 1)
brcd_log.info ("Sent Out of Port %s ,1 frame with Unicast Src MAC %s and Unicast Dest MAC 00:16:17:18:19:20" %(port,src_mac_list[i]))
when I run on calling this function as below, the following error comes:
self.remote_kvm = Kvm_Infra(self.vem_2_ip,self.vem2_uname,self.vem2_pwd)
self.remote_kvm.send_scapy() ##
Error:
root@com-node12-36:/home/localadmin# 2014-04-07 22:47:57,520 [INFO] brcd_os - Payload of the to-be-generated frames =
REMOTE REMOTE REMOTE REMOTE REMOTE
2014-04-07 22:47:57,524 [INFO] brcd_os - SRC MAC LIST == ['00:11:22:23:bb:88', '00:11:22:5a:e6:b8', '00:11:22:13:70:39', '00:11:22:42:b6:11', '00:11:22:16:a4:ff', '00:11:22:1c:23:88', '00:11:22:3a:3b:b6', '00:11:22:3e:dd:f0', '00:11:22:03:5b:72', '00:11:22:7b:16:d7']
MAC == 00:11:22:23:bb:88
PKT == "#»E@
2014-04-07 22:47:57,531 [INFO] brcd_os - Exception Type = <class 'socket.error'>, Exception Object = [Errno 19] No such device
&LT;&LT;&LT;&LT;&LT;&LT;&LT;&LT;&LT;&LT;&LT;
我在这里公然失踪了什么?
当我在本地主机(调用python脚本的主机)中调用相同的函数时,它工作正常。此外,在远程主机中,当我手动尝试相同的步骤(该功能对同一个有效端口执行的操作)时,它可以正常工作
答案 0 :(得分:0)
我认为问题可能是在与远程主机通信时,传输的值将转换为unicode
。例如,如果用于传输IP地址的格式为json
,则可能发生这种情况。然后,虽然打印值没有显示任何特殊情况,甚至在与预期的str
值进行比较时,一切看起来都很好,但实际上底层基础设施可能无法很好地处理unicode
。尝试打印所有传输值的类型并将其转换回str
。