From: "Øyvind Harboe" <oyvind.harboe@zylin.com>
To: "eCos Disuss" <ecos-discuss@ecos.sourceware.org>
Subject: [ECOS] Improving TFTP performance
Date: Wed, 19 Dec 2007 12:41:00 -0000 [thread overview]
Message-ID: <c09652430712190104v180581bck61f9cdaf852f249e@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 392 bytes --]
Has anyone done any work in improving TFTP get performance?
Block size is currently set to 512 whereas TFTP RFC 248 allows for
negotiating block size...
http://www.faqs.org/rfcs/rfc2348.html
Attached is some work in progress. It doesn't work, but including it
in case anyone
is interested in this.
--
Øyvind Harboe
http://www.zylin.com - eCos ARM & FPGA developer kit
[-- Attachment #2: tftpfaster.txt --]
[-- Type: text/plain, Size: 4234 bytes --]
### Eclipse Workspace Patch 1.0
#P ecos
Index: net/common/current/cdl/net.cdl
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/common/current/cdl/net.cdl,v
retrieving revision 1.17
diff -u -r1.17 net.cdl
--- net/common/current/cdl/net.cdl 7 Jan 2007 14:46:55 -0000 1.17
+++ net/common/current/cdl/net.cdl 19 Dec 2007 09:04:00 -0000
@@ -167,6 +167,16 @@
threads can have precedence over TFTP server processing."
}
+ cdl_option CYGPKG_NET_TFTPD_CLIENT_GET_PACKETSIZE {
+ display "Pervert TFTP protocol to allow bigger packets."
+ flavor data
+ default_value 512
+ legal_values 512 to 65464
+ description "
+ Some TFTP servers pragmatically allow increasing the
+ packet size, contrary to the TFTP standard. Use with caution!"
+ }
+
cdl_option CYGPKG_NET_TFTPD_THREAD_STACK_SIZE {
display "Stack size for TFTP threads."
flavor data
Index: net/common/current/src/tftp_client.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/common/current/src/tftp_client.c,v
retrieving revision 1.10
diff -u -r1.10 tftp_client.c
--- net/common/current/src/tftp_client.c 16 Sep 2005 14:56:26 -0000 1.10
+++ net/common/current/src/tftp_client.c 19 Dec 2007 09:04:01 -0000
@@ -57,6 +57,7 @@
#include <network.h>
#include <arpa/tftp.h>
#include <tftp_support.h>
+#include <stdlib.h>
#define min(x,y) (x<y ? x : y)
@@ -66,7 +67,8 @@
// On error, *err will hold the reason.
// This version uses the server name. This can be a name for DNS lookup
// or a dotty or colony number format for IPv4 or IPv6.
-int tftp_client_get(const char * const filename,
+static int tftp_client_get_inner(char *data,
+ const char * const filename,
const char * const server,
const int port,
char *buf,
@@ -85,7 +87,6 @@
int error;
struct sockaddr local_addr, from_addr;
- char data[SEGSIZE+sizeof(struct tftphdr)];
struct tftphdr *hdr = (struct tftphdr *)data;
const char *fp;
char *cp, *bp;
@@ -214,9 +215,9 @@
}
}
} else {
- recv_len = sizeof(data);
+ recv_len = CYGPKG_NET_TFTPD_CLIENT_GET_PACKETSIZE;
from_len = sizeof(from_addr);
- if ((data_len = recvfrom(s, &data, recv_len, 0,
+ if ((data_len = recvfrom(s, data, recv_len, 0,
&from_addr, &from_len)) < 0) {
// What happened?
*err = TFTP_NETERR;
@@ -244,7 +245,7 @@
// To prevent an out-of-sequence packet from
// terminating transmission prematurely, set
// actual_len to a full size packet.
- actual_len = SEGSIZE;
+ actual_len = CYGPKG_NET_TFTPD_CLIENT_GET_PACKETSIZE;
}
// Send out the ACK
hdr->th_opcode = htons(ACK);
@@ -256,7 +257,7 @@
goto out;
}
// A short packet marks the end of the file.
- if ((actual_len >= 0) && (actual_len < SEGSIZE)) {
+ if ((actual_len >= 0) && (actual_len < CYGPKG_NET_TFTPD_CLIENT_GET_PACKETSIZE)) {
// End of data
close(s);
freeaddrinfo(res);
@@ -290,6 +291,35 @@
freeaddrinfo(res);
return -1;
}
+
+
+int tftp_client_get(const char * const filename,
+ const char * const server,
+ const int port,
+ char *buf,
+ int len,
+ const int mode,
+ int * const err) {
+ int result;
+#if CYGPKG_NET_TFTPD_CLIENT_GET_PACKETSIZE>512
+ char *data = malloc(CYGPKG_NET_TFTPD_CLIENT_GET_PACKETSIZE+sizeof(struct tftphdr));
+ if (data==NULL)
+ {
+ *err=TFTP_ENOSPACE;
+ return -1;
+ }
+#else
+ char data[SEGSIZE+sizeof(struct tftphdr)];
+#endif
+ result=tftp_client_get_inner(data, filename, server, port, buf, len, mode, err);
+
+#if CYGPKG_NET_TFTPD_CLIENT_GET_PACKETSIZE>512
+ free(data);
+#endif
+
+ return result;
+}
+
//
// Read a file from a host into a local buffer. Returns the
// number of bytes actually read, or (-1) if an error occurs.
[-- Attachment #3: Type: text/plain, Size: 148 bytes --]
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
next reply other threads:[~2007-12-19 9:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-19 12:41 Øyvind Harboe [this message]
2007-12-19 13:53 ` [ECOS] " Øyvind Harboe
2007-12-19 14:17 ` Andrew Lunn
2007-12-19 14:47 ` Øyvind Harboe
2007-12-19 15:11 ` Andrew Lunn
2007-12-19 15:34 ` Øyvind Harboe
2007-12-19 22:42 ` Andrew Lunn
2007-12-19 23:39 ` Gary Thomas
2007-12-19 23:52 ` Øyvind Harboe
2007-12-19 14:28 ` Sergei Gavrikov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c09652430712190104v180581bck61f9cdaf852f249e@mail.gmail.com \
--to=oyvind.harboe@zylin.com \
--cc=ecos-discuss@ecos.sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).