I refined the last message so that it is more clear:<br><br>Hello --<br><br>I want to <b>install and modify</b> flow entries<b> from the controller</b>. First, I proactively install new rules into the flow table in this way:<br>
<br><b>#flow generate-- simulated flows</b><br>for i in "a set of ip addresses":<br>
    u = udp()<br>    u.srcport = 1<br>    u.dstport = 2<br>    p = ipv4()<br>    p.set_payload(u)<br>    p.srcip =IPAddr(i)#i is increased ip address such as 192.168.0.1, 192.168.0.2, 192.168.0.3, ... 192.168.1.255 ...<br>

    p.dstip = IPAddr("192.168.56.100")<br>   e =ethernet (...)<br>   e.set_payload(p)<br><b>#get a match from packet and tries to install a new rule...</b><br><div><span>   msg</span> <span>=</span> <span>of</span><span>.</span><span>ofp_flow_mod</span><span>()</span></div>

<div>   <span>msg</span><span>.</span><span>match</span> <span>=</span> <span>of</span><span>.</span><span>ofp_match</span><span>.</span><span>from_packet</span><span>(</span><span>packet</span><span>)</span></div>
<div> <span>  msg</span><span>.</span><span>idle_timeout</span> <span>=</span> <span>0</span></div><div>   <span>msg</span><span>.</span><span>hard_timeout</span> <span>=</span> <span>0</span></div>
<div> <span>  msg</span><span>.</span><span>actions</span><span>.</span><span>append</span><span>(</span><span>of</span><span>.</span><span>ofp_action_output</span><span>(</span><span>port</span> <span>=</span> <span>1</span><span>))</span></div>

<div> <span>  self</span><span>.</span><span>connection</span><span>.</span><span>send</span><span>(</span><span>msg</span><span>)<br>
Till now, the results is what I expected-- a set of new rules are installed in the flow table;<br><br>Next, I want to <b>modify</b> the installed (newly installed rules).  At the same time, I want to <b>send out a packet which matches a particular rules</b> so that I know that modified rule takes effect.<br>

<br>The code is like this--<br><b>#repeat the "</b></span><b>flow generate-- simulated flows" procedure<br>...<br>#</b><br><b>#get a match from packet and tries to modify that rule...<br></b><br><span>   msg</span> <span>=</span> <span>of</span><span>.</span><span>ofp_flow_mod</span><span>()<br>

   msg.command = of.OFPFC_MODIFY (make sure that this command is for modification)<br></span><div>   <span>msg</span><span>.</span><span>match</span> <span>=</span> <span>of</span><span>.</span><span>ofp_match</span><span>.</span><span>from_packet</span><span>(</span><span>packet</span><span></span><span>)</span></div>

<div> <span>  msg</span><span>.</span><span>idle_timeout</span> <span>=</span> <span>0</span></div><div>   <span>msg</span><span>.</span><span>hard_timeout</span> <span>=</span> <span>0<br>
   msg.data = e.pack()<br></span></div><div> <span>  msg</span><span>.</span><span>actions</span><span>.</span><span>append</span><span>(</span><span>of</span><span>.</span><span>ofp_action_output</span><span>(</span><span>port</span> <span>=</span> <span>2</span><span>)) # the output port is modified here...<br>
</span></div>
<div> <span>  self</span><span>.</span><span>connection</span><span>.</span><span>send</span><span>(</span><span>msg</span><span>)</span></div>
</div>Now, I get the error: <br>********error message*****************<br>File "/home/sdn/pox/pox/openflow/<div id=":43w">of_01.py", line 687, in send<br>    data = data.pack()<br>  File "/home/sdn/pox/pox/openflow/libopenflow_01.py", line 2191, in pack<br>

    self.buffer_id = self.data.buffer_id<br><b>AttributeError: 'str' object has no attribute 'buffer_id'</b><br>*********error message end**********<br><br>I tested that If I change <span>msg</span> <span>=</span> <span>of</span><span>.</span><span>ofp_flow_mod</span><span>()
 to msg = of.ofp_packet_out(), it is fine. But I do not just want to 
send packet out. What I want to do is, first modify a rule and then send
 out a packet matching that rule.<br>
<br><br>Can anyone help on the error? Thanks:)<br></span><br>-------------end of the message---------------------<br><br></div><br><br><div class="gmail_quote">On Fri, Jul 26, 2013 at 11:55 AM, Keqiang He <span dir="ltr"><<a href="mailto:hekeqiang@gmail.com" target="_blank">hekeqiang@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello --<br><br>I want to <b>install and modify</b> flow entries<b> from the controller</b>. First, I proactively install new rules into the flow table in this way:<br>
<br><b>#flow generate-- simulated flows</b><br>for i in "a set of ip addresses":<br>
    u = udp()<br>    u.srcport = 1<br>    u.dstport = 2<br>    p = ipv4()<br>    p.set_payload(u)<br>    p.srcip =IPAddr(i)#i is increased ip address such as 192.168.0.1, 192.168.0.2, 192.168.0.3, ... 192.168.1.255 ...<br>

    p.dstip = IPAddr("192.168.56.100")<br>   e =ethernet (...)<br>   e.set_payload(p)<br><b>#get a match from packet and tries to install a new rule...</b><br><div><span>   msg</span> <span>=</span> <span>of</span><span>.</span><span>ofp_flow_mod</span><span>()</span></div>

<div>   <span>msg</span><span>.</span><span>match</span> <span>=</span> <span>of</span><span>.</span><span>ofp_match</span><span>.</span><span>from_packet</span><span>(</span><span>packet</span><span>,</span> <span>event</span><span>.</span><span>port</span><span>)</span></div>

<div> <span>  msg</span><span>.</span><span>idle_timeout</span> <span>=</span> <span>10</span></div><div>   <span>msg</span><span>.</span><span>hard_timeout</span> <span>=</span> <span>30</span></div>
<div> <span>  msg</span><span>.</span><span>actions</span><span>.</span><span>append</span><span>(</span><span>of</span><span>.</span><span>ofp_action_output</span><span>(</span><span>port</span> <span>=</span> <span>port</span><span>))</span></div>

<div> <span>  self</span><span>.</span><span>connection</span><span>.</span><span>send</span><span>(</span><span>msg</span><span>)<br>
Till now, the results is what I expected-- a set of new rules are installed in the flow table;<br><br>Next, I want to <b>modify</b> the installed (newly installed rules).  At the same time, I want to <b>send out a packet which matches a particular rules</b> so that I know that modified rule takes effect.<br>

<br>The code is like this--<br><b>#repeat the "</b></span><b>flow generate-- simulated flows" procedure<br>...<br>#</b><br><b>#get a match from packet and tries to modify that rule...<br></b><br><span>   msg</span> <span>=</span> <span>of</span><span>.</span><span>ofp_flow_mod</span><span>()<br>

   msg.command = of.OFPFC_MODIFY (make sure that this command is for modification)<br></span><div>   <span>msg</span><span>.</span><span>match</span> <span>=</span> <span>of</span><span>.</span><span>ofp_match</span><span>.</span><span>from_packet</span><span>(</span><span>packet</span><span>,</span> <span>event</span><span>.</span><span>port</span><span>)</span></div>

<div> <span>  msg</span><span>.</span><span>idle_timeout</span> <span>=</span> <span>10</span></div><div>   <span>msg</span><span>.</span><span>hard_timeout</span> <span>=</span> <span>30<br>
   msg.data = e.pack()<br></span></div><div> <span>  msg</span><span>.</span><span>actions</span><span>.</span><span>append</span><span>(</span><span>of</span><span>.</span><span>ofp_action_output</span><span>(</span><span>port</span> <span>=</span> <span>port</span><span>))</span></div>

<div> <span>  self</span><span>.</span><span>connection</span><span>.</span><span>send</span><span>(</span><span>msg</span><span>)</span></div>
</div>Now, I get the error: <br>********error message*****************<br>File "/home/sdn/pox/pox/openflow/of_01.py", line 687, in send<br>    data = data.pack()<br>  File "/home/sdn/pox/pox/openflow/libopenflow_01.py", line 2191, in pack<br>

    self.buffer_id = self.data.buffer_id<br>*********error message end**********<br><br>I tested that If I change <span>msg</span> <span>=</span> <span>of</span><span>.</span><span>ofp_flow_mod</span><span>() to msg = of.ofp_packet_out(), it is fine. But I do not just want to send packet out. What I want to do is, first modify a rule and then send out a packet matching that rule.<br>

<br><br>Can anyone help on the error? Thanks:)<br></span>AttributeError: 'str' object has no attribute 'buffer_id'<br><br>
</blockquote></div><br>