<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><div style="text-align: left;direction: ltr; "><span style="-webkit-text-size-adjust: auto;">Thank you</span></div><div style="text-align: left;direction: ltr; "><span style="-webkit-text-size-adjust: auto;">I did it in other way around</span></div><div style="text-align: left;direction: ltr; "><span style="-webkit-text-size-adjust: auto;">I created new dictionary. swdpid ={}</span></div><div style="text-align: left;direction: ltr; "><span style="-webkit-text-size-adjust: auto;">and I put the switch MAC as keys and dpids are values</span></div><div style="text-align: left;direction: ltr; "><span style="-webkit-text-size-adjust: auto;">:)</span></div><div style="text-align: left;direction: ltr; "><span style="-webkit-text-size-adjust: auto;"><br></span></div><div style="text-align: left;direction: ltr; "><span style="-webkit-text-size-adjust: auto;">Best regards,</span></div><div style="text-align: left;direction: ltr; "><span style="-webkit-text-size-adjust: auto;">Amer</span></div><br><span style="-webkit-text-size-adjust: auto;">Sent from my iPhone</span></div><div style="-webkit-text-size-adjust: auto; "><br>On ١٩/١١/٢٠١٣, at ١٠:٣٨ م, Murphy McCauley <<a href="mailto:murphy.mccauley@gmail.com">murphy.mccauley@gmail.com</a>> wrote:<br><br></div><blockquote type="cite" style="-webkit-text-size-adjust: auto; "><div><span>On Nov 19, 2013, at 4:01 AM, Amer <<a href="mailto:amer7777@hotmail.com">amer7777@hotmail.com</a>> wrote:</span><br><span></span><br><blockquote type="cite"><span>Thank you Murphy</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>I have another question:</span><br></blockquote><blockquote type="cite"><span>I have got the switch MAC address, i.e., 00-00-00-00-0x, how can I convert it to dpid.</span><br></blockquote><blockquote type="cite"><span>I am working in l2_multi, while the switches array has something like [1: 00-00-00-00-01, 2: 00-00-00-00-02 ]</span><br></blockquote><blockquote type="cite"><span>is there a way to get the dpid number from switches array or I must use a specific command to convert from MAC to dpid.</span><br></blockquote><span></span><br><span>In general, there's no way to convert a MAC to a DPID. However, everything you see when printing out "switches" is already a DPID. Look at the l2_multi code:</span><br><span>44 # Switches we know of. [dpid] -> Switch</span><br><span>45 switches = {}</span><br><span></span><br><span>So we see it's not an array. It's a map from DPID to a Switch object. The keys are DPIDs. The values are Switches.</span><br><span></span><br><span>When you print it out, you don't see "<Switch object at 0x12345678>", though. Hmm; why not? Let's take a look...</span><br><span>230 class Switch (EventMixin):</span><br><span>...</span><br><span>238 def __repr__ (self):</span><br><span>239 return dpid_to_str(self.dpid)</span><br><span></span><br><span>Ah-ha. So that's not a MAC at all. It's also the DPID, but formatted with dpid_to_str().</span><br><span></span><br><span></span><br><span>POX treats DPIDs as numbers. That's what the keys of the switches dictionary are. For display to humans, POX components usually format them with dpid_to_str(), which (purposely) produces something which often looks a lot like an Ethernet address, and that's what you're seeing as the values of the switches dictionary. One easy way to tell them apart is that Ethernet addresses in POX always have the bytes separated by a colon. DPIDs have bytes separated by dashes.</span><br><span></span><br><span>Hope that helps.</span><br><span></span><br><span>-- Murphy</span><br><span></span><br><blockquote type="cite"><span>Best regards,</span><br></blockquote><blockquote type="cite"><span>Amer</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>On ١٩/١١/٢٠١٣, at ٧:٢١ ص, Murphy McCauley <<a href="mailto:murphy.mccauley@gmail.com">murphy.mccauley@gmail.com</a>> wrote:</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><blockquote type="cite"><span>I think you may have to modify l2_multi a bit to get this to work with it -- it was designed with the assumption that it's in control of all the switches, and I think that will cause problems.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>l2_learning, on the other hand, should be easy to run on individual switches. And l2_pairs should be pretty easy too.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>I'd suggest not doing it by writing your own PacketIn handler and demultiplexing it yourself. Instead, just have your L2 stuff listen to PacketIns from some switches, and your L3 stuff listen to PacketIns from the others. That is, you should make this decision in response to a ConnectionUp event instead of each PacketIn. Something like...</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>from pox.forwarding.l2_learning import LearningSwitch</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>def _handle_ConnectionUp (event):</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>if event.dpid == 1:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span> LearningSwitch(event.connection, False)</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>else:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span> # initialize your L3 thing, binding its events to this connection</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Hope that helps.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-- Murphy</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>On Nov 15, 2013, at 10:17 AM, Amer <<a href="mailto:amer7777@hotmail.com">amer7777@hotmail.com</a>> wrote:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Hello,</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>I want to create a handle packetin method, if the incoming packet is from specific switch run l2 if it from another run l3</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>What I did</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>from pox.forearding.l2_multi import *</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>def H_P (event):</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>p = event.parsed</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>If (p.dpid == "1"):</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span> sw= Switch()</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span> sw._handle_PacketIn(event)</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Else:</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span> #. L3.learning</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>I have received this error:</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>NoneType object has no Len()</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Pox.py l2l3 openflow.discovery</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Any help is appreciated</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Best regards,</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Amer</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><span></span><br><span></span><br></div></blockquote></body></html>