Hi Weiyang,
You can inject packets from the controller into the switch like this.
Here is some code that I've used to send UDP packets from the
controller to hosts.
Aaron
def send_udp(mac, dstip, srcip, port, payload):
l4 = udp()
l4.srcport = port
l4.dstport = AGENT_MESSAGE_PORT
l4.len = udp.MIN_LEN + len(payload)
l4.set_payload(payload)
l4.arr = l4.tostring()
l3 = ipv4()
l3.iplen = ipv4.MIN_LEN + l4.len
l3.protocol = ipv4.UDP_PROTOCOL
l3.dstip = dstip
l3.srcip = srcip
l3.set_payload(l4)
l2 = ethernet()
l2.set_payload(l3)
l2.dst = mac
l2.src = octstr_to_array(CONTROLLER_MAC)
l2.type = ethernet.IP_TYPE
l4.csum = l4.checksum()
return l2
inform_dest = send_udp(mac, dstip, srcip, port, payload)
inst.send_openflow_packet(HA, inform_dest.tostring(),
inst.Agent[HA]['inport'], openflow.OFPP_NONE)
On Wed, Apr 25, 2012 at 3:02 PM, Weiyang Mo <[email protected]> wrote:
> Thanks very much for your quick reply.
>
> But I am still confused. do you mean that "the controller instruct a switch
> to send a packet" is not an OpenFlow feature? Or I misunderstand what you
> mean.
>
> I am sending packets from a client to a server through multiple OpenFlow
> switches. I already have this functionality that the controller inserts
> flow-entries and then the packets can be sent to the server.
>
> Now, I want to have another action that " when the controller receives the
> first packet-in message, it can instruct a switch to send a packet which
> contains some data(e.g, hello). And this new packet can be sent to another
> host. If so, the host can run other applications automatically upon receving
> the packet "hello".
>
> Is it possible?( Packet in->controller controller-> instrucrt the
> switch to create a new packet new packet(Hello) ->host). How should I
> write the pseudo code.
>
> Thanks
>
> Weiyang
>
> 2012/4/25 Murphy McCauley <[email protected]>
>>
>> There are no examples of this because this is not an OpenFlow feature --
>> only the controller can instruct a switch to send a packet.
>>
>> Unless maybe there is some vendor extension for some switches…
>>
>> -- Murphy
>>
>> On Apr 25, 2012, at 11:28 AM, Weiyang Mo wrote:
>>
>> BTW,any example code for this? For instance, the controller wishes to send
>> a packet which contains the data "Hello" through the switch to the Output.
>>
>> How should I write the code? Is it like "actions=[openflow.ofp_packet_out,
>> ...]" ?
>>
>> I am not clear because I don't find sample codes. Could anyone provides a
>> simple sample code?
>>
>> Regards
>>
>> Weiyang
>> ---------- Forwarded message ----------
>> From: Weiyang Mo <[email protected]>
>> Date: 2012/4/25
>> Subject: instruct the swtich to create a new packet.
>> To: [email protected]
>>
>>
>> Hi,all,
>>
>> I want to insert an action in to flow entry. The action can tell the
>> switch to create a new arbitary packet. What command should I use?
>>
>> Thanks a lot
>>
>> Weiyang
>>
>>
>
--
Aaron O. Rosen
Masters Student - Network Communication
306B Fluor Daniel