Re: [lwip-users] tcp_write fails: package generation doesn't work properly

2014-06-11 Thread Sergio R. Caprile
Well, I don't see how you call those functions on your client, but you
know you have to wait to be connected before you send data, do you ? The
callback in tcp_connect() will be called when that happens.
Also, you are supposed to check for the available room  before calling
tcp_write(), and/or check its returned value to confirm data has been sent.
Have you run any other (supposed to work) example on your client before
trying this your own code ?
Assuming the port is working and you are calling lwip functions from
only one thread, have a look at the examples in the contrib area, smtp.c
is a master piece of an example for a client. Also, the wiki is not bad
at all.


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


[lwip-users] tcp_write fails: package generation doesn't work properly

2014-06-10 Thread Friedrico

Hello,

I have the following setup:
Server (Lwip 1.4.1 in a VM)
Client (also 1.4.1 on an Infineon Triboard using Erika Enterprise os)

The client code looks similar to this:

struct tcp_pcb *tcpPcb;
static const char data[] = ... /*100 bytes*/

static err_t tcpReceive(void *arg, struct tcp_pcb *pcb, struct pbuf *p,
err_t err) {
return ERR_OK;
}
static err_t tcpSent(void *arg, struct tcp_pcb *tpcb, u16_t len) {
return ERR_OK;
}


void initTcp(){
data=/*...*/
ip_addr_t *target, *local;
tcpPcb = tcp_new();
tcp_sent(tcpPcb, tcpSent);
tcp_recv(tcpPcb, tcpReceive);
tcp_arg(tcpPcb, data);
tcp_nagle_disable(tcpPcb);
tcp_bind(tcpPcb, local, C_PORT);
tcp_connect(tcpPcb, target, S_PORT, NULL);
}

void sendData(void *data) {
tcp_write(tcpPcb, data, 100, 0);
}




The server code uses the socket api:

struct sockaddr_in client_addr;
int addrlen=sizeof(client_addr);
int lSocket,nbytes,clientfd;

lSocket = socket(PF_INET, SOCK_STREAM, 0);
memset(sa, 0, sizeof(struct sockaddr_in));
sa.sin_family = AF_INET;
sa.sin_addr.s_addr = INADDR_ANY;
sa.sin_port = htons(PORT);

bind(lSocket, (struct sockaddr *)sa, sizeof(sa))
listen(lSocket,5);
addr_size = sizeof(isa);
while(1){
clientfd = accept(lSocket, (struct sockaddr*)client_addr,
(socklen_t)addrlen);
while (1){
nbytes=recv(clientfd, data, datalen,0);
if (nbytes0){
send(clientfd, data, datalen, 0);
}
}
close(clientfd);
}
close(lSocket); 


lwipopts.h (client):

#define MEMP_NUM_TCP_PCB13
#define MEMP_NUM_TCP_PCB_LISTEN 6
#define MEMP_NUM_TCP_SEG  200
#define MEMP_NUM_SYS_TIMEOUT6
#define PBUF_POOL_SIZE  11
#define PBUF_POOL_BUFSIZE   1536
#define LWIP_TCP1
#define TCP_TTL 255
#define TCPIP_THREAD_STACKSIZE  LWIP_STK_SIZE
#define TCP_QUEUE_OOSEQ 0
#define TCPIP_MBOX_SIZE MAX_QUEUE_ENTRIES //==20
#define DEFAULT_TCP_RECVMBOX_SIZE   MAX_QUEUE_ENTRIES
#define DEFAULT_ACCEPTMBOX_SIZE MAX_QUEUE_ENTRIES
#define TCP_MSS (1500 - 40)  /* TCP_MSS = 
(Ethernet MTU - IP header size - TCP header size) */

#define TCP_SND_BUF (4*TCP_MSS)
#define TCP_SND_QUEUELEN(6 * TCP_SND_BUF)/TCP_MSS
#define TCP_WND (2*TCP_MSS)



I attached the pcapng wireshark gathered.
No 12. shows the transmission of a test packet from server to client 
which works as intended.
No 16. should show the transmission back to the server which fails as 
one can see.
Even the payload is wrong (6 times 0) - it should be 100 bytes in length 
and contain the teststring, shouldn't it?


Can someone tell me where to search for the problem's cause?

Regards,
Friedrico



board.pcapng
Description: Binary data
___
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users