<div dir="ltr"><div><div><div>Thank you so much Murphy. I tried it but got little problem in add function i.e. when I used <br>self.macaddrs.add((packet.src,packet.dst])) it generated error in this function then I tried <br>
self.macaddrs.add(packet.src,packet.dst)<br></div>It also generated an error that add must have 1 argument where as 2 given. Then I tried<br><br>if (packet.src,packet.dst) not in self.macaddrs:<br>  self.macaddrs.add(packet.src)<br>
  self.macaddrs.add(packet.dst)<br>  self.macaddrtable[f_id]=(packet.src,packet.dst)<br><div id=":123">
  f_id=f_id+1</div><br></div>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.<br></div>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.<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Nov 10, 2013 at 3:26 AM, Murphy McCauley <span dir="ltr"><<a href="mailto:murphy.mccauley@gmail.com" target="_blank">murphy.mccauley@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">One possible answer is that you should keep a set of the ones you've added so far...<br>
self.macaddrtable = {}<br>
self.macaddrs = set()<br>
<br>
...<br>
<br>
if (packet.src,packet.dst) not in self.macaddrs:<br>
  self.macaddrs.add((packet.src,packet.dst]))<br>
  self.macaddrtable[f_id]=(packet.src,packet.dst)<br>
  f_id=f_id+1<br>
<br>
<br>
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.).<br>
<span class="HOEnZb"><font color="#888888"><br>
-- Murphy<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Nov 9, 2013, at 10:35 AM, Sayed Qaiser Ali Shah <<a href="mailto:11msitqshah@seecs.edu.pk">11msitqshah@seecs.edu.pk</a>> wrote:<br>
<br>
> Hello everybody,<br>
><br>
> 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<br>
><br>
>     self.macaddrtable = {}<br>
> ...<br>
>     f_id=1<br>
>     self.macaddrtable[f_id]={packet.src, packet.dst}<br>
>     print self.macaddrtable<br>
>     f_id=f_id+1<br>
><br>
> 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.<br>
> What I want is to save mac address only if its not in dictionary.<br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><b style="color:rgb(51,51,153)"><span style="background-color:rgb(255,255,255)">Regards</span><br style="background-color:rgb(255,255,255)"><br style="background-color:rgb(255,255,255)">
<span style="background-color:rgb(255,255,255)">Sayed Qaiser Ali Shah</span><br style="background-color:rgb(255,255,255)"><span style="background-color:rgb(255,255,255)">MSIT-12</span><br style="background-color:rgb(255,255,255)">
<span style="background-color:rgb(255,255,255)">NUST (SEECS)</span></b><br>
</div>