Thanks Murphy,
I was able to get all the required information from .flow parameter
mentioned by you.
I am trying to accomplish below mentioned statement, would like your or
other developers inputs on the approach chosen.
I am prioritizing the flows between end hosts on the basis of port numbers.
Say i allocate port 80,8080,100 etc as high priority ports and rest as low
priority. By default, i set the flow timeout to 5 secs. Initially i let all
the flows to start i.e. data is allowed on all the ports. I create a list of
dictionary which contains information about src_ip, dst_ip, src_port,
dst_port, timestamp, packetcount. When the program starts, i set the packet
count to 0, then when flow expires i find the dictionary value meeting the
ip/port information and update value of packet number and timestamp. This
means i have value of packets sent in last 5 seconds for that flow. That is
the reason i needed to obtain this information when the flow expired.
I am writing a logic (basic one) that once the flow expires i will get the
packet again in the NOX controller. I will check if this packet is in the
list of high priority ports, if yes then flow is renewed without further
processing. If the port is not a high priority, then i will compare the
packet value of this port with all the high priority ports' packet value. if
i find this to be higher than any of them, then i will not renew the flow
for that packet. Next time again the packet comes for that low priority
port, if the current and the timestamp stored value exceeds 1 sec then i
renew it else i dont renew the flow. I kept the value of 1 sec because if i
increase this value TCP times out and breaks the connection.
This might not be the best approach and it has few problems. First, the
packet comparison is having 5 second time lag. *I was looking for something
like dpctl's tcpdump in python where i can fetch the latest packet count for
comparison*.Second, If one host is connected to say port 80 and 300, then I
cannot do any bandwidth splitting based on port numbers. I can only do so if
one host is connected to two different hosts on different ports. Is there a
workaround for that? Third, I am using the concept of not renewing flow for
one second for low priority ports. Is there a better approach for doing so?
Thanks,
Kavitesh Singh
Graduate Student
North Carolina State University,
Raleigh,NC-USA
On Fri, Nov 26, 2010 at 6:42 AM, Murphy McCauley wrote:
> Responses inline.
>
> On Nov 25, 2010, at 9:29 PM, K Singh wrote:
>
> > I was adding flow removed event in the pyswitch.py file.
> >
> >def install(self):
> > inst.register_for_packet_in(packet_in_callback)
> > inst.register_for_datapath_leave(datapath_leave_callback)
> > inst.register_for_datapath_join(datapath_join_callback)
> > inst.post_callback(1, timer_callback)
> > inst.register_for_flow_removed(flow_removed_callback)
> >
> > Then creating a callback function as below.
> >
> > def flow_removed_callback(dpid, duration_sec, duration_nsec,
> idle_timeout, packet_count, byte_count, cookie):
> > print "---flow removed---"
> > return CONTINUE
> >
> > The parameter for flow removed event have been obtained from
> ~/noxcore/src/include
>
> Tangential, but is this pulled from the noxcore_old repository? That's
> quite old now...
>
> > where the parameters are defined as
> > Flow_removed_event(datapathid datapath_id_,
> >uint32_t duration_sec_, uint32_t duration_nsec_,
> >uint16_t idle_timeout_,
> >uint64_t packet_count_, uint64_t byte_count_,
> >uint64_t cookie_)
> >
> > when i run this code i get this error message:
> > TypeError: flow_removed_callback() takes exactly 7 arguments (1 given)
> >
> >
> > if I change the code in pyswitch.py for the flow removed callback
> function like below
> >
> > def flow_removed_callback(packet_count):
> > print "---flow removed---",packet_count
> > return CONTINUE
> >
> > the function executes but I see this printed on the terminal
> > ---flow removed--- Object of type 'pyevent *' at 0xb5118128>
> > which is not a correct value i think.
>
> The event handler gets called with a single argument: a Flow_removed_event
> object (actually a Pythonized version of one, but whatever). This object has
> a number of fields: datapath_id, duration_sec, duration_nsec, byte_count,
> etc. So what you want is something like:
> def flow_removed_callback (e):
> print "---flow removed---", e.packet_count
> return CONTINUE
>
> > How can i obtain the values of the listed arguments when a flow
> expires/removed. Also when a flow is created in switch, is there some
> identification number attached to flows? How would I know which flow expired
> when flow_removed event is triggered as I cannot see any flow identification
> number. This would be essential if I would be dealing with multiple flow.
>
> So the Flow_removed_event has a .flow field whic