I am sorry it still doesn't work. I checked the code and I think the
problems happen in the first few lines where I set IP packet attributes.

Here is the complete error message: (It seems there's a problem in
ipv4_packet.csum = ipv4_packet.checksum(), even I delete this line, same
errors)

Traceback (most recent call last):
  File "./nox/lib/util.py", line 114, in f
    event.total_len, buffer_id, packet)
  File "./nox/coreapps/examples/sendIPV4.py", line 89, in packet_in_callback
    self.learn_and_forward(dpid, inport, packet, packet.arr, bufid)
  File "./nox/coreapps/examples/sendIPV4.py", line 53, in learn_and_forward
    ipv4_packet.csum = ipv4_packet.checksum()
  File "./nox/lib/packet/ipv4.py", line 162, in checksum
    self.dstip)
error: 'H' format requires 0 <= number <= 65535
Thanks

Weiyang
2012/4/25 Aaron Rosen <[email protected]>

> I believe if you do ipstr_to_int("10.0.0.3") it should work.
>
> Aaron
>
>
> On Wed, Apr 25, 2012 at 6:37 PM, Weiyang Mo <[email protected]>
> wrote:
> > Hi,
> >
> > I tested the code and view the packets in Wireshark.  For ETH packets, it
> > works. For IPV4, some errors when I complie it.
> >
> > (1) I tried ETH packets and the host can receive the packets.
> >         eth_packet= ethernet()
> >         eth_packet.set_payload(str("hello"))
> >         eth_packet.dst = packet.dst
> >         eth_packet.src = packet.src
> >         eth_packet.type = ethenet.IP_TYPE
> >
> >         self.send_openflow_packet(dpid,eth_packet.tostring(),inport)
> >
> > (2) I tried IPV4 and this time an error "  "H" format requires
> > <=number<=65535 " , here's the following code
> >
> >         ipv4_packet = ipv4()
> >         payload = str("hello")
> >         ipv4_packet.iplen = ipv4.MIN_LEN + len(payload)
> >         ipv4_packet.set_payload(payload)
> >         ipv4_packet.dstip = str("10.0.0.3")
> >         ipv4_packet.srcip = str("192.168.56.102")
> >
> >         eth_packet= ethernet()
> >         eth_packet.set_payload(ipv4_packet)
> >         packet.dst = packet.dst
> >        eth_packet.src = packet.src
> >         eth_packet.type = ethenet.IP_TYPE
> >         ipv4_packet.csum = ipv4_packet.checksum()
> >
> >         self.send_openflow_packet(dpid,ipv4_packet.tostring(),inport)
> >
> > I guess why it is failed maybe due to such line ipv4_packet.dstip
> > = str("10.0.0.3") is not acceptable. Or other reasons?
> >
> > Thanks very much.
> >
> > Weiyang
> >
> >
> >
> >
> > 2012/4/25 Aaron Rosen <[email protected]>
> >>
> >> 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
> >
> >
>
>
>
> --
> Aaron O. Rosen
> Masters Student - Network Communication
> 306B Fluor Daniel
>

Reply via email to