我目前正在学习来自Linux.希望您仍然可以为我提供帮助.这是我的课程代码:
def main():
connection = socket.socket(socket.AF_INET, socket.SOCK_RAW,
socket.IPPROTO_IP)
#mainloop
raw_data, addr = connection.recvfrom(65536)
dest_mac, src_mac, eth_proto, data = ethernet_frame(raw_data)
print('\nEthernet Frame:')
print('Destination: {}, Source: {}, Protocol: {}'.format(dest_mac,
src_mac, eth_proto))
#unpack ethernet frame
def ethernet_frame(data):
dest_mac, src_mac, proto = struct.unpack('! 6s 6s H', data[:14])
return get_mac_addr(dest_mac), get_mac_addr(src_mac),
socket.htons(proto), data[14:]
#format MAC adress
def get_mac_addr(bytes_addr):
bytes_str = map('{:02x}'.format, bytes_addr)
return ':'.join(bytes_str).upper()
main()
在执行时,我收到以下错误:
OSError: [WinError 10022] An invalid argument was supplied
在“ connection.recvfrom(65536)”行中.
无论如何,是否将要在Linux上获得虚拟机?我应该等待吗?或者还有针对Windows的好的解决方案?