Hello,

I emailed the mailing list about this before but it seems like maybe
something changed or maybe I'm blind. Anyways, the following code generates
the following execption.  Any ideas what's going wrong?


 def send_udp(mac, dstip, srcip, port, payload):
    l4 = udp()
    l4.srcport = 1999
    l4.dstport = 1998
    l4.len = udp.MIN_LEN  + len("hello world")
    l4.set_payload("hello world")
    l4.arr = l4.tostring()

    l3 = ipv4()
    l3.iplen = ipv4.MIN_LEN + l4.len
    l3.protocol = ipv4.UDP_PROTOCOL
    l3.dstip = ipstr_to_int("10.1.1.1")
    l3.srcip = ipstr_to_int("10.1.1.2")
    l3.set_payload(l4)

    l2 = ethernet()
    l2.set_payload(l3)
    l2.dst = octstr_to_array("00:00:00:00:00:01")
    l2.src = octstr_to_array("00:00:00:00:00:09")
    l2.type = ethernet.IP_TYPE
    l3.checksum()
    l4.csum = l4.checksum()
    return l2


00019|pyrt|ERR:unable to invoke a Python event handler:
Traceback (most recent call last):
  File "./nox/lib/util.py", line 114, in f
    event.total_len, buffer_id, packet)
  File "./nox/coreapps/examples/sos.py", line 626, in packet_in_callback
    learn(dpid, inport, packet, packet.arr, bufid)
  File "./nox/coreapps/examples/sos.py", line 194, in learn
    forward(dpid, inport, packet, packet.arr, bufid, TRUNK_PORT)
  File "./nox/coreapps/examples/sos.py", line 315, in forward
    ret = install_agent_flows(dpid, inport, packet, buf, bufid, TRUNK_PORT);
  File "./nox/coreapps/examples/sos.py", line 575, in install_agent_flows
    inform_dest = send_udp(mac, dstip, srcip, port, payload)
  File "./nox/coreapps/examples/sos.py", line 89, in send_udp
    l3.checksum()
  File "./nox/lib/packet/ipv4.py", line 162, in checksum
    self.dstip)
error: 'H' format requires 0 <= number <= 65535


On Mon, Jun 20, 2011 at 1:59 PM, Aaron Rosen <aro...@clemson.edu> wrote:

> Thanks Murphy!
>
> You're right, that did the trick.
>
> Aaron
>
> On Mon, Jun 20, 2011 at 1:55 PM, Murphy McCauley <jam...@nau.edu> wrote:
> > So I think the call to l3.checksum() is extraneous, but the real issue is
> > probably that l3.iplen should be ipv4.MIN_LEN + l4.len.
> >
> > -- Murphy
> >
> > On Monday, June 20, 2011 09:42:07 AM Aaron Rosen wrote:
> >> Hi Murphy,
> >>
> >> wow... Opps...
> >>
> >> I'm trying the following: This doesn't return any errors but in
> >> wireshark the packet_outs say Malformed UDP packets.
> >>
> >> def send_udp_message():
> >>
> >>    l4 = udp()
> >>    l4.srcport = 1999
> >>    l4.dstport = 1888
> >>    l4.len = udp.MIN_LEN + len("hello_world")
> >>    l4.set_payload("Hello_world")
> >>    l4.arr = l4.tostring()
> >>
> >>    l3 = ipv4()
> >>    l3.iplen = ipv4.MIN_LEN
> >>    l3.protocol = ipv4.UDP_PROTOCOL
> >>    l3.dstip = ipstr_to_int("130.127.39.7");
> >>    l3.srcip = ipstr_to_int("1.1.1.1");
> >>    l3.set_payload(l4)
> >>
> >>    l2 = ethernet()
> >>    l2.set_payload(l3)
> >>    l2.dst = octstr_to_array("00:00:00:00:00:02")
> >>    l2.dst = octstr_to_array("a1:00:04:00:0a:04")
> >>    l2.type = ethernet.IP_TYPE
> >>    l3.checksum()
> >>    l4.csum = l4.checksum()
> >>
> >>    return l2
> >>
> >> ....
> >>     inst.send_openflow_packet(dpid, send_udp_message().tostring(),
> >> openflow.OFPP_FLOOD, inport)
> >>     source = mac_to_str(packet.src)
> >>
> >> On Mon, Jun 20, 2011 at 12:29 PM, Murphy McCauley <jam...@nau.edu>
> wrote:
> >> > Unfortunately, your tweak breaks the logic of the assert.
> >> >
> >> > The assert is asserting that self.next is a packet_base of some sort
> OR a
> >> > string.  You've set it to a string, so... it should be a string.  So
> it
> >> > should definitely not be a packet_base.  So the first of your asserts
> >> > will always fail.
> >> >
> >> > For the sake of testing, would you please comment out the first of
> your
> >> > two asserts (leaving only the one against type('')), and let me know
> the
> >> > result?
> >> >
> >> > -- Murphy
> >> >
> >> > On Monday, June 20, 2011 09:22:23 AM Aaron Rosen wrote:
> >> >> Hi Murphy,
> >> >>
> >> >> I'm using zaku but the one in destiny looked the same to be.
> >> >>
> >> >> I changed to assert to be on two lines so I could see which one was
> >> >> firing.
> >> >>
> >> >>     def checksum(self):
> >> >>         #assert(isinstance(self.next, packet_base) or type(self.next)
> >> >> == type(''))
> >> >>         assert(isinstance(self.next, packet_base))
> >> >>         assert(type(self.next) == type(''))
> >> >>
> >> >>
> >> >> Thanks,
> >> >>
> >> >> Aaron
> >> >>
> >> >> On Mon, Jun 20, 2011 at 12:19 PM, Murphy McCauley <jam...@nau.edu>
> wrote:
> >> >> > What NOX are you using?  Your udp.py does not seem to be the one in
> >> >> > zaku or destiny...
> >> >> >
> >> >> > -- Murphy
> >> >> >
> >> >> > On Sunday, June 19, 2011 03:34:20 PM Aaron Rosen wrote:
> >> >> >> Hello,
> >> >> >>
> >> >> >> I'm trying to send udp packets from my controller but I'm getting
> the
> >> >> >> following assertion when I call udp().checksum(). I was hoping
> >> >> >> someone could point out where I'm going wrong.
> >> >> >>
> >> >> >> Thanks,
> >> >> >>
> >> >> >> Aaron
> >> >> >>
> >> >> >> Traceback (most recent call last):
> >> >> >>   File "./nox/lib/util.py", line 116, in f
> >> >> >>     event.total_len, buffer_id, packet)
> >> >> >>   File "./nox/coreapps/examples/sos.py", line 299, in
> >> >> >> packet_in_callback learn(dpid, inport, packet)
> >> >> >>   File "./nox/coreapps/examples/sos.py", line 56, in learn
> >> >> >>     send_packet = send_udp_message()
> >> >> >>   File "./nox/coreapps/examples/sos.py", line 48, in
> send_udp_message
> >> >> >>     l4.csum = l4.checksum()
> >> >> >>   File "./nox/lib/packet/udp.py", line 111, in checksum
> >> >> >>     assert(isinstance(self.next, packet_base))
> >> >> >> AssertionError
> >> >> >>
> >> >> >>
> >> >> >> def send_udp_message():
> >> >> >>
> >> >> >>     l4 = udp()
> >> >> >>     l4.srcport = 1999
> >> >> >>     l4.dstport = 1888
> >> >> >>     l4.len = udp.MIN_LEN + len("hello_world")
> >> >> >>     l4.set_payload("Hello_world")
> >> >> >>
> >> >> >>     l3 = ipv4()
> >> >> >>     l3.iplen = ipv4.MIN_LEN
> >> >> >>     l3.protocol = ipv4.UDP_PROTOCOL
> >> >> >>     l3.dstip = ipstr_to_int("130.127.39.7");
> >> >> >>     l3.srcip = ipstr_to_int("1.1.1.1");
> >> >> >>     l3.set_payload(l4)
> >> >> >>
> >> >> >>     l2 = ethernet()
> >> >> >>     l2.set_payload(l3)
> >> >> >>     l2.dst = octstr_to_array("00:00:00:00:00:02")
> >> >> >>     l2.dst = octstr_to_array("a1:00:04:00:0a:04")
> >> >> >>     l2.type = ethernet.IP_TYPE
> >> >> >>     l3.checksum()
> >> >> >>     l4.csum = l4.checksum()
> >> >> >>
> >> >> >>     return l2
> >> >> >>
> >> >> >>
> >> >> >> ....
> >> >> >>     send_packet = send_udp_message()
> >> >> >>     inst.send_openflow_packet(dpid, send_packet.tostring(),
> >> >> >> openflow.OFPP_FLOOD, inport)
> >
>
>
>
> --
> Aaron O. Rosen
> Masters Student - Network Communication
> 306B Fluor Daniel
>



-- 
Aaron O. Rosen
Masters Student - Network Communication
306B Fluor Daniel
_______________________________________________
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev

Reply via email to