lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] the RST is sent as the connection is established


From: Rishi Khan
Subject: Re: [lwip-users] the RST is sent as the connection is established
Date: Thu, 19 Jun 2008 12:22:38 -0400

I have faced this problem. It turned out that I had two instances running using the same IP. When I killed the other instance, everything was fine. I spent a day trying to track that down.
Rishi

On Jun 19, 2008, at 12:15 PM, Kiran Bacchewar wrote:


Hi all,

Am to trying to impliment the web-server , lwip works fine till the connection establishment with the web browser.. but as soon as it recieves the ACK from the browser (in return to the ACK+SYN sent by the lwip), lwip sends the RST instead of waiting for the GET / HTTP/ 1.1 segment from the browser....

The following debugging statements generated by LWIP  may help you....
192.168.1.103 is the ip address of the machine on which browser is running 192.168.1.104 is the ip address of the board on which lwip is running..

the code that iam using is the same which is given in the lwip doc. iam using the RAW API... as there is no operating system in the board..

has any one faced this problem before??
update_arp_entry()
update_arp_entry: 192.168.1.103 - 00:50:ba:b1:1c:0d
find_entry: found matching stable entry 1
update_arp_entry: updating stable entry 1
pbuf_header: old 0x000210e0 new 0x000210ee (-14)
iam in ip_input()ip_input: iphdr->dest 0xc0a80168 netif->ip_addr 0xc0a80168 (0xc0a80100, 0xc0a80100, 0x68)
ip_input: packet accepted on interface FE
ip_input:
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        40     | (v, hl, tos, len)
+-------------------------------+
|    20677      |010|       0   | (id, flags, offset)
+-------------------------------+
|  128  |    6  |    0x25eb     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |    1  |  103  | (src)
+-------------------------------+
|  192  |  168  |    1  |  104  | (dest)
+-------------------------------+
ip_input: p->len 40 p->tot_len 40
iam in tcp_input layerTCP header:
+-------------------------------+
|     1317      |       80      | (src port, dest port)
+-------------------------------+
|           0477804200          | (seq no)
+-------------------------------+
|           0000006511          | (ack no)
+-------------------------------+
|  5 |   |010000|     65535     | (hdrlen, flags (ACK ), win)
+-------------------------------+
|    0x39ae     |         0     | (chksum, urgp)
+-------------------------------+
pbuf_header: old 0x000210ee new 0x00021102 (-20)
inet_chksum_pseudo(): checksumming pbuf 0x00037fb0 (has next 0x00000000)
inet_chksum_pseudo(): pbuf chain lwip_chksum()=ffff
pbuf_header: old 0x00021102 new 0x00021116 (-20)
+-+-+-+-+-+-+-+-+-+-+-+-+-+- tcp_input: flags ACK -+-+-+-+-+-+-+-+- +-+-+-+-+-+
State: SYN_RCVD
TCP connection established 1317 -> 80.
end of http_accept()
tcp_pcb_purge
tcp_pcb_purge: data left on ->unacked
pbuf_free(0x00021800)
pbuf_free: deallocating 0x00021800
tcp_abort: sending RST
pbuf_alloc(length=20)
pbuf_alloc(length=20) == 0x00021800
inet_chksum_pseudo(): checksumming pbuf 0x00021800 (has next 0x00000000)
inet_chksum_pseudo(): pbuf chain lwip_chksum()=656
pbuf_header: old 0x00021840 new 0x0002182c (20)
ip_output_if: FE0
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        40     | (v, hl, tos, len)
+-------------------------------+
|        7      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |    6  |    0x37a9     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |    1  |  104  | (src)
+-------------------------------+
|  192  |  168  |    1  |  103  | (dest)
+-------------------------------+
netif->output()pbuf_header: old 0x0002182c new 0x0002181e (14)
etharp_send_ip: sending packet 0x00021800
pbuf_free(0x00021800)
pbuf_free: deallocating 0x00021800
tcp_rst: seqno 6511 ackno 477804200.
pbuf_free(0x00037fb0)
pbuf_free: deallocating 0x00037fb0
State: CLOSED


/* A simple HTTP/1.0 server direcly interfacing the stack. */
#include "tcp.h"
#include"err.h"
void http_init(void);
static err_t http_accept(void *, struct tcp_pcb *,err_t);
static err_t http_recv(void *, struct tcp_pcb *, struct pbuf *,err_t);
/* This is the data for the actual web page. */
static char indexdata[] =
"HTTP/1.0 200 OK\r\n\
Content-type: text/html\r\n\
\r\n\
<html> \
<head><title>A test page</title></head> \
<body> \
This is a small test page. \
</body> \
</html>";

/* The initialization function. */
void http_init(void)
{
 struct tcp_pcb *pcb;
 /* Create a new TCP PCB. */
 pcb = tcp_new();
 /* Bind the PCB to TCP port 80. */
 tcp_bind(pcb, NULL, 80);
 /* Change TCP state to LISTEN. */
 pcb=tcp_listen(pcb);
 /* Set up http_accet() function to be called
 when a new connection arrives. */
 tcp_accept(pcb, http_accept);
}

/* This is the callback function that is called when
a connection has been accepted. */
static err_t http_accept(void *arg, struct tcp_pcb *pcb,err_t result)
{
 /* Set up the function http_recv() to be called when data
 arrives. */
 tcp_recv(pcb, http_recv);

}


/* This is the callback function that is called
when a TCP segment has arrived in the connection. */
static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p,err_t result)
{
char *rq;
/* If we got a NULL pbuf in p, the remote end has closed
the connection. */

 if(p != NULL)
 {
  /* The payload pointer in the pbuf contains the data
  in the TCP segment. */
  rq = p->payload;
  /* Check if the request was an HTTP "GET /\r\n". */
if(rq[0] == 'G' && rq[1] == 'E' && rq[2] == 'T' && rq[3] == ' ') // removed some conditions just for simplicity

  {
  /* Send the web page to the remote host. A zero
  in the last argument means that the data should
  not be copied into internal buffers. */

  tcp_write(pcb, indexdata, sizeof(indexdata), 0);
  }

 /* Free the pbuf. */

 pbuf_free(p);
 }

 /* Close the connection. */

 tcp_close(pcb);
}



--
Regards,
Kirankumar K B
M: 9373709346
_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users





reply via email to

[Prev in Thread] Current Thread [Next in Thread]