[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] UDP reception problem
From: |
Peter LM |
Subject: |
[lwip-users] UDP reception problem |
Date: |
Fri, 28 Jun 2013 06:42:53 -0700 (PDT) |
Hi Everybody
I am facing a problem concerning UDP reception. After have written my
driver, I am currently testing it and things worked well until UDP test. Let
me explain:
_ARP is correctly running
_ICMP is correctly running
_IP is correctly running
_UDP *broadcast sending* is correctly running through netconn API
_UDP *reception* doesn't work at all through netconn API
_UDP *reception* receives *one * packet through RAW API then crash at the
second UDP request(ICMP not reachable sent)
I am using the latest release of lwIP in multi-threading with FreeRTOS
Could anybody help me? Note that I'm working on embedded system and don't
have standard output... but these are my settings from lwipopts.h :
/*********************************************************/
#define BYTE_ORDER LITTLE_ENDIAN
#define XLWIP_CONFIG_INCLUDE_EMACLITE 1
#define TCPIP_THREAD_NAME "tcpip"
#define LWIP_HTTPD_MAX_TAG_NAME_LEN 20
#define LWIP_HTTPD_MAX_TAG_INSERT_LEN 1500
#define TCPIP_THREAD_PRIO configLWIP_TASK_PRIORITY
#define TCPIP_THREAD_STACKSIZE configTCPIP_TASK_STACK_SIZE
#define DEFAULT_THREAD_STACKSIZE configDEFAULT_THREAD_STACKSIZE
#define DEFAULT_TCP_RECVMBOX_SIZE 5
#define DEFAULT_UDP_RECVMBOX_SIZE 5
#define DEFAULT_ACCEPTMBOX_SIZE 5
#define TCPIP_MBOX_SIZE 10
#define NO_SYS 0
#define LWIP_SOCKET 1
#define LWIP_NETCONN 1
#define LWIP_SNMP 0
#define LWIP_IGMP 0
#define LWIP_ICMP 1
#define LWIP_DNS 0
#define LWIP_HAVE_LOOPIF 0
#define TCP_LISTEN_BACKLOG 0
#define LWIP_SO_RCVTIMEO 1
#define LWIP_SO_RCVBUF 1
#undef LWIP_DEBUG
#ifdef LWIP_DEBUG
#define LWIP_DBG_MIN_LEVEL 0
#define PPP_DEBUG LWIP_DBG_OFF
#define MEM_DEBUG LWIP_DBG_ON
#define MEMP_DEBUG LWIP_DBG_ON
#define PBUF_DEBUG LWIP_DBG_ON
#define API_LIB_DEBUG LWIP_DBG_OFF
#define API_MSG_DEBUG LWIP_DBG_OFF
#define TCPIP_DEBUG LWIP_DBG_OFF
#define NETIF_DEBUG LWIP_DBG_OFF
#define SOCKETS_DEBUG LWIP_DBG_OFF
#define DNS_DEBUG LWIP_DBG_OFF
#define AUTOIP_DEBUG LWIP_DBG_OFF
#define DHCP_DEBUG LWIP_DBG_OFF
#define IP_DEBUG LWIP_DBG_OFF
#define IP_REASS_DEBUG LWIP_DBG_OFF
#define ICMP_DEBUG LWIP_DBG_OFF
#define IGMP_DEBUG LWIP_DBG_OFF
#define UDP_DEBUG LWIP_DBG_OFF
#define TCP_DEBUG LWIP_DBG_OFF
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
#define TCP_RTO_DEBUG LWIP_DBG_OFF
#define TCP_CWND_DEBUG LWIP_DBG_OFF
#define TCP_WND_DEBUG LWIP_DBG_OFF
#define TCP_FR_DEBUG LWIP_DBG_OFF
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
#define TCP_RST_DEBUG LWIP_DBG_OFF
#endif
#define LWIP_DBG_TYPES_ON
(LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT)
#define MEM_ALIGNMENT 4
#define MEM_SIZE 5120
#define MEMP_NUM_PBUF 6
#define LWIP_RAW 0
#define MEMP_NUM_RAW_PCB 2
#define MEMP_NUM_UDP_PCB 8
#define MEMP_NUM_TCP_PCB 2
#define MEMP_NUM_TCP_PCB_LISTEN 2
#define MEMP_NUM_TCP_SEG 8
#define MEMP_NUM_SYS_TIMEOUT 10
#define MEMP_NUM_NETBUF 4
#define MEMP_NUM_NETCONN 4
#define MEMP_NUM_TCPIP_MSG_API 4
#define MEMP_NUM_TCPIP_MSG_INPKT 4
#define MEMP_NUM_ARP_QUEUE 5
#define PBUF_POOL_SIZE 11
#define PBUF_POOL_BUFSIZE 375
#define PBUF_LINK_HLEN 16
#define SYS_LIGHTWEIGHT_PROT (NO_SYS==0)
#define LWIP_TCP 1
#define TCP_TTL 255
#define TCP_QUEUE_OOSEQ 0
#define TCP_MSS 1460
#define TCP_SND_BUF ( TCP_MSS * 2 )
#define TCP_SND_QUEUELEN (4 * TCP_SND_BUF/TCP_MSS)
#define TCP_SNDLOWAT (TCP_SND_BUF/2)
#define TCP_WND (PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - (PBUF_LINK_HLEN +
PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)))
#define TCP_MAXRTX 12
#define TCP_SYNMAXRTX 4
#define LWIP_ARP 1
#define ARP_TABLE_SIZE 10
#define ARP_QUEUEING 1
#define IP_FORWARD 0
#define IP_REASSEMBLY 1
#define IP_REASS_MAX_PBUFS 10
#define MEMP_NUM_REASSDATA 10
#define IP_FRAG 0
#define ICMP_TTL 255
#define LWIP_DHCP 0
#define DHCP_DOES_ARP_CHECK (LWIP_DHCP)
#define LWIP_AUTOIP 0
#define LWIP_DHCP_AUTOIP_COOP (LWIP_DHCP && LWIP_AUTOIP)
#define LWIP_UDP 1
#define LWIP_UDPLITE 1 //Enable UDP
Lite support for all API layers.
#define UDP_TTL 255
#define LWIP_STATS 0
#define LWIP_STATS_DISPLAY 0
#if LWIP_STATS
#define LINK_STATS 1
#define IP_STATS 1
#define ICMP_STATS 0
#define IGMP_STATS 0
#define IPFRAG_STATS 1
#define UDP_STATS 0
#define TCP_STATS 1
#define MEM_STATS 1
#define MEMP_STATS 1
#define PBUF_STATS 1
#define SYS_STATS 1
#endif /* LWIP_STATS */
#define PPP_SUPPORT 0 /* Set > 0 for PPP */
#if PPP_SUPPORT
#define NUM_PPP 1 /* Max PPP
sessions. */
#define PPPOE_SUPPORT 1
#define PPPOS_SUPPORT 1
#define PAP_SUPPORT 1 /* Set > 0
for PAP. */
#define CHAP_SUPPORT 1 /* Set > 0 for CHAP.
*/
#define MSCHAP_SUPPORT 0 /* Set > 0 for MSCHAP
(NOT FUNCTIONAL!) */
#define CBCP_SUPPORT 0 /* Set > 0 for CBCP
(NOT FUNCTIONAL!) */
#define CCP_SUPPORT 0 /* Set > 0
for CCP (NOT FUNCTIONAL!) */
#define VJ_SUPPORT 1 /* Set > 0
for VJ header compression. */
#define MD5_SUPPORT 1 /* Set > 0
for MD5 (see also CHAP) */
/************************************************************************/
*/Netconn reception (does not work !)/* :
static void udpecho_thread(void *arg)
{
struct netconn *conn;
char msg[]="testing" ;
struct netbuf *buf;
char * data;
err_t err;
conn = netconn_new( NETCONN_UDP );
if(netconn_bind(conn, IP_ADDR_ANY, 1234 )== ERR_USE ) //local
port
debug_raw("Alt already used");
netconn_connect(conn, IP_ADDR_BROADCAST, 1235 );
for( ;; ){
//reception part
if((err = netconn_recv(conn, &buf))==ERR_OK)
debug_raw("data received !!");
//return ERR_OK if data has been
received
//sending part
buf = netbuf_new();
data =netbuf_alloc(buf, sizeof(msg));
memcpy (data, msg, sizeof (msg));
//netconn_send(conn, buf);
netbuf_delete(buf); // De-allocate packet buffer
vTaskDelay( 200 ); //some delay!
}
}
void udpecho_init(void)
{
sys_thread_new("udpecho_thread", udpecho_thread, NULL,
TCPIP_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO + 1);
}
*/Raw reception (accept only one UDP request ! )/* :
/* UDP receive
.............................................................*/
void my_udp_rx(void *arg, struct udp_pcb *upcb,
struct pbuf *p, struct ip_addr *addr, u16_t port)
{
/* process the payload in p->payload */
if(udp_connect(upcb, addr, port)==ERR_OK){ /* connect to the
remote host */
debug_raw("DATA 2");
debug_raw((char *)p->payload);
}
pbuf_free(p); /* don't leak the pbuf! */
}
/* UDP initialization
......................................................*/
void my_udp_init(void) {
g_upcb = udp_new();
udp_bind(g_upcb, IP_ADDR_ANY, 1234);
udp_recv(g_upcb, &my_udp_rx, (void *)0);
}
Thank you in advance,
BR,
PLM
--
View this message in context:
http://lwip.100.n7.nabble.com/UDP-reception-problem-tp21624.html
Sent from the lwip-users mailing list archive at Nabble.com.
- [lwip-users] UDP reception problem,
Peter LM <=