On 2014年11月19日 21:20, Salaheddine ZERKANE wrote:
> Hello,
> 
> I am a phd student working in SDN security and new in RYU, Could you please 
> help me to find out if it is possible to create rules in RYUusing matching on 
> TCP Flags such as : RST, FIN, SYNAck, etc. and if RYUsupports a parsing of 
> packet-in by thesetcpflags? If it is the case how please?

> RST, FIN, SYNAck, etc. and if RYUsupports a parsing of packet-in by 
> thesetcpflags? 
Is possible.
Ryu can generate a corresponding python object from a sequence of bytes of the 
packet. The following URL has describes how to use.

  
http://osrg.github.io/ryu-book/en/html/packet_lib.html#analysis-of-packet-parse

Of course, this feature also supports tcp.

  
http://ryu.readthedocs.org/en/latest/library_packet_ref.html#ryu.lib.packet.tcp.tcp

And I wrote a simple sample code.
Please try the following.

sample.py
-----------------------------------------------------------
from ryu.lib.packet.packet import Packet
from ryu.lib.packet import ethernet
from ryu.lib.packet import tcp
from ryu.lib.packet import ipv4
from ryu.lib.packet import packet_utils

# Generation of Packets (Serialization)
pkt = Packet()
pkt.add_protocol(ethernet.ethernet(dst='22:22:22:22:22:22', 
src='12:11:11:11:11:11', ethertype=2048))
pkt.add_protocol(ipv4.ipv4(tos=32, proto=6, src='192.168.10.10', 
dst='192.168.20.20', ttl=64))
pkt.add_protocol(tcp.tcp(dst_port=2222, bits=0b001100, option=str('\\x00' * 4), 
src_port=11111))
pkt.add_protocol('\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\\r\\x0e\\x0f\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f')

pkt.serialize()
bin_packet = pkt.data

# Analysis of Packet (Parse)
pkt = Packet(data=bin_packet)
pkt_tcp = pkt.get_protocol(tcp.tcp)

print pkt_tcp
# show TCP Flags (6bits)
print pkt_tcp.bits
-----------------------------------------------------------

xxx@xxx:xxx/ryu/ $ python sample.py 
tcp(ack=0,bits=12,csum=57105,dst_port=2222,offset=9,option=bytearray(b'\\x00\\x00\\x00\\x00'),seq=0,src_port=11111,urgent=0,window_size=0)
12

thanks

> 
> Thanks and regards,
> 
>  
> 
> *Meilleures salutations,*
> 
> *Salaheddine ZERKANE*
> 
>  
> 
> {P}
> 
>       
> 
> Doctorant
> Cubiq
> 
> {T}
> 
>       
> 
> +33 (0) 2 56 35 82 11
> 
>  
> 
> http://signature.b-com.com/logo-bleu.gif <http://www.b-com.com/>
> 
>  
> 
> ZAC DES CHAMPS BLANCS
> BÂT. A · 13 RUE CLAUDE CHAPPE
> 35510 CESSON-SÉVIGNÉ (FRance)
> 
>  
> 
>  
> 
>  
> 
>  
> 
> 
> 
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
> 
> 
> 
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> 

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to