Problem receiving large packets

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem receiving large packets

feroz-2
Hello,

Im having problems receiving properly large packets.
I'm trying to a receive file using lwip. this is my callback function:

err_t serv_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
    err_t ret_code = ERR_OK;
    unsigned char *c = p->payload;
    unsigned int cnt=0;
    int ret;

   if(ERR_OK == err)
    {
        if(p != NULL)
        {
            for(cnt=0;cnt<p->tot_len;cnt++)
                xil_printf("%c", *(c+cnt));
            print("\n\r");    

                if(*c == 'q' && *(c+1) == 'u' && *(c+2) == 'i' && *(c+3)
== 't' && p->tot_len == 4)
                {
                    serv_close(pcb);
                }
            tcp_recved(pcb, p->tot_len);
            pbuf_free(p);

            ret=tcp_write(pcb, "a", 1, 1);
            tcp_sent(pcb, NULL);
        }
        else if(p == NULL)
        {
            serv_close(pcb);
        }
    }
    else
    {
        ret_code = err;
    }
    return ret_code;
}

On the other side, as client  i use a small script that is sending
string for now.

my $port = 7;
my $server = "193.51.45.84";

socket(SH, PF_INET, SOCK_STREAM, getprotobyname('tcp')) || print
"socket() failed: $!\n";

my $sin = sockaddr_in ($port,inet_aton($server));
print "Connecting...\n";
connect(SH,$sin) || die "connect() failed: $!\n";
syswrite(SH, "hello", 5);
sysread(SH, $line, 1);
my $a = 'a' x 600;
syswrite(SH, $a, length($a));
sysread(SH, $line, 1); << Never get a char back when the string i send
is larger than 600 chars

My problem is that as long as i send a string shorter than 600 chars
everything seems to be ok, but when sending larger strings, i dont get
the "a" char i send after receiving something. So the program waits for
that on the last sysread on the client side.
Is there anything i have done wrong?

Regards,
Feroz.



_______________________________________________
lwip-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem receiving large packets

Christiaan Simons

Feroz wrote:

> My problem is that as long as i send a string shorter than 600 chars
> everything seems to be ok, but when sending larger strings, i dont get
> the "a" char i send after receiving something. So the program waits for
> that on the last sysread on the client side.
> Is there anything i have done wrong?

I guess you should traverse the whole pbuf-chain
(a linked list) to obtain all payload bytes.

Does 600 chars equals the PBUF_POOL_BUFSIZE setting in lwipopts.h?

BTW

I've found some problems with the IP reassembly and fragmentation code.
You might encounter problems with ICMP or UDP payloads larger than
your MTU (1500 bytes for Ethernet).

I'm working on this issue.

As long as you stick with TCP everything should go just fine.
I can read / write a few megs over TCP without problems.

Christiaan Simons

Hardware / Software Engineer
Axon Digital Design

http://www.axon.tv

This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the system manager.
This message contains confidential information and is intended only for the
individual named.  If you are not the named addressee you should not
disseminate, distribute or copy this e-mail.



_______________________________________________
lwip-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem receiving large packets

feroz-2
In reply to this post by feroz-2
Hello,

Christiaan, PBUF_POOL_BUFSIZE is equal to 1500 in my lwipopts.h.
I think i expressed my problem wrong, actually, when sendding a packet
larger than 600bytes, the fpga receives it fully, but the one character
it's supposed to send back after each receive seems to be "ignored" or
not seen at all by the pc. So the script on my pc is waiting forever for
that char to arrive.


_______________________________________________
lwip-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Re: Problem receiving large packets

Christiaan Simons






lwip-users-bounces+christiaan.simons=[hidden email] wrote on 07-02-2006
18:41:29:

> Christiaan, PBUF_POOL_BUFSIZE is equal to 1500 in my lwipopts.h.

That is clearly not your problem then.

> I think i expressed my problem wrong, actually, when sendding a packet
> larger than 600bytes, the fpga receives it fully, but the one character
> it's supposed to send back after each receive seems to be "ignored" or
> not seen at all by the pc. So the script on my pc is waiting forever for
> that char to arrive.

Ah, are you sure your lwip server actually outputs the packet on the
network. Can you observe it with a sniffer program?

If not you can try to set the LWIP_DEBUG predefine in your Makefile,
and select the debugging options in lwipopts.h. Then you can see
where things might get lost in your stack.

Maybe some IP configuration is incomplete.

Christiaan Simons

Hardware / Software Engineer
Axon Digital Design

http://www.axon.tv

This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the system manager.
This message contains confidential information and is intended only for the
individual named.  If you are not the named addressee you should not
disseminate, distribute or copy this e-mail.



_______________________________________________
lwip-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Can't send the data by Raw API

陳 小擁
Hi all :
    i am using the Raw API to transmit data between ARM and PC . after all the initialization , i use tcp_wrtie() to send the data to PC . however , first data can be sent , and the follow data can't be sent . can someone tell me how to solve this problem ? THX

_______________________________________
YM - 離線訊息
就算你沒有上網,你的朋友仍可以留下訊息給你,當你上網時就能立即看到,任何說話都冇走失。
http://messenger.yahoo.com.hk
_______________________________________________
lwip-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply | Threaded
Open this post in threaded view
|

Re: Can't send the data by Raw API

Sathya Thammanur
You will need to keep checking the tcp send buffer for the amount of space left in the buffer before you call tcp_write. Keep calling a function that checks the tcp snd buf for space available and send accordingly.

hope this helps

Sathya


On 2/12/06, 陳 小擁 <[hidden email]> wrote:
Hi all :
    i am using the Raw API to transmit data between ARM and PC . after all the initialization , i use tcp_wrtie() to send the data to PC . however , first data can be sent , and the follow data can't be sent . can someone tell me how to solve this problem ? THX

_______________________________________
YM - 離線訊息
就算你沒有上網,你的朋友仍可以留下訊息給你,當你上網時就能立即看到,任何說話都冇走失。
<a href="http://messenger.yahoo.com.hk" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> http://messenger.yahoo.com.hk


_______________________________________________
lwip-users mailing list
[hidden email]
<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://lists.nongnu.org/mailman/listinfo/lwip-users" target="_blank"> http://lists.nongnu.org/mailman/listinfo/lwip-users



_______________________________________________
lwip-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Re: Can't send the data by Raw API

陳 小擁
Hi Sathya:
    thanks for your help. however, how can i check the tcp send buffer? which function can i use ? or i have to write it by myself ? someone have told me that if i want to use tcp_write , i have use tcp_output follow it .
>     temp_pcb = tcp_active_pcbs ;
>    err = tcp_write(temp_pcb , &abc[j] , sizeof(abc[j]),0) ;
>    tcp_output(temp_pcb) ;
is it right? thanks again !

 
You will need to keep checking the tcp send buffer for the amount of space left in the buffer before you call tcp_write. Keep calling a function that checks the tcp snd buf for space available and send accordingly.

hope this helps

Sathya

_______________________________________
YM - 離線訊息
就算你沒有上網,你的朋友仍可以留下訊息給你,當你上網時就能立即看到,任何說話都冇走失。
http://messenger.yahoo.com.hk
_______________________________________________
lwip-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Can't send the data by Raw API

Sathya Thammanur
Take a look at the doc/rawapi.txt document in the lwip installation area. This has all the functions that you would need for writing TCP and UDP applications.
Here is a snippet of a function that sends data.

  err_t err = ERR_OK;
  u16_t len;

  /* We cannot send more data than space available in the send
     buffer. */    
  if (tcp_sndbuf(pcb) < ps->left) {
    len = tcp_sndbuf(pcb);
  } else {
    len = ps->left;
  }

  if (len > 0) {
    err = tcp_write(pcb, ps->buf_p, len, 1);
  }

Sathya

On 2/14/06, 陳 小擁 <[hidden email]> wrote:
Hi Sathya:
    thanks for your help. however, how can i check the tcp send buffer? which function can i use ? or i have to write it by myself ? someone have told me that if i want to use tcp_write , i have use tcp_output follow it .
>     temp_pcb = tcp_active_pcbs ;
>    err = tcp_write(temp_pcb , &abc[j] , sizeof(abc[j]),0) ;
>    tcp_output(temp_pcb) ;
is it right? thanks again !

 
You will need to keep checking the tcp send buffer for the amount of space left in the buffer before you call tcp_write. Keep calling a function that checks the tcp snd buf for space available and send accordingly.

hope this helps

Sathya

_______________________________________
YM - 離線訊息
就算你沒有上網,你的朋友仍可以留下訊息給你,當你上網時就能立即看到,任何說話都冇走失。
<a href="http://messenger.yahoo.com.hk" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://messenger.yahoo.com.hk


_______________________________________________
lwip-users mailing list
[hidden email]
<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://lists.nongnu.org/mailman/listinfo/lwip-users" target="_blank"> http://lists.nongnu.org/mailman/listinfo/lwip-users



_______________________________________________
lwip-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Can't send the data by Raw API

陳 小擁
Thanks for your help, i will try it again . [hidden email] is my MSN , hope to make friend with you .
 
 
Sathya Thammanur <[hidden email]> 說:
Take a look at the doc/rawapi.txt document in the lwip installation area. This has all the functions that you would need for writing TCP and UDP applications.
Here is a snippet of a function that sends data.

  err_t err = ERR_OK;
  u16_t len;

  /* We cannot send more data than space available in the send
     buffer. */    
  if (tcp_sndbuf(pcb) < ps->left) {
    len = tcp_sndbuf(pcb);
  } else {
    len = ps->left;
  }

  if (len > 0) {
    err = tcp_write(pcb, ps->buf_p, len, 1);
  }

Sathya

 

_______________________________________
YM - 離線訊息
就算你沒有上網,你的朋友仍可以留下訊息給你,當你上網時就能立即看到,任何說話都冇走失。
http://messenger.yahoo.com.hk
_______________________________________________
lwip-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-users