You want to use etherPkt.tostring(), not str(etherPkt).

-- Murphy

On Apr 13, 2012, at 9:07 AM, Rohan Gandhi wrote:

> Hi,
> 
> I am trying to send an ARP response, but on the receiver I can see the ASCII 
> for the src/dst addresses instead of binary.
> 
> The following is my code:
> 
> from nox.lib.packet.ethernet import ethernet
> 
> mysrc = "11:11:11:11:11:11"
> mydst = "01:02:03:04:05:06"
> 
>         etherPkt = ethernet() 
>         etherPkt.set_payload(arpResponse) 
>         etherPkt.type = ethernet.ARP_TYPE 
>         etherPkt.src = octstr_to_array(mysrc) #mysrc
>         etherPkt.dst = octstr_to_array(mydst) #mysrc
> 
> #        log.debug("ether pkt %s" % str(etherPkt)) 
> 
>         self.send_openflow_packet(dp, str(etherPkt), inport) 
> 
> on the receiver, the tcpdump shows me the received packet as:
> 
> 21:34:35.677597 3a:31:31:3a:31:31 (oui Unknown) > 5b:31:31:3a:31:31 (oui 
> Unknown), ethertype Unknown (0x3a31), length 41: 
>         0x0000:  5b31 313a 3131 3a31 313a 3131 3a31 313a  [11:11:11:11:11:
>         0x0010:  3131 3e30 313a 3032 3a30 333a 3034 3a30  11>01:02:03:04:0
>         0x0020:  353a 3036 3a41 5250 5d                   5:06:ARP]
> 
> where I get ASCII instead of byte values for all the header fields (and also 
> for the character ":"). I am guessing the problem might be while converting 
> to string and I might be doing something silly. Can someone please help me in 
> sending the correct bytes instead of the ASCII?
> 
> Thanks!!
> Rohan

Reply via email to