<div dir="ltr">I think so. I want to delete entry from dictionary defined on controller. Thanks. I will try this.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Nov 23, 2013 at 11:04 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"><div style="word-wrap:break-word"><br><div><div class="im"><div>On Nov 22, 2013, at 12:57 PM, Sayed Qaiser Ali Shah <<a href="mailto:11msitqshah@seecs.edu.pk" target="_blank">11msitqshah@seecs.edu.pk</a>> wrote:</div>
<br><blockquote type="cite"><div dir="ltr"><div>Hello Murphy McCauley,<br><br></div><div>I solved the duplication problem now I want to refresh the dictionary I have defined after an idle_timeout. I want to set idle_timeout to 10. I tried this but didn't get what I wanted.<br>
<br>msg.idle_timeout = 10<br> if msg.idle_timeout== True:<br> self.macaddrtable=' '<br><br></div><div>This will destroy all entries in dictionary. Is there any other way so that only that entry whose idle_timeout has expired is removed and then rearrange remaining entries in dictionary.<br>
</div><div>Just as a reminder. macaddrtable is dictionary defined which contains source and destination mac addresses. When a packet arrives controller its entry is saved in the dictionary macaddrtable.<br></div></div></blockquote>
<div><br></div></div><div>If you set the OFPFF_SEND_FLOW_REM flag when installing the table entry, you'll get a FlowRemoved event when it expires. Maybe that's what you need?</div><span class="HOEnZb"><font color="#888888"><div>
<br></div><div>-- Murphy</div></font></span><div><div class="h5"><br><blockquote type="cite"><div class="gmail_extra"><div class="gmail_quote">On Fri, Nov 15, 2013 at 6:05 PM, Sayed Qaiser Ali Shah <span dir="ltr"><<a href="mailto:11msitqshah@seecs.edu.pk" target="_blank">11msitqshah@seecs.edu.pk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Ok thank you I will check it out.<br></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 15, 2013 at 5:54 PM, 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"><div style="word-wrap:break-word">I'm just suggesting you work backwards to find the problem. Use Wireshark to monitor the traffic to help determine where the duplicates are coming from. If they're coming from a switch, I suggest you inspect the table on that switch to see which table entry the switch. Then analyze the OpenFlow traffic to that switch to find the OpenFlow messages which installed the problematic entries. Then analyze your controller code to see where you sent those problematic entries.<span><font color="#888888">
<br></font></span><div><span><font color="#888888">-- Murphy</font></span><div><br><div><br><div><div>On Nov 15, 2013, at 4:49 AM, Sayed Qaiser Ali Shah <<a href="mailto:11msitqshah@seecs.edu.pk" target="_blank">11msitqshah@seecs.edu.pk</a>> wrote:</div>
<br><blockquote type="cite"><div dir="ltr"><div><div><div>Thank you so much. Yes you are right about what you said but is there is any other way, so that I can do this. I can read individual entries statically but the problem is I want to get it dynamic.<br>
</div>Like I can print individual entries by using:<br></div><br>print self.macaddrtable[1]<br>print self.macaddrtable[2]<br>print self.macaddrtable[3]<br>print self.macaddrtable[4]<br><br></div>To get desired result dynamically I used loop. But you know what I got. :(<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 15, 2013 at 3:36 PM, 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"><div style="word-wrap:break-word"><br><div><div><div>On Nov 15, 2013, at 2:20 AM, Sayed Qaiser Ali Shah <<a href="mailto:11msitqshah@seecs.edu.pk" target="_blank">11msitqshah@seecs.edu.pk</a>> wrote:</div>
<br><blockquote type="cite"><div dir="ltr"><div>Hello Murphy actually I am working on Traffic Engineering. I am now learning that how to forward traffic when we have dictionary on controller. I want to forward some entries of dictionary via queue-1 and some entries via queue-2. For this I have created dictionary and it created successfully with you help. Those entries of dictionary contain Source Mac Address and Destination Mac address. I created 2 queues on Interface 1 of switch. I then Pinged host 2 from host 1 and host 1 from host 3. It inserted four entries in dictionary created on controller. Entries in Dictionary are<br>
{1: (EthAddr('00:00:00:00:00:02'), EthAddr('00:00:00:00:00:01')), <br> 2: (EthAddr('00:00:00:00:00:01'), EthAddr('00:00:00:00:00:02')), <br> 3: (EthAddr('00:00:00:00:00:01'), EthAddr('00:00:00:00:00:03')), <br>
4: (EthAddr('00:00:00:00:00:03'), EthAddr('00:00:00:00:00:01')) }<br></div><div>Dear Murphy you asked earlier that you didn't get what I wanted to do. I think that I am just explaining it in easy way that I just want to forward two entries of dictionary via queue-1 and other 2 entries of dictionary via queue-2. I am just doing practice on different techniques of Traffic Engineering. I used the following code for forwarding traffic via queues:<br>
<br>if self.macaddrtable=='': //When we have no entry in macaddrtable dictionary<br> queue=1<br> msg.actions.append(of.ofp_action_enqueue(port = port, queue_id = queue))<br>else:<br> for a in self.macaddrtable:<br>
if a<=2:<br> queue=1<br> msg.actions.append(of.ofp_action_enqueue(port = port, queue_id = queue))<br> elif a>2:<br> queue=2<br> msg.actions.append(of.ofp_action_enqueue(port = port, queue_id = queue))<br>
<br></div><div>The code worked fine and forwarded traffic via desired queues but after about 10 seconds of pinging, duplicate packets were detected. I don't know why duplicate packets were detected. Can you please tell the reason?</div>
</div></blockquote><div><br></div></div><div>My best guesses are that you are somehow creating a flow entry with multiple actions or a loop, but it's hard to say. I'd suggest that you try to use Wireshark or a similar tool to figure out where the duplicates are coming from. You should see the duplicates at the port of the destination host and the egress port of the last switch. Work backwards from there. If you find the source of the duplications is a switch, examine the flow table of that switch and see if you can spot the reason.</div>
<span><font color="#888888"><div><br></div><div>-- Murphy</div></font></span><div><br><blockquote type="cite"><div class="gmail_extra"><div class="gmail_quote">On Tue, Nov 12, 2013 at 2:00 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"><div style="word-wrap:break-word"><div>It's still hard for me to answer questions since I still don't know what you're really trying to accomplish here.</div>
<div><br></div><div>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.</div>
<div><br></div><div>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.</div>
<span><font color="#888888"><div>
<br></div><div>-- Murphy</div></font></span><div><div><br></div>On Nov 11, 2013, at 9:42 AM, Sayed Qaiser Ali Shah <<a href="mailto:11msitqshah@seecs.edu.pk" target="_blank">11msitqshah@seecs.edu.pk</a>> wrote:<br>
<div><br><blockquote type="cite"><div dir="ltr"><div>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.<br>
Another Problem is:<br>The code is as below.<br><br>if (packet.src,packet.dst) not in self.macaddrs and (packet.dst,packet.src) not in self.macaddrs:<br> self.macaddrs.add((packet.src,packet.dst))<br> self.macaddrtable[f_id]=(packet.src,packet.dst)<br>
</div> f_id=f_id+1<br><div>print "Mac Table is "<br>print self.macaddrtable<br><br></div><div>When I created a topology with 3 hosts the following result was shown<br><br>Mac Table is <br>{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'))}<br>
<br></div><div>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.<br>
</div><div>Is there any way so that I can get desired exact mac, not broadcast?<br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Nov 10, 2013 at 5:00 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"><div style="word-wrap:break-word"><div>It sounds like you need to record them as a pair to get what you want, so ... put them in as a pair.</div>
<div><br></div><div>It looks like I may have been responsible for the problem you were seeing -- a little typo inserted an errant right square bracket. Try:</div><div>self.macaddrs.add((packet.src,packet.dst))</div><div>
<br></div><div>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...</div>
<div><br></div><div>if (packet.src,packet.dst) not in self.macaddrs and (packet.dst,packet.src) not in self.macaddrs:</div><div><br></div><div>-- Murphy</div><div><div><br></div>On Nov 9, 2013, at 3:32 PM, Sayed Qaiser Ali Shah <<a href="mailto:11msitqshah@seecs.edu.pk" target="_blank">11msitqshah@seecs.edu.pk</a>> wrote:<br>
<div><br><blockquote type="cite"><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>
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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style: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><font color="#888888"><br>
-- Murphy<br>
</font></span><div><br>
On Nov 9, 2013, at 10:35 AM, Sayed Qaiser Ali Shah <<a href="mailto:11msitqshah@seecs.edu.pk" target="_blank">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></blockquote></div><br><br clear="all"><br>-- <br><b style="color:rgb(51,51,153)"><span>Regards</span><br><br>
<span>Sayed Qaiser Ali Shah</span><br><span>MSIT-12</span><br>
<span>NUST (SEECS)</span></b><br>
</div>
</blockquote></div><br></div></div></blockquote></div><br><br clear="all"><br>-- <br><b style="color:rgb(51,51,153)"><span>Regards</span><br>
<br><span>Sayed Qaiser Ali Shah</span><br><span>MSIT-12</span><br>
<span>NUST (SEECS)</span></b><br>
</div>
</blockquote></div><br></div></div></blockquote></div><br><br clear="all"><br>-- <br><b style="color:rgb(51,51,153)"><span>Regards</span><br>
<br><span>Sayed Qaiser Ali Shah</span><br><span>MSIT-12</span><br>
<span>NUST (SEECS)</span></b><br>
</div>
</blockquote></div></div><br></div></blockquote></div><br><br clear="all"><br>-- <br><b style="color:rgb(51,51,153)"><span>Regards</span><br>
<br><span>Sayed Qaiser Ali Shah</span><br><span>MSIT-12</span><br>
<span>NUST (SEECS)</span></b><br>
</div>
</blockquote></div><br></div></div></div></div></blockquote></div><br><br clear="all"><br>-- <br><b style="color:rgb(51,51,153)"><span>Regards</span><br>
<br><span>Sayed Qaiser Ali Shah</span><br><span>MSIT-12</span><br>
<span>NUST (SEECS)</span></b><br>
</div>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><b style="color:rgb(51,51,153)"><span style>Regards</span><br style><br style>
<span style>Sayed Qaiser Ali Shah</span><br style><span style>MSIT-12</span><br style>
<span style>NUST (SEECS)</span></b><br>
</div>
</blockquote></div></div></div><br></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>