[pox-dev] Defining Dictionary in POX controller

Murphy McCauley murphy.mccauley at gmail.com
Mon Nov 11 13:00:00 PST 2013


It's still hard for me to answer questions since I still don't know what you're really trying to accomplish here.

If you want entries to time out on the switch, set timeouts when installing the table entry (sending the flow_mod).  If you want notifications when flows are removed on the switch, that's also an option you can set when installing the entry; then listen to the FlowRemoved event to tell when it has actually happened.

I'm not sure what you mean by "exact mac".  Your code records the address the packets were sent to.  If they were sent to the broadcast address, then... that's the destination.

-- Murphy

On Nov 11, 2013, at 9:42 AM, Sayed Qaiser Ali Shah <11msitqshah at seecs.edu.pk> wrote:

> Thank you so much Murphy for your help. I did it the way you explained. But how can I refresh entries in the table. i.e. how to set idle timeout and hard timeout for this so that the table can be refreshed or how the entries can be updated when a flow is removed from flow table on Switch.
> Another Problem is:
> The code is as below.
> 
> if (packet.src,packet.dst) not in self.macaddrs and (packet.dst,packet.src) not in self.macaddrs:
>         self.macaddrs.add((packet.src,packet.dst))
>         self.macaddrtable[f_id]=(packet.src,packet.dst)
>         f_id=f_id+1
> print "Mac Table is "
> print self.macaddrtable
> 
> When I created a topology with 3 hosts the following result was shown
> 
> Mac Table is 
> {1: (EthAddr('00:00:00:00:00:01'), EthAddr('ff:ff:ff:ff:ff:ff')), 2: (EthAddr('00:00:00:00:00:02'), EthAddr('00:00:00:00:00:01')), 3: (EthAddr('00:00:00:00:00:03'), EthAddr('00:00:00:00:00:01')), 4: (EthAddr('00:00:00:00:00:02'), EthAddr('ff:ff:ff:ff:ff:ff')), 5: (EthAddr('00:00:00:00:00:03'), EthAddr('00:00:00:00:00:02'))}
> 
> The result I expected is little bit different in terms of broadcast address. Like in 1 destination mac is ff:ff:ff:ff:ff:ff but I was expecting 00:00:00:00:00:02 and similar is the case with some other entries as well.
> Is there any way so that I can get desired exact mac, not broadcast?
> 
> 
> 
> On Sun, Nov 10, 2013 at 5:00 AM, Murphy McCauley <murphy.mccauley at gmail.com> wrote:
> It sounds like you need to record them as a pair to get what you want, so ... put them in as a pair.
> 
> It looks like I may have been responsible for the problem you were seeing -- a little typo inserted an errant right square bracket.  Try:
> self.macaddrs.add((packet.src,packet.dst))
> 
> It's still not clear from context whether ordering matters to you (is A sending to B the same as B sending to A?).  If it isn't, you might want to sort the two addresses or just check for both...
> 
> if (packet.src,packet.dst) not in self.macaddrs and (packet.dst,packet.src) not in self.macaddrs:
> 
> -- Murphy
> 
> On Nov 9, 2013, at 3:32 PM, Sayed Qaiser Ali Shah <11msitqshah at seecs.edu.pk> wrote:
> 
>> Thank you so much Murphy. I tried it but got little problem in add function i.e. when I used 
>> self.macaddrs.add((packet.src,packet.dst])) it generated error in this function then I tried 
>> self.macaddrs.add(packet.src,packet.dst)
>> It also generated an error that add must have 1 argument where as 2 given. Then I tried
>> 
>> if (packet.src,packet.dst) not in self.macaddrs:
>>   self.macaddrs.add(packet.src)
>>   self.macaddrs.add(packet.dst)
>>   self.macaddrtable[f_id]=(packet.src,packet.dst)
>>   f_id=f_id+1
>> 
>> It didn't generate an error and I didn't get any repeated result but there was some problem in the code I got results as below.
>> When I ping host1 from host 2 it added record in dictionary. Then I ping host 3 from h1 record was inserted again but the problem was, as record of host 1, host 2 and host 3 was saved in macaddrs and two records were there but when I pinged the hosts present in macaddrs i.e. 1, 2, 3 like I ping host 2 from h3 as record was not present in macaddrtable still record was not added to dictionary. It is because addresses are saving in macaddrs one by one individually i.e. first source and then destination address. When packet arrives controller it checks for source and destination address in macaddrs as when there are individual record of each host it then doesn't execute IF body because source and destination addresses are already there as individual address. What to do with this???? Kindly help.
>> 
>> 
>> On Sun, Nov 10, 2013 at 3:26 AM, Murphy McCauley <murphy.mccauley at gmail.com> wrote:
>> One possible answer is that you should keep a set of the ones you've added so far...
>> self.macaddrtable = {}
>> self.macaddrs = set()
>> 
>> ...
>> 
>> if (packet.src,packet.dst) not in self.macaddrs:
>>   self.macaddrs.add((packet.src,packet.dst]))
>>   self.macaddrtable[f_id]=(packet.src,packet.dst)
>>   f_id=f_id+1
>> 
>> 
>> There might be better things to be done, but it's impossible to say without knowing more (e.g., what you're trying to accomplish, what f_id is used for, etc.).
>> 
>> -- Murphy
>> 
>> On Nov 9, 2013, at 10:35 AM, Sayed Qaiser Ali Shah <11msitqshah at seecs.edu.pk> wrote:
>> 
>> > Hello everybody,
>> >
>> > I have defined dictionary in POX controller and I by the name addrtable and I am saving two things in this dictionary i.e. Source mac and destination mac. What I have done is
>> >
>> >     self.macaddrtable = {}
>> > ...
>> >     f_id=1
>> >     self.macaddrtable[f_id]={packet.src, packet.dst}
>> >     print self.macaddrtable
>> >     f_id=f_id+1
>> >
>> > It is saving source mac and destination mac in the dictionary but the problem is when f_id increases it then save same source and destination mac again and again.
>> > What I want is to save mac address only if its not in dictionary.
>> 
>> 
>> 
>> 
>> -- 
>> Regards
>> 
>> Sayed Qaiser Ali Shah
>> MSIT-12
>> NUST (SEECS)
> 
> 
> 
> 
> -- 
> Regards
> 
> Sayed Qaiser Ali Shah
> MSIT-12
> NUST (SEECS)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.noxrepo.org/pipermail/pox-dev-noxrepo.org/attachments/20131111/fe110af8/attachment-0001.htm>


More information about the pox-dev mailing list