RE: UDP connection
2011-06-24 09:38:46 GMT
Hello.
Have a look at the DHCP client process in dhcpc.c in the apps folder of the package.
Remember to include the UDP (an option in the build of uIP)!
Regards,
Edward Harris.
From: Edgardo C. [mailto:edxxgardo <at> gmail.com]
Sent: 24 June 2011 08:22
To: uip-users <at> sics.se
Subject: [uip-users] UDP connection
Hello,
Could somebody point me an example of sending and receiving simple UDP packets with uIP?. I want to establish a UDP communication between a computer and a PCB.
Thanks in advance,
UDP problems with IP header
2011-06-27 13:28:36 GMT
Hello again,
RE: UDP problems with IP header
2011-06-27 13:52:35 GMT
Just check the flag variable and the packet buffer contents when this message is printed. I suspect that UDP packet is ready to be sent and packet buffer is containing UDP headers but uip_process() is called in context of something else (other than UIP_UDP_SEND_CONN)
-amit
From: Edgardo C. [mailto:edxxgardo <at> gmail.com]
Sent: Monday, June 27, 2011 9:29 AM
To: uip-users <at> sics.se
Subject: [uip-users] UDP problems with IP header
Hello again,
I have a problem with my UDP application. When I send UDP packets from my pc, I get the following error in uIP:
"invalid version or header length" and using a log I can see that it is 0x46 and not 0x45 as expected for IPV4. IPV6 is disabled in my Linux pc and there are no macros in uIP enabling it. Any idea how to solve it? thx in advance,
Regards,
IMPORTANT CONFIDENTIALITY NOTICE
This message and any attached documents contain information from ViXS Systems, Inc. and are confidential and privileged and further subject to any confidentiality agreement between the parties. The information is intended to be viewed only by the individual(s) or entity(ies) to whom the message is addressed. If you are not the intended recipient, be aware that reading, disclosing, copying, distributing or using the contents of this transmission is prohibited. Please notify us immediately if you have received this transmission in error, and delete this message along with any attached files.
Re: UDP problems with IP header
2011-06-27 14:14:58 GMT
Thx a lot for your suggestion and help,
I just tried printing "uip_flags & UIP_NEWDATA" and uip_len when the error message is printed, in the uip.c
uip_flags & UIP_NEWDATA is 0
uip_len is 54
meaning that there is no data available for the application
the code is this:
#ifndef __UDPAPP_H__
#define __UDPAPP_H__
#include "pt.h"
typedef struct socket_app_state {
char name;
} uip_tcp_appstate_t;
void dummy_app_appcall(void);
#ifndef UIP_APPCALL
#define UIP_APPCALL dummy_app_appcall
#endif /* UIP_APPCALL */
typedef struct udpapp_state {
struct pt pt;
char state;
char inputbuf[10];
} uip_udp_appstate_t;
void udp_init(void);
void udpapp_appcall(void);
#ifndef UIP_UDP_APPCALL
#define UIP_UDP_APPCALL udpapp_appcall
#endif /* UIP_UDP_APPCALL */
void udpapp_init(void);
#endif /* __UDPAPP_H__ */
*********************************************************************************************************************************************
#include "uip.h"
#include <string.h>
#include "udp.h"
#define STATE_INIT 0
#define STATE_LISTENING 1
#define STATE_HELLO_RECEIVED 2
#define STATE_NAME_RECEIVED 3
static struct udpapp_state s;
void dummy_app_appcall(void)
{
}
void udp_init(void)
{
uip_ipaddr_t addr;
struct uip_udp_conn *c;
uip_listen(HTONS(1167)); the local port
uip_ipaddr(&addr, 192,168,0,1); the server where to send UDP
c = uip_udp_new(&addr, HTONS(9988)); the server port
if(c != NULL) {
uip_udp_bind(c, HTONS(1167));
}
s.state = STATE_INIT;
PT_INIT(&s.pt);
}
static unsigned char parse_msg(void)
{
if (memcmp(uip_appdata, "Hello", 5) == 0) {
return 1;
}
return 0;
}
static void send_request(void)
{
char str[] = "Hello. What is your name?\n";
memcpy(uip_appdata, str, strlen(str));
uip_send(uip_appdata, strlen(str));
}
static void send_response(void)
{
int i = 0;
char str[] = "Hello ";
while ( ( ((char*)uip_appdata)[i] != '\n') && i < 9) {
s.inputbuf[i] = ((char*)uip_appdata)[i];
i++;
}
s.inputbuf[i] = '\n';
memcpy(uip_appdata, str, 6);
memcpy(uip_appdata+6, s.inputbuf, i+1);
uip_send(uip_appdata, i+7);
}
static PT_THREAD(handle_connection(void))
{
PT_BEGIN(&s.pt);
s.state = STATE_LISTENING;
do {
PT_WAIT_UNTIL(&s.pt, uip_newdata());
if(uip_newdata() && parse_msg()) {
s.state = STATE_HELLO_RECEIVED;
uip_flags &= (~UIP_NEWDATA);
break;
}
} while(s.state != STATE_HELLO_RECEIVED);
do {
send_request();
PT_WAIT_UNTIL(&s.pt, uip_newdata());
if(uip_newdata()) {
s.state = STATE_NAME_RECEIVED;
uip_flags &= (~UIP_NEWDATA);
break;
}
} while(s.state != STATE_NAME_RECEIVED);
send_response();
s.state = STATE_INIT;
PT_END(&s.pt);
}
void udpapp_appcall(void)
{
handle_connection();
}
the main is just the main in the unix folder when you download uIP, changed to call the udp_init, that's it.
Hope this helps, there are no more changes. Thanks again and I hope you can help me,
Just check the flag variable and the packet buffer contents when this message is printed. I suspect that UDP packet is ready to be sent and packet buffer is containing UDP headers but uip_process() is called in context of something else (other than UIP_UDP_SEND_CONN)
-amit
From: Edgardo C. [mailto:edxxgardo <at> gmail.com]
Sent: Monday, June 27, 2011 9:29 AM
To: uip-users <at> sics.se
Subject: [uip-users] UDP problems with IP header
Hello again,
I have a problem with my UDP application. When I send UDP packets from my pc, I get the following error in uIP:
"invalid version or header length" and using a log I can see that it is 0x46 and not 0x45 as expected for IPV4. IPV6 is disabled in my Linux pc and there are no macros in uIP enabling it. Any idea how to solve it? thx in advance,
Regards,
IMPORTANT CONFIDENTIALITY NOTICE
This message and any attached documents contain information from ViXS Systems, Inc. and are confidential and privileged and further subject to any confidentiality agreement between the parties. The information is intended to be viewed only by the individual(s) or entity(ies) to whom the message is addressed. If you are not the intended recipient, be aware that reading, disclosing, copying, distributing or using the contents of this transmission is prohibited. Please notify us immediately if you have received this transmission in error, and delete this message along with any attached files.
Re: UDP problems with IP header
2011-06-27 15:36:31 GMT
Hello Peter,
Hello Edgardo,
Remove the uip_listen() call because this is only for TCP.
Do you receive nothing at all (the 1st Hello), or do you see the error after waiting for response after send_request()?
In the last case, try resetting the newdata flag directly after send_request().
Regards,
Peter
Re: UDP problems with IP header
2011-06-27 16:03:47 GMT
----- Original Message -----From: Edgardo C.To: Peter ZuidemaSent: Monday, June 27, 2011 5:36 PMSubject: Re: [uip-users] UDP problems with IP headerHello Peter,First of all, let me say that I am compiling both, the uip UDP application and the pc application on a Linux pc. So, the application that send the UDP datagrams is a GUI application running on the Linux machine where the uip run as well. So, both application run on the same machine.I removed the uip_listen and the problem persist. I do not receive any packet and what is weird is that even though I don't send any packet from the application, as soon as I run the uip UDP aplication, it gives me the error. I tried compiling the httpd application that comes into the uip package and I get the same error. agrrrrrrrrrrrrrrrrrrrrrI have no idea.2011/6/27 Peter Zuidema <pzuidema <at> opencontroller.com>Hello Edgardo,
Remove the uip_listen() call because this is only for TCP.
Do you receive nothing at all (the 1st Hello), or do you see the error after waiting for response after send_request()?
In the last case, try resetting the newdata flag directly after send_request().
Regards,
Peter
Re: UDP problems with IP header
2011-06-27 19:26:03 GMT
Hello Peter and Martin,
Hello Edgardo,
Martin is right about that 0x46 is possible in the IP header, but it is not supported by uIP v1.0
So there is probably some service or device on your network using longer headers. uIP just ignores them (drop).
Maybe try using netcat on your linux machine to send controlled UDP packets to your uIP application (replace IP address with the one uIP is using):
$ netcat -u -p 9988 192.168.8.8 1167
Type 'Hello' with Enter
Did you also try to run it on your microcontroller? Also test via ICMP and try to ping the uIP device (or application). If this all fails you have to trace the packets and see what is exactly received by the uIP stack.
I presume you have configured all the network stuff right? Like a valid MAC address (uip_ethaddr), IP-address (uip_hostaddr), Netmask (uip_netmask) and Default Router address (uip_draddr).
Regards,
Peter
On 27-6-2011 18:03, Martin Maurer wrote:Hello,have you tried to do a wireshark trace ? Do you see the error in wireshark ? Can you post the trace or content of the "broken" packet ?If i remember correctly, 0x46 (and higher) instead of 0x45 is possible. It means IP uses additional headers, so IP hdr is not 20 bytes (5 * 4 bytes) but 24 bytes (6 * 4 bytes) long.BTW: What uip version do you use ? 0.9 or 1.0 ?Best regards,Martin----- Original Message -----From: Edgardo C.To: Peter ZuidemaSent: Monday, June 27, 2011 5:36 PMSubject: Re: [uip-users] UDP problems with IP headerHello Peter,First of all, let me say that I am compiling both, the uip UDP application and the pc application on a Linux pc. So, the application that send the UDP datagrams is a GUI application running on the Linux machine where the uip run as well. So, both application run on the same machine.I removed the uip_listen and the problem persist. I do not receive any packet and what is weird is that even though I don't send any packet from the application, as soon as I run the uip UDP aplication, it gives me the error. I tried compiling the httpd application that comes into the uip package and I get the same error. agrrrrrrrrrrrrrrrrrrrrrI have no idea.2011/6/27 Peter Zuidema <pzuidema <at> opencontroller.com>Hello Edgardo,
Remove the uip_listen() call because this is only for TCP.
Do you receive nothing at all (the 1st Hello), or do you see the error after waiting for response after send_request()?
In the last case, try resetting the newdata flag directly after send_request().
Regards,
Peter
Re: UDP problems with IP header
2011-06-28 09:16:26 GMT
Hello, I am here again,
struct uip_udp_conn *c;
uip_ipaddr(&addr, 192,168,0,1); the server where to send UDP
c = uip_udp_new(&addr, HTONS(9988)); the server port
if(c != NULL) {
uip_udp_bind(c, HTONS(1167)); the local port
uip_ipaddr(&addr, 192,168,0,1); the server where to send UDP
uip_udp_conn = uip_udp_new(&addr, HTONS(9988)); the server port
uip_udp_bind(uip_udp_conn, HTONS(1167)); the local port
Hello Peter and Martin,Sorry I did not replay earlier, I am not at work now, So, tomorrow I'll check all you mentioned in the mails. The IP configuration is right, I checked it twice.This is the first time I use uIP, and I use it in Linux before installing it into the controller board. You are right, I checked uip.c and indeed, uIP drops the ip headers !=0x45. I send the UDP datagrams rom a QT application, so if uIP drop long ip headers, it means that I am not able to use uIP, what's a pity.I use uIP 1.0.Now I remember that the first time i downloaded uIP, I compile it in Ubuntu ( my linux machine) with the httpd and I tried accessing the web server from the browser and it worked, I could access to the html pages, so, it means that something happens afterwards. I'll let you know tomorrow. Thanks in advance guys for the support,Regards,2011/6/27 Peter Zuidema <pzuidema <at> opencontroller.com>Hello Edgardo,
Martin is right about that 0x46 is possible in the IP header, but it is not supported by uIP v1.0
So there is probably some service or device on your network using longer headers. uIP just ignores them (drop).
Maybe try using netcat on your linux machine to send controlled UDP packets to your uIP application (replace IP address with the one uIP is using):
$ netcat -u -p 9988 192.168.8.8 1167
Type 'Hello' with Enter
Did you also try to run it on your microcontroller? Also test via ICMP and try to ping the uIP device (or application). If this all fails you have to trace the packets and see what is exactly received by the uIP stack.
I presume you have configured all the network stuff right? Like a valid MAC address (uip_ethaddr), IP-address (uip_hostaddr), Netmask (uip_netmask) and Default Router address (uip_draddr).
Regards,
Peter
On 27-6-2011 18:03, Martin Maurer wrote:Hello,have you tried to do a wireshark trace ? Do you see the error in wireshark ? Can you post the trace or content of the "broken" packet ?If i remember correctly, 0x46 (and higher) instead of 0x45 is possible. It means IP uses additional headers, so IP hdr is not 20 bytes (5 * 4 bytes) but 24 bytes (6 * 4 bytes) long.BTW: What uip version do you use ? 0.9 or 1.0 ?Best regards,Martin----- Original Message -----From: Edgardo C.To: Peter ZuidemaSent: Monday, June 27, 2011 5:36 PMSubject: Re: [uip-users] UDP problems with IP headerHello Peter,First of all, let me say that I am compiling both, the uip UDP application and the pc application on a Linux pc. So, the application that send the UDP datagrams is a GUI application running on the Linux machine where the uip run as well. So, both application run on the same machine.I removed the uip_listen and the problem persist. I do not receive any packet and what is weird is that even though I don't send any packet from the application, as soon as I run the uip UDP aplication, it gives me the error. I tried compiling the httpd application that comes into the uip package and I get the same error. agrrrrrrrrrrrrrrrrrrrrrI have no idea.2011/6/27 Peter Zuidema <pzuidema <at> opencontroller.com>Hello Edgardo,
Remove the uip_listen() call because this is only for TCP.
Do you receive nothing at all (the 1st Hello), or do you see the error after waiting for response after send_request()?
In the last case, try resetting the newdata flag directly after send_request().
Regards,
Peter
RSS Feed