cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

Cisco Community Designated VIP Class of 2020

679
Views
1
Helpful
0
Replies
Highlighted
Cisco Employee

Packet creation for onePK DPSS using Scapy

Other contributors have shown how it is possible to use libnet to create packets for injection by the DPSS. An alternate approach is to use a Python tool called Scapy in conjunction with embedding a Python interpreter in your C program for the DPSS. Attached is tar file showing how to invoke a simple Scapy script from a C application, get back the created packet and do a hex dump in the C code. While using the DPSS, a call to a packet inject routine could be used instead. The attached sample depends on:

The idea of this sample is to show how the capabilities of Scapy can be leveraged for flexible packet creation. The initial hook was discovering that libnet could not easily create q-in-q packets, but that a simple Scapy invocation such as this:

p = Ether(dst='ff:ff:ff:ff:ff:ff', src='00:01:02:03:04:05')/Dot1Q(vlan=1)/Dot1Q(vlan=10)/IP(dst='255.255.255.255', src='192.168.0.1')/ICMP()

...allowed a q-in-q packet to be created very easily...as well as many other packet formats.

The sample could be extended to allow for a range of packet creation routines, which I leave as an exercise for the interested reader. Further, Scapy has a very full set of packet parsing capabilities that could be similarly leveraged, but I leave that as an exercise for the reader!!

Please comment if you find this example helpful or if it inspires other thoughts.

Cheers,

Einar

Everyone's tags (4)
Content for Community-Ad
FusionCharts will render here