[lwip-users] UDP-server not working!

251 views
Skip to first unread message

Kai Parow-Souchon

unread,
Jul 31, 2011, 9:41:49 AM7/31/11
to lwip-...@nongnu.org
Hey!

I'm trying to get a simple UDP-server to work on an LM3S8538 stellaris arm.

TCP works great, but my UDP server initialized by:

pcb = udp_new();
udp_bind(pcb, IP_ADDR_ANY, 1338);

udp_recv(pcb, myUDPrcv, NULL);

always returns ICMP "destination unreachable (port unreachable)"
messages when I try to send a package to it.

In die config file I only defined LWIP_UDP - is there anything else that
needs to be configured?

I don't have any idea left to try...it's really simple but still doesn't
work ;)

Any suggestions or anything I can try or have a look at are welcome,
Thanks,
Kai

_______________________________________________
lwip-users mailing list
lwip-...@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Marcos Guerra Medina

unread,
Jul 31, 2011, 6:53:11 PM7/31/11
to Mailing list for lwIP users
you need to implemented this code:

udp -> myUDPrcv:
udp -> IP_ADDR_ANY;
udp -> 1338;

2011/7/31 Kai Parow-Souchon <kai....@googlemail.com>

Kieran Mansley

unread,
Aug 1, 2011, 4:19:58 AM8/1/11
to Mailing list for lwIP users
On Sun, 2011-07-31 at 15:41 +0200, Kai Parow-Souchon wrote:
> Any suggestions or anything I can try or have a look at are welcome,

Your UDP code looks fine to me. I suggest tracing a received packet
through the stack (e.g. by turning on some of the debugging code that
prints stuff out) and seeing where the packet gets dropped (or if it
never reaches lwIP at all).

Kieran

Kieran Mansley

unread,
Aug 1, 2011, 4:20:25 AM8/1/11
to Mailing list for lwIP users
On Sun, 2011-07-31 at 23:53 +0100, Marcos Guerra Medina wrote:
> you need to implemented this code:
>
> udp -> myUDPrcv:
> udp -> IP_ADDR_ANY;
> udp -> 1338;

This makes no sense to me.

Kieran

Marcos Guerra Medina

unread,
Aug 1, 2011, 6:35:14 AM8/1/11
to Mailing list for lwIP users

sorry:

        upcb->remote_ip.addr = IP_ADDR_PC_LAB;
        upcb->remote_port = 1338;
        upcb->local_ip.addr = IP_ADDR_LOCAL;

Kieran Mansley

unread,
Aug 1, 2011, 6:39:50 AM8/1/11
to Mailing list for lwIP users
On Mon, 2011-08-01 at 11:35 +0100, Marcos Guerra Medina wrote:
> sorry:
>
> upcb->remote_ip.addr = IP_ADDR_PC_LAB;
> upcb->remote_port = 1338;
> upcb->local_ip.addr = IP_ADDR_LOCAL;

No, you shouldn't be setting internal state of the PCB directly.
udp_bind() will set the local ip and port fields, udp_connect() will set
the remote ip and port fields, but without a udp_connect() you should be
able to receive traffic (I think).

Chris Williams

unread,
Aug 1, 2011, 4:46:04 AM8/1/11
to lwip-...@nongnu.org
Quoting Kai Parow-Souchon <kai....@googlemail.com>:

> Hey!
>
> I'm trying to get a simple UDP-server to work on an LM3S8538 stellaris arm.
>

You talk about a server? A server sends data to something else.
Looking at the code you seem to be trying to receive UDP data ie client!

Are you clear which one you are doing?

Chris.

> TCP works great, but my UDP server initialized by:
>
> pcb = udp_new();
> udp_bind(pcb, IP_ADDR_ANY, 1338);
>
> udp_recv(pcb, myUDPrcv, NULL);
>
> always returns ICMP "destination unreachable (port unreachable)"
> messages when I try to send a package to it.
>
> In die config file I only defined LWIP_UDP - is there anything else
> that needs to be configured?
>
> I don't have any idea left to try...it's really simple but still
> doesn't work ;)
>
> Any suggestions or anything I can try or have a look at are welcome,
> Thanks,
> Kai
>
> _______________________________________________
> lwip-users mailing list
> lwip-...@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/lwip-users
>
>

--
---------------------------------------------------------------------------
| Chris Williams EMail ch...@chrydesn.co.uk |
| Web www.chrydesn.co.uk |
| Tel/Fax 01686 688065 |
| Chrysalis Design. Electronics, Computers, Hardware, Software. |
| Design and development to meet all your needs. |
---------------------------------------------------------------------------

Kieran Mansley

unread,
Aug 1, 2011, 8:19:07 AM8/1/11
to Mailing list for lwIP users
On Mon, 2011-08-01 at 09:46 +0100, Chris Williams wrote:
>
> You talk about a server? A server sends data to something else.
> Looking at the code you seem to be trying to receive UDP data ie
> client!

The distinction between server and client is always a difficult one, as
both involve sending and receiving, but a server will typically first
receive a request, then send its response, with a client the other way
round. I think their server is trying to receive the request and
failing.

Kieran

Kai Parow-Souchon

unread,
Aug 1, 2011, 8:29:08 AM8/1/11
to Mailing list for lwIP users
Hey!

first, let me thank you all for your help :)

And yes, Kieran is right, my "server" should be able to receive commands
or requests and should answer with anything appriopriate to that. In my
understanding this would make it a server ;)

@Marcos: doesn't work, but this values are definitively written in
udp_bind...

@Kieran: tracking a packet through debug-outputs is kind of difficult,
as my debug outputs are crashing the ARM from time to time (when setting
IP_DEBUG). Setting only UDP_DEBUG i just get a lot of confusing logs
which doesn't seem to be related to the event me sending a debug-packet
to the ARM.

I once got a "UDP: not for us" message, but that was just once.

The outputs for bind are completely chaotic, number encoding doesn't
seem to like me at the moment.
I'll have a look on that soon...

Thanks all,
Kai

Kieran Mansley

unread,
Aug 1, 2011, 8:35:47 AM8/1/11
to Mailing list for lwIP users
On Mon, 2011-08-01 at 14:29 +0200, Kai Parow-Souchon wrote:
> tracking a packet through debug-outputs is kind of difficult,
> as my debug outputs are crashing the ARM from time to time (when
> setting
> IP_DEBUG).

I wonder if that is due to some assertion firing. It could be related
to your problem.

> Setting only UDP_DEBUG i just get a lot of confusing logs
> which doesn't seem to be related to the event me sending a
> debug-packet
> to the ARM.

Perhaps you would be better turning off most of the messages, and just
changing the log level of a couple of useful ones so you see those.
That should make it easier to see things that are relevant.

> I once got a "UDP: not for us" message, but that was just once.
>
> The outputs for bind are completely chaotic, number encoding doesn't
> seem to like me at the moment.
> I'll have a look on that soon...

I don't like the sound of that. I think it's worth looking into.

Reply all
Reply to author
Forward
0 new messages