[nox-dev] using scapy with nox

2011-10-13 Thread Javier Liendo
hi experts,

a) is there a way to decode/parse a receiving packet inside nox using scapy?

b) is it possible to craft a packet using scapy and then use it (i.e.
send_openflow) inside nox?

regards,

javier
___
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev


Re: [nox-dev] using scapy with nox

2011-10-13 Thread Murphy McCauley
From the second listing, I think line 7 can be something like:
e = Ether(packet.arr.tostring())

(which is much more efficient and straightforward)

-- Murphy

On Oct 13, 2011, at 3:48 PM, Javier Liendo wrote:

 hi experts...
 
 i know it is of really bad etiquette answering over you own email, but
 as soon i sent this mail i did the following test which seems to be
 working...just wanted to share it and see if anybody sees anything
 wrong with this approach...
 
 i defined an hex-string to an hex-binary-blob function inside
 packet_utils.py (conversion method taken from Brian@stackoverflow)
 
 1 def octstr_to_hexbinary(octstr):
 2hexdigits = [int(x,16) for x in octstr]
 3blob = ''.join(struct.pack('B',(high4) + low) for high,low in
 zip(hexdigits[::2], hexdigits[1::2]))
 4return blob
 
 then on my controller program i did the following
 
 1 from scapy.all import *
 2 ...
 3 def arping_me(self, dpid, inport, packet, buf, bufid):
 4   If arping one of my own IPs respond
 5log.debug(+++ inside arping_me)
 6print array_to_octstr(packet.arr)
 7e=Ether(octstr_to_hexbinary(array_to_octstr(packet.arr)))
 8e.show()
 
 in (6) i'm printing the hex string representation of the packet...
 
 in (7) i'm calling octstr_to_hexbinary to get a binary blob that i
 could use with scapy...
 
 in (8) i get a variable 'e'  which can be scapy-manipulated...
 
 does this sounds right?
 
 regards,
 
 javier
 
 
 On Thu, Oct 13, 2011 at 4:40 PM, Javier Liendo jav...@liendo.net wrote:
 hi experts,
 
 a) is there a way to decode/parse a receiving packet inside nox using scapy?
 
 b) is it possible to craft a packet using scapy and then use it (i.e.
 send_openflow) inside nox?
 
 regards,
 
 javier
 
 ___
 nox-dev mailing list
 nox-dev@noxrepo.org
 http://noxrepo.org/mailman/listinfo/nox-dev

___
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev


Re: [nox-dev] using scapy with nox

2011-10-13 Thread Christian Esteve Rothenberg
Javier,

while not directly related to its use in NOX, you may want to have a
look at oftest, 1.0 test suites do use scapy for a number of tests...

Keep posting updates on your research,
regards,
Christian



On Thu, Oct 13, 2011 at 20:25, Javier Liendo jav...@liendo.net wrote:
 you are absolutely right...thanks for the tip...

 On Thu, Oct 13, 2011 at 6:18 PM, Murphy McCauley jam...@nau.edu wrote:
 From the second listing, I think line 7 can be something like:
 e = Ether(packet.arr.tostring())

 (which is much more efficient and straightforward)

 -- Murphy

 On Oct 13, 2011, at 3:48 PM, Javier Liendo wrote:

 hi experts...

 i know it is of really bad etiquette answering over you own email, but
 as soon i sent this mail i did the following test which seems to be
 working...just wanted to share it and see if anybody sees anything
 wrong with this approach...

 i defined an hex-string to an hex-binary-blob function inside
 packet_utils.py (conversion method taken from Brian@stackoverflow)

 1 def octstr_to_hexbinary(octstr):
 2    hexdigits = [int(x,16) for x in octstr]
 3    blob = ''.join(struct.pack('B',(high4) + low) for high,low in
 zip(hexdigits[::2], hexdigits[1::2]))
 4    return blob

 then on my controller program i did the following

 1 from scapy.all import *
 2 ...
 3 def arping_me(self, dpid, inport, packet, buf, bufid):
 4       If arping one of my own IPs respond
 5        log.debug(+++ inside arping_me)
 6        print array_to_octstr(packet.arr)
 7        e=Ether(octstr_to_hexbinary(array_to_octstr(packet.arr)))
 8        e.show()

 in (6) i'm printing the hex string representation of the packet...

 in (7) i'm calling octstr_to_hexbinary to get a binary blob that i
 could use with scapy...

 in (8) i get a variable 'e'  which can be scapy-manipulated...

 does this sounds right?

 regards,

 javier


 On Thu, Oct 13, 2011 at 4:40 PM, Javier Liendo jav...@liendo.net wrote:
 hi experts,

 a) is there a way to decode/parse a receiving packet inside nox using 
 scapy?

 b) is it possible to craft a packet using scapy and then use it (i.e.
 send_openflow) inside nox?

 regards,

 javier

 ___
 nox-dev mailing list
 nox-dev@noxrepo.org
 http://noxrepo.org/mailman/listinfo/nox-dev


 ___
 nox-dev mailing list
 nox-dev@noxrepo.org
 http://noxrepo.org/mailman/listinfo/nox-dev




-- 
Christian
___
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev