<div dir="ltr">Dear Murphy,<div>I found the mistake! Of course that was a snapshot of the code and not all, anyway I found the problem.</div><div>I was binding the socket with the tuple ('127.0.0.1',12345). When I changed to ('', 12345) it worked. I guessed the host would have had 127.0.0.1 as default loopback IP interface, but probably it is not because of the mininet layer.</div>
<div>Thanks for your support!</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/7/22 Murphy McCauley <span dir="ltr"><<a href="mailto:murphy.mccauley@gmail.com" target="_blank">murphy.mccauley@gmail.com</a>></span><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">Hm.<div>Okay, so if you run "netcat -u -l  12345" on say... h1, you see the data (it works).</div>
<div>.. but with your python code on h1, you don't?</div><div><br></div><div>If the code you pasted below is your real code, then it may be the problem, since it has at least two bugs.</div><div>Try the following complete Python program:</div>
<div><div>import socket</div><div>s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)</div><div>s.bind(('',12345))</div><div>data = s.recv(10)</div><div>print len(data), data</div></div><span class="HOEnZb"><font color="#888888"><div>
<br></div><div>-- Murphy</div></font></span><div><div class="h5"><div><br><div><div>On Jul 22, 2013, at 2:14 AM, Silvia Fichera wrote:</div><br><blockquote type="cite"><div dir="ltr">If you mean the field eth_packet.dst yes, I've set it as 00:00:00:00:00:01 the mac address of the host h1.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">2013/7/22 Murphy McCauley <span dir="ltr"><<a href="mailto:murphy.mccauley@gmail.com" target="_blank">murphy.mccauley@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word">
Are you setting the ethernet destination address correctly?<div><div><div>
<br><div><div>On Jul 21, 2013, at 3:23 PM, Silvia Fichera wrote:</div><br><blockquote type="cite"><div dir="ltr">Dear Murphy,<div>I am still experiencing problems to send packets from controller to host.</div><div>I tried to send UDP packet via packet_out and they are correctly sent and received from the host (I can see using tcpdump from receiving host) but if I try to open a socket with python to read the data, I receive nothing in the socket even if tcpdump keeps seeing the packets.</div>


<div><br></div><div>Then I tried to communicate from host to host (opening two xterm from mininet). If I use netcat listening for data communication is perfect. If I try to receive data with python sockets I receive the following tcpdump output (python or netcat send, tcpdump and python listen):</div>


<div><br></div><div>IP 10.0.0.2.12345 > 10.0.0.1.12345: UDP, length 14</div><div>IP 10.0.0.1 > <a href="http://10.0.0.2/" target="_blank">10.0.0.2</a>: ICMP 10.0.0.1 udp port 12345 unreachable, length 50</div><div>

<br></div><div>I can see the process listening to the port by lsof -i :12345</div>
<div>If I put netcat listening to the port, the packet arrives correctly.</div><div>I also tried to change the ports but same result.</div><div><br></div><div>Is it maybe a problem of the low-level python socket binding? I am using simply</div>


<div>s= socket.socket(socket.AF_INET, soket.SOCK_DGRAM)</div><div>s.bind((host,port))</div><div>data, addr = sock.recv(10)</div><div><br></div><div>Eventually, I tried in both my ubuntu+mininet installation and in the virtual machine of mininet (mininet 2.0 with ubuntu 12.10 64 bit) without success.</div>


<div><br></div><div>Thanks for support</div><div><br></div><div>regards</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/7/21 Murphy McCauley <span dir="ltr"><<a href="mailto:murphy.mccauley@gmail.com" target="_blank">murphy.mccauley@gmail.com</a>></span><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">If you have any switches, then you'll have received a ConnectionUp event when they connect.  You can save a reference to the Connection object into your own variable at this point.  Lots of the example components do this (e.g., l2_learning more or less does it).<div>


<br></div><div>You can also get the connections later from the OpenFlow nexus, e.g., using the core.openflow.connections collection which holds a Connection for each connected switch (you can either enumerate it, or you can get connections by their DPID).  There's also the related core.openflow.sendToDPID(dpid, data) method if you know the DPID you want to send to.</div>


<span><font color="#888888"><div><br></div></font></span><div><span><font color="#888888">-- Murphy</font></span><div><div><div><div> <br><div><div>On Jul 20, 2013, at 3:57 PM, Silvia Fichera wrote:</div>
<br><blockquote type="cite"><div dir="ltr">Thanks for the summary.<div><span style="color:rgb(38,38,38);font-family:arial,sans-serif;font-size:13px;line-height:16px">I was planning to use the packet_out but I am missing the connection object (I saw this is usually taken from an event). Can I create a connection object (to link controller and a switch) starting the communication from the controller?</span><br>



</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/7/20 Murphy McCauley <span dir="ltr"><<a href="mailto:murphy.mccauley@gmail.com" target="_blank">murphy.mccauley@gmail.com</a>></span><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>Let me try restating.</div><div><br></div><div>Imagine you have a hardware switch.  It has some ports which connect it to other switches and hosts and stuff -- it makes a network (call this the "data network" for lack of a better term).</div>



<div><br></div><div>So if it's an OpenFlow switch, where is the controller in this picture?</div><div><br></div><div>One type configuration, the controller can be anywhere on the data network.  It communicates with the switch over IP, so why not?  You have OpenFlow mixed with normal traffic all over your network.  (This is often called "in band control")</div>



<div><br></div><div>In another type of configuration (out of band control), you set aside one port on each switch as "special", and use this port to connect to the controller.  The special port is *not* a part of the data network.  You might say it's part of a control or management network.  No normal forwarding ever takes place over this port -- *only* OpenFlow.</div>



<div><br></div><div><br></div><div>If your setup looks like the first configuration, a controller can easily send arbitrary traffic over the data network using plain old socket programming.  But if your configuration is similar to the second option, there's no direct way for the controller to send to or receive from the data network.  The only way it can do it is over OpenFlow -- by instructing one of the switches to send data (via a packet out) and having the switch send data to the controller (via packet in).</div>



<div><br></div><div>Of course, even in the second configuration, you could run a cable between a second interface on the controller and a normal port on the switch.  That way you have two cables between switch and controller -- one on the management network and one on the data network.</div>



<div><div><br></div><div><br></div><div>Hope that helps.</div><div><br></div><div>-- Murphy</div><div><br></div></div><div><div><div>On Jul 20, 2013, at 8:49 AM, Silvia Fichera wrote:</div><div><br><blockquote type="cite">



<div dir="ltr">> <span style="font-family:arial,sans-serif;font-size:13px"> In which case, there's no way to send except via a datapath or a host which actually is.</span><div>Can you clarify this sentence?</div><div>




<br></div><div>Am I following the right way to send packets from the controller to hosts through switches, so using my network, or do I miss something?</div><div><div class="gmail_extra"><br><br><div class="gmail_quote">



2013/7/20 Murphy McCauley <span dir="ltr"><<a href="mailto:murphy.mccauley@gmail.com" target="_blank">murphy.mccauley@gmail.com</a>></span><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"><div style="word-wrap:break-word">If I'm understanding correctly, the problem is that the controller isn't necessarily *on* the data network.  In Mininet, for example, it is often the case that the controller and the datapaths are linked essentially by a separate management network, and this is not an unusual case in the real world either.  In which case, there's no way to send except via a datapath or a host which actually is.<div>




<br></div><div>Hope that helps.</div><span><font color="#888888"><div><br></div><div>-- Murphy</div></font></span><div><div><div><br><div><div><div>On Jul 19, 2013, at 3:39 PM, Silvia Fichera wrote:</div>
<br><blockquote type="cite"><div dir="ltr"><div><div>Hello,<br>I am having trouble sending packets from l3_learning controller to host.<br></div>I would like to send UDP packets but if I try to use normal socket from controller I see no traffic (I minotired it with wireshark on all switches) unless I send to itself (127.0.0.1).  I was also trying to make a switch sending the controller generated packet in this way:<br>





<a href="http://lists.noxrepo.org/pipermail/pox-dev-noxrepo.org/2012-October/000281.html" target="_blank">http://lists.noxrepo.org/pipermail/pox-dev-noxrepo.org/2012-October/000281.html</a><br><br></div>Although I have no traffic too.<br>





I guess the problem is that I am missing something like<br><br> self.connection.send(msg)<br clear="all"><div><div><div><div><br></div><div>but I don't have any datapath connection with any switch since I want to start the communication from the controller.<br>





</div><div>Is there an easier way to send these udp packets?<br><br></div><div>thanks<br></div><div><br></div><div>-- <br>Silvia Fichera</div></div></div></div></div>
</blockquote></div><br></div></div></div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Silvia Fichera
</div></div></div>
</blockquote></div><br></div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Silvia Fichera
</div>
</blockquote></div><br></div></div></div></div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Silvia Fichera
</div>
</blockquote></div><br></div></div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Silvia Fichera
</div>
</blockquote></div><br></div></div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Silvia Fichera
</div>