frenetic-lang / frenetic

The Frenetic Programming Language and Runtime System
http://www.frenetic-lang.org/
Other
223 stars 51 forks source link

Two flow_mod instructions #541

Closed sushiljain1989 closed 7 years ago

sushiljain1989 commented 7 years ago

Hi,

I am using frenetic as controller and running a simple application and capturing the packets using tshark. As per my application, there should be one flow rule in the switch and when I execute dpctl dump-flows, it also returns only one rule. But when I look at the output generated by tshark, there are two flow_mod instructions(line 18 and 22, see below), could anyone explain to me why it's the case?

tshark output :

`1 0.000000000 127.0.0.1 ?~F~R 127.0.0.1 TCP 74 47418?~F~R6633 [SYN] Seq=0 Win=43690 Len=0 MSS=65495 SACK_PERM=1 TSval=7474071 TSecr=0 WS=512

2 0.000012872 127.0.0.1 ?~F~R 127.0.0.1 TCP 74 6633?~F~R47418 [SYN, ACK] Seq=0 Ack=1 Win=43690 Len=0 MSS=65495 SACK_PERM=1 TSval=7474071 TSecr=7474071 WS=512

3 0.000024780 127.0.0.1 ?~F~R 127.0.0.1 TCP 66 47418?~F~R6633 [ACK] Seq=1 Ack=1 Win=44032 Len=0 TSval=7474071 TSecr=7474071

4 0.002099696 127.0.0.1 ?~F~R 127.0.0.1 TCP 74 6633?~F~R47418 [PSH, ACK] Seq=1 Ack=1 Win=44032 Len=8 TSval=7474072 TSecr=7474071

5 0.002123409 127.0.0.1 ?~F~R 127.0.0.1 TCP 66 47418?~F~R6633 [ACK] Seq=1 Ack=9 Win=44032 Len=0 TSval=7474072 TSecr=7474072

6 0.007420721 127.0.0.1 ?~F~R 127.0.0.1 OpenFlow 74 Type: OFPT_HELLO

7 0.007442474 127.0.0.1 ?~F~R 127.0.0.1 TCP 66 6633?~F~R47418 [ACK] Seq=9 Ack=9 Win=44032 Len=0 TSval=7474073 TSecr=7474073

8 0.007680840 :: ?~F~R ff02::16 OpenFlow 174 Type: OFPT_PACKET_IN

9 0.007689056 127.0.0.1 ?~F~R 127.0.0.1 TCP 66 6633?~F~R47418 [ACK] Seq=9 Ack=117 Win=44032 Len=0 TSval=7474073 TSecr=7474073

10 0.012062290 127.0.0.1 ?~F~R 127.0.0.1 OpenFlow 74 Type: OFPT_FEATURES_REQUEST

11 0.012318360 127.0.0.1 ?~F~R 127.0.0.1 OpenFlow 290 Type: OFPT_FEATURES_REPLY

12 0.013528244 127.0.0.1 ?~F~R 127.0.0.1 TCP 128 8984?~F~R56293 [PSH, ACK] Seq=1 Ack=1 Win=86 Len=62 TSval=7474075 TSecr=7471659

13 0.013557654 127.0.0.1 ?~F~R 127.0.0.1 TCP 66 56293?~F~R8984 [ACK] Seq=1 Ack=63 Win=86 Len=0 TSval=7474075 TSecr=7474075

14 0.013783094 127.0.0.1 ?~F~R 127.0.0.1 HTTP 179 HTTP/1.1 200 OK

15 0.013796438 127.0.0.1 ?~F~R 127.0.0.1 TCP 66 45240?~F~R9000 [ACK] Seq=1 Ack=114 Win=86 Len=0 TSval=7474075 TSecr=7474075

16 0.013807281 127.0.0.1 ?~F~R 127.0.0.1 TCP 151 56292?~F~R8984 [PSH, ACK] Seq=1 Ack=1 Win=86 Len=85 TSval=7474075 TSecr=7473990

17 0.026616596 127.0.0.1 ?~F~R 127.0.0.1 HTTP 213 GET /quick_start/event HTTP/1.1

18 0.029550379 127.0.0.1 ?~F~R 127.0.0.1 OpenFlow 138 Type: OFPT_FLOW_MOD

19 0.031562043 127.0.0.1 ?~F~R 127.0.0.1 TCP 88 8984?~F~R56292 [PSH, ACK] Seq=1 Ack=86 Win=86 Len=22 TSval=7474079 TSecr=7474075

20 0.031591119 127.0.0.1 ?~F~R 127.0.0.1 TCP 66 56292?~F~R8984 [ACK] Seq=86 Ack=23 Win=86 Len=0 TSval=7474079 TSecr=7474079

21 0.031786109 127.0.0.1 ?~F~R 127.0.0.1 TCP 163 56292?~F~R8984 [PSH, ACK] Seq=86 Ack=23 Win=86 Len=97 TSval=7474079 TSecr=7474079

22 0.031958834 127.0.0.1 ?~F~R 127.0.0.1 OpenFlow 146 Type: OFPT_FLOW_MOD

23 0.032035439 127.0.0.1 ?~F~R 127.0.0.1 TCP 66 47418?~F~R6633 [ACK] Seq=341 Ack=169 Win=44032 Len=0 TSval=7474079 TSecr=7474079

24 0.032732179 127.0.0.1 ?~F~R 127.0.0.1 TCP 88 8984?~F~R56292 [PSH, ACK] Seq=23 Ack=183 Win=86 Len=22 TSval=7474080 TSecr=7474079

25 0.038687398 36:68:ff:8e:d1:9c ?~F~R Broadcast OpenFlow 126 Type: OFPT_PACKET_IN

26 0.038966518 127.0.0.1 ?~F~R 127.0.0.1 TCP 190 8984?~F~R56293 [PSH, ACK] Seq=63 Ack=1 Win=86 Len=124 TSval=7474081 TSecr=7474075

27 0.038979534 127.0.0.1 ?~F~R 127.0.0.1 TCP 66 56293?~F~R8984 [ACK] Seq=1 Ack=187 Win=86 Len=0 TSval=7474081 TSecr=7474081`

application code : ` import frenetic from frenetic.syntax import *

class RepeaterApp(frenetic.App):

client_id = "quick_start"

def connected(self): self.update( id >> SendToController("repeater_app") )

def packet_in(self, dpid, port_id, payload): out_port_id = 2 if port_id == 1 else 1 self.pkt_out(dpid, payload, SetPort(out_port_id), port_id )

app = RepeaterApp() app.start_event_loop() `

jnfoster commented 7 years ago

Hi Sushil,

I believe what's happening is that when the switch first connects, Frenetic sends a single FlowMod to delete all existing rules on the switch. This is not strictly speaking necessary when starting from a cold boot, but we do it just to be safe.

See here: https://github.com/frenetic-lang/frenetic/blob/master/async/Frenetic_OpenFlow0x01_Plugin.ml#L357

-N

On Thu, Jan 26, 2017 at 10:35 AM, Sushil Jain notifications@github.com wrote:

Hi,

I am using frenetic as controller and running a simple application and capturing the packets using tshark. As per my application, there should be one flow rule in the switch and when I execute dpctl dump-flows, it also returns only one rule. But when I look at the output generated by tshark, there are two flow_mod instructions, could anyone explain to me why it's the case?

tshark output :

1 0.000000000 127.0.0.1 ?~F~R 127.0.0.1 TCP 74 47418?~F~R6633 [SYN] Seq=0 Win=43690 Len=0 MSS=65495 SACK_PERM=1 TSval=7474071 TSecr=0 WS=512 2 0.000012872 127.0.0.1 ?~F~R 127.0.0.1 TCP 74 6633?~F~R47418 [SYN, ACK] Seq=0 Ack=1 Win=43690 Len=0 MSS=65495 SACK_PERM=1 TSval=7474071 TSecr=7474071 WS=512 3 0.000024780 127.0.0.1 ?~F~R 127.0.0.1 TCP 66 47418?~F~R6633 [ACK] Seq=1 Ack=1 Win=44032 Len=0 TSval=7474071 TSecr=7474071 4 0.002099696 127.0.0.1 ?~F~R 127.0.0.1 TCP 74 6633?~F~R47418 [PSH, ACK] Seq=1 Ack=1 Win=44032 Len=8 TSval=7474072 TSecr=7474071 5 0.002123409 127.0.0.1 ?~F~R 127.0.0.1 TCP 66 47418?~F~R6633 [ACK] Seq=1 Ack=9 Win=44032 Len=0 TSval=7474072 TSecr=7474072 6 0.007420721 127.0.0.1 ?~F~R 127.0.0.1 OpenFlow 74 Type: OFPT_HELLO 7 0.007442474 127.0.0.1 ?~F~R 127.0.0.1 TCP 66 6633?~F~R47418 [ACK] Seq=9 Ack=9 Win=44032 Len=0 TSval=7474073 TSecr=7474073 8 0.007680840 :: ?~F~R ff02::16 OpenFlow 174 Type: OFPT_PACKET_IN 9 0.007689056 127.0.0.1 ?~F~R 127.0.0.1 TCP 66 6633?~F~R47418 [ACK] Seq=9 Ack=117 Win=44032 Len=0 TSval=7474073 TSecr=7474073 10 0.012062290 127.0.0.1 ?~F~R 127.0.0.1 OpenFlow 74 Type: OFPT_FEATURES_REQUEST 11 0.012318360 127.0.0.1 ?~F~R 127.0.0.1 OpenFlow 290 Type: OFPT_FEATURES_REPLY 12 0.013528244 127.0.0.1 ?~F~R 127.0.0.1 TCP 128 8984?~F~R56293 [PSH, ACK] Seq=1 Ack=1 Win=86 Len=62 TSval=7474075 TSecr=7471659 13 0.013557654 127.0.0.1 ?~F~R 127.0.0.1 TCP 66 56293?~F~R8984 [ACK] Seq=1 Ack=63 Win=86 Len=0 TSval=7474075 TSecr=7474075 14 0.013783094 127.0.0.1 ?~F~R 127.0.0.1 HTTP 179 HTTP/1.1 200 OK 15 0.013796438 127.0.0.1 ?~F~R 127.0.0.1 TCP 66 45240?~F~R9000 [ACK] Seq=1 Ack=114 Win=86 Len=0 TSval=7474075 TSecr=7474075 16 0.013807281 127.0.0.1 ?~F~R 127.0.0.1 TCP 151 56292?~F~R8984 [PSH, ACK] Seq=1 Ack=1 Win=86 Len=85 TSval=7474075 TSecr=7473990 17 0.026616596 127.0.0.1 ?~F~R 127.0.0.1 HTTP 213 GET /quick_start/event HTTP/1.1 18 0.029550379 127.0.0.1 ?~F~R 127.0.0.1 OpenFlow 138 Type: OFPT_FLOW_MOD 19 0.031562043 127.0.0.1 ?~F~R 127.0.0.1 TCP 88 8984?~F~R56292 [PSH, ACK] Seq=1 Ack=86 Win=86 Len=22 TSval=7474079 TSecr=7474075 20 0.031591119 127.0.0.1 ?~F~R 127.0.0.1 TCP 66 56292?~F~R8984 [ACK] Seq=86 Ack=23 Win=86 Len=0 TSval=7474079 TSecr=7474079 21 0.031786109 127.0.0.1 ?~F~R 127.0.0.1 TCP 163 56292?~F~R8984 [PSH, ACK] Seq=86 Ack=23 Win=86 Len=97 TSval=7474079 TSecr=7474079 22 0.031958834 127.0.0.1 ?~F~R 127.0.0.1 OpenFlow 146 Type: OFPT_FLOW_MOD 23 0.032035439 127.0.0.1 ?~F~R 127.0.0.1 TCP 66 47418?~F~R6633 [ACK] Seq=341 Ack=169 Win=44032 Len=0 TSval=7474079 TSecr=7474079 24 0.032732179 127.0.0.1 ?~F~R 127.0.0.1 TCP 88 8984?~F~R56292 [PSH, ACK] Seq=23 Ack=183 Win=86 Len=22 TSval=7474080 TSecr=7474079 25 0.038687398 36:68:ff:8e:d1:9c ?~F~R Broadcast OpenFlow 126 Type: OFPT_PACKET_IN 26 0.038966518 127.0.0.1 ?~F~R 127.0.0.1 TCP 190 8984?~F~R56293 [PSH, ACK] Seq=63 Ack=1 Win=86 Len=124 TSval=7474081 TSecr=7474075 27 0.038979534 127.0.0.1 ?~F~R 127.0.0.1 TCP 66 56293?~F~R8984 [ACK] Seq=1 Ack=187 Win=86 Len=0 TSval=7474081 TSecr=7474081

application code : `import frenetic from frenetic.syntax import *

class RepeaterApp(frenetic.App):

client_id = "quick_start"

def connected(self): self.update( id >> SendToController("repeater_app") )

def packet_in(self, dpid, port_id, payload): out_port_id = 2 if port_id == 1 else 1 self.pkt_out(dpid, payload, SetPort(out_port_id), port_id )

app = RepeaterApp() app.start_event_loop()`

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/frenetic-lang/frenetic/issues/541, or mute the thread https://github.com/notifications/unsubscribe-auth/ABwi0rYxwdwdA24I2yIvq3fhKPzo8QgYks5rWOd6gaJpZM4Lu-71 .