On Oct 30, 2013, at 2:23 AM, Sayed Qaiser Ali Shah Shah 
<[email protected]> wrote:

> Thanks to both of you. I got what you want to say. Thanks Murphy for 
> explaining it clearly. I will try this.
> 
> What I have done till now is:
> I sent flow stats request to switch from pox controller and in response of 
> that request I got reply from switch. I am sharing the code
> 
>   def _handle_flowstats_received (self, event):
>       stats = flow_stats_to_list(event.stats)
>       log.debug("FlowStatsReceived from %s: %s",
>         dpidToStr(event.connection.dpid), stats)
>       for f in event.stats:
>           print stats
> 
> Using this method I received following reply
> 
> [{'packet_count': 7, 'hard_timeout': 30, 'byte_count': 686, 'duration_sec': 
> 7, 'actions': [{'type': 'OFPAT_ENQUEUE', 'port': 3, 'queue_id': 2}], 
> 'duration_nsec': 46000000, 'priority': 65535, 'idle_timeout': 10, 'cookie': 
> 0, 'table_id': 0, 'match': {'dl_type': 'IP', 'nw_dst': IPAddr('10.0.0.3'), 
> 'tp_src': 8, 'dl_vlan_pcp': 0, 'dl_src': 'fe:9c:4e:22:7e:6c', 'nw_proto': 1, 
> 'nw_tos': 0, 'tp_dst': 0, 'get_nw_src': '10.0.0.1/32', 'get_nw_dst': 
> '10.0.0.3/32', 'dl_dst': '52:4f:83:f5:cc:24', 'dl_vlan': 65535, 'nw_src': 
> IPAddr('10.0.0.1'), 'in_port': 1}}
> 
> When I use 
>       for f in event.stats:
>           print f.priority
>           print f.duration_nsec
>           print f.idle_timeout
>           print f.cookie
>           print f.table_id
> 
> I got all of the above. But I am unable to get MAC address. I think it is 
> because MAC address is in action field.

It's not in the action, it's in the match.

print f.match.dl_src

-- Murphy

> On Wed, Oct 30, 2013 at 1:51 PM, durga <[email protected]> wrote:
> Hi Sayed,
> 
> My 2 cents as below..
> 
> Just to put Murphy's words into examples- please find below
> 
> while initialising the controller, create a mac adde dictionary like below
> 
> 
>         def __init__(self):
> 
> 
> 
>         # as soon as the module is hooked initialise..
> 
> 
>                 self.macaddrtable = {}
> 
> 
> 
> as and when you get an packet with unknown address you can update the 
> dictionary based on source mac learning like below
> 
> 
> 
>         #updating srcmactable
>                 self.updateMap(inport,srcmacaddr)  
> 
> 
> 
> 
> that will help you keep a dummy src mac able in the controller.
> 
> 
> 
> 
> 
> Cheers!
> Durga
> 
> 
> 
> On Wed, Oct 30, 2013 at 7:46 PM, Murphy McCauley <[email protected]> 
> wrote:
> You want to compare to entries in the flow table of a particular switch?  
> This seems like a sort of strange thing to want.  But the easiest way to do 
> it is to keep track of what flow entries you installed in a normal Python 
> data structure like a set or dictionary and check if the MAC is in there.
> 
> -- Murphy
> 
> On Oct 30, 2013, at 1:39 AM, Sayed Qaiser Ali Shah Shah 
> <[email protected]> wrote:
> 
> > Hello everyone,
> >
> > Using POX controller I want to compare Mac addresses from packet in and 
> > flow table. As we can get source mac from packet in by using packet.src but 
> > I don't know how can we get source mac and destination MAC from table. What 
> > I want to do is:
> > Lets say source mac from table is table.src.
> >
> > if (packet.src == table.src):
> >     Do This
> > else
> >     Do this
> >
> 
> 
> 
> 
> 
> -- 
> Regards
> 
> Sayed Qaiser Ali Shah
> MSIT-12
> NUST (SEECS)

Reply via email to