|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
TCP MSSHi,
I've implemented a wget like function to a sam7x. It will download a file from a webserver, and store in in dataflash. On ethernet link, I read the remote file in 256 byte chunks, and everything is works fine. But I have a problem on doing the same on a GPRS link. I tried to read the file by 256, 128 or 64 byte chunks, but after 2 256 byte read the fread only read 24 byte. The same is true for 128 or 64 byte chunk, so I always read 536 byte, which is default TCP_MAXSEG. so I read: 256 256 24 256 256 24 and so on. I tried to increase TCP MSS, but it didn't helped. Is there a solution to achive the same function on GPRS just like on ethernet? Or what I missed? Thanks, Andras _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
|
|
Re: TCP MSSHi Andras,
> But I have a problem on doing the same on a GPRS link. I tried to read > the file by 256, 128 or 64 byte chunks, > but after 2 256 byte read the fread only read 24 byte. The same is > true for 128 or 64 byte chunk, so I always read > 536 byte, which is default TCP_MAXSEG. I don't know if I understand your problem correctly. But let me try to explain... The GPRS modem is connected by a serial line, right? Caused by buffersizes etc. the fread from a serial line is not garanteed to always return the same number of bytes you asked for... So fread(buffer, 1, 256, stream); will not necessarily return 256 bytes. That's independent on the device you read from and depends on the driver internal buffering and / or the transport media the dataflow is read from. IP packages might be larger then 256 bytes, so on an ethernte cable, where the MTU is set to approximately 1500 bytes you may always receive full IP packages of 256 in just on fread. But on another transport medium like GPRS you might perhaps just read two times 256 bytes, next 24 as this is what your driver is giving you at the moment. Eventually even the packet size of grps is somewhat more limited, but this is far beyond my knowledge.. If you always want to read 256 bytes try a construct like this: uchar buffer[256]; int offset; int size; offset = size = 0; do { size = fread(&buffer[offset], 1, 256-offset, stream); offset += size; } while (size > 0) && (offset < 256); Bye, Ole -- _____________________________________________________________ | | | Embedded-IT | | | | Ole Reinhardt Tel. / Fax: +49 (0)271 7420433 | | Luisenstraße 29 Mobil: +49 (0)177 7420433 | | 57076 Siegen eMail: ole.reinhardt@... | | Germany Web: http://www.embedded-it.de | |_____________________________________________________________| _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
|
|
Re: TCP MSSOle,
Thanks for the fast reply and help, i will rewrite my code and try this way. Regards, Andras On Sep 30, 2009, at 11:53 AM, Ole Reinhardt wrote: > Hi Andras, > >> But I have a problem on doing the same on a GPRS link. I tried to >> read >> the file by 256, 128 or 64 byte chunks, >> but after 2 256 byte read the fread only read 24 byte. The same is >> true for 128 or 64 byte chunk, so I always read >> 536 byte, which is default TCP_MAXSEG. > > I don't know if I understand your problem correctly. But let me try to > explain... The GPRS modem is connected by a serial line, right? Caused > by buffersizes etc. the fread from a serial line is not garanteed to > always return the same number of bytes you asked for... > > So fread(buffer, 1, 256, stream); will not necessarily return 256 > bytes. > That's independent on the device you read from and depends on the > driver > internal buffering and / or the transport media the dataflow is read > from. IP packages might be larger then 256 bytes, so on an ethernte > cable, where the MTU is set to approximately 1500 bytes you may always > receive full IP packages of 256 in just on fread. But on another > transport medium like GPRS you might perhaps just read two times 256 > bytes, next 24 as this is what your driver is giving you at the > moment. > Eventually even the packet size of grps is somewhat more limited, but > this is far beyond my knowledge.. > > If you always want to read 256 bytes try a construct like this: > > uchar buffer[256]; > int offset; > int size; > > offset = size = 0; > > do { > size = fread(&buffer[offset], 1, 256-offset, stream); > offset += size; > } while (size > 0) && (offset < 256); > > Bye, > > Ole > > > -- > _____________________________________________________________ > | | > | Embedded-IT | > | | > | Ole Reinhardt Tel. / Fax: +49 (0)271 7420433 | > | Luisenstraße 29 Mobil: +49 (0)177 7420433 | > | 57076 Siegen eMail: ole.reinhardt@... | > | Germany Web: http://www.embedded-it.de | > |_____________________________________________________________| > > _______________________________________________ > http://lists.egnite.de/mailman/listinfo/en-nut-discussion _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
| Free embeddable forum powered by Nabble | Forum Help |