cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
4,585 Views
Registered: ‎01-05-2010

lwip client on ZC702 [RST,ACK] received

Hi All,

 

I am trying to add some networking capabilities to my ZC702 design. I have PC running a Server and ZC702 running a LWIP-TCP Client. Following is my LWIP client side code snippet

 

1) I bind local lwip socket to IP address 192.168.1.10 on port 8888

2) I bind the remote server to IP address 192.168.1.100 on port 8888 and listen to any incoming connections

3) lwip client calls tcp_connect() 

4) In the callback function connected to tcp_connect I try to send some data to the remote server by calling tcp_write() 

 

int custom_application(){
	struct tcp_pcb *pcb;
	err_t err;
	u16_t port = 8888;
	//ip_addr_t server_ip;
	//ip_addr_t local_ip;

	struct ip_addr server_ip,local_ip;

	/* create new TCP PCB structure */
	pcb = tcp_new();
	if (!pcb) {
		xil_printf("Error creating PCB. Out of Memory\n\r");
		return -1;
	}

	IP4_ADDR(&server_ip,  192, 168,   1, 100);
	IP4_ADDR(&local_ip,  192, 168,   1, 10);

	//server_ip.addr =  inet_addr("192.168.1.100");
	//local_ip.addr =  inet_addr("192.168.1.10");



	err = tcp_bind(pcb,  (ip_addr_t *)&local_ip, port);
	if (err != ERR_OK) {
		xil_printf("Unable to bind to port %d: err = %d\n\r", port, err);
		return -2;
	}

	/* we do not need any arguments to callback functions */
	tcp_arg(pcb, NULL);

	if(tcp_connect(pcb, (ip_addr_t*)&server_ip,port,connected_callback) != ERR_OK){
		xil_printf("Error in connection");
		return -1;
	}




}

 connected_callback code

 

err_t connected_callback(void *arg, struct tcp_pcb *tpcb, err_t err){
	char* msg = "Get Data";
	xil_printf("Connection Established");

	tcp_recv(tpcb, recv_callback);


    if(tcp_write(tpcb,msg,sizeof(msg),1) != ERR_OK){
    	xil_printf("Error in Sending Data to Server");
    }

    if(tcp_output(tpcb) != ERR_OK){
    	xil_printf("Error in Sending Data to Server");
    }

    return ERR_OK;
}

  

Now the usual handshake to setup TCP should be as follows

 

CLIENT                          SERVER

 

SYN   -------------------> 

           <------------------  SYN/ACK

ACK  --------------------> 

 

But I receive an additional RST/ACK packet from the remote server which probably closes the connection.

 -------------------------------------------

|          <------------------  RST/ACK  |

---------------------------------------------

 

Shown below is the snapshot captured from wireshark. 

 

Server IP = 192.168.1.100

LWIP Client IP = 192.168.1.10

 

WiresharkRST_ACK.JPG

 

Could any of you suggest if I may have faltered in some settings ? Or anything else that could have possibly gone wrong ?

 

PS: I have tested the same server for a PC socket client  transfer and it is responding as expected without sending any RST/ACK packets. Also attaching my complete source file running on ZC702

 

Thank you

Tags (4)
0 Kudos
Reply
0 Replies