Added Hydra dynamic transmitbuffer adjust
This commit is contained in:
parent
fa012a111d
commit
9ece329bdc
@ -26,6 +26,8 @@ v0.39.1 22-Oct-2003
|
|||||||
Added hydra rpos id -1 indicator for compression stop that
|
Added hydra rpos id -1 indicator for compression stop that
|
||||||
Alex and I agreed to use.
|
Alex and I agreed to use.
|
||||||
Compression log fixed and added percentage compression.
|
Compression log fixed and added percentage compression.
|
||||||
|
Added dynamic optimum sendbuffer size with a maximum of 8192
|
||||||
|
bytes with an average size of 2048 bytes.
|
||||||
|
|
||||||
mbsetup:
|
mbsetup:
|
||||||
In node editor, fixed error message when there was no more
|
In node editor, fixed error message when there was no more
|
||||||
|
@ -343,7 +343,7 @@ enum HyPktTypes hyrxpkt(char *rxbuf, int *rxlen, int tot)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Syslog('h', "GETCHAR returned %i", c);
|
Syslog('h', "Hydra: GETCHAR returned %i", c);
|
||||||
|
|
||||||
if ((c == TERROR) || (c == EOFILE) || (c == HANGUP)) {
|
if ((c == TERROR) || (c == EOFILE) || (c == HANGUP)) {
|
||||||
return H_CARRIER;
|
return H_CARRIER;
|
||||||
@ -362,7 +362,7 @@ void hytxpkt(enum HyPktTypes pkttype, char *txbuf, int txlen)
|
|||||||
enum HyPktFormats format;
|
enum HyPktFormats format;
|
||||||
|
|
||||||
if (pkttype == HPKT_DATAACK)
|
if (pkttype == HPKT_DATAACK)
|
||||||
Syslog('h', "ACK 0x%02x%02x%02x%02x", txbuf[0], txbuf[1], txbuf[2], txbuf[3]);
|
Syslog('h', "Hydra: ACK 0x%02x%02x%02x%02x", txbuf[0], txbuf[1], txbuf[2], txbuf[3]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* some packets have to be transferred in HEX mode
|
* some packets have to be transferred in HEX mode
|
||||||
@ -530,13 +530,11 @@ int resync(off_t off)
|
|||||||
int hydra_batch(int role, file_list *to_send)
|
int hydra_batch(int role, file_list *to_send)
|
||||||
{
|
{
|
||||||
static char txbuf[H_ZIPBUFLEN], rxbuf[H_ZIPBUFLEN];
|
static char txbuf[H_ZIPBUFLEN], rxbuf[H_ZIPBUFLEN];
|
||||||
static char txzbuf[H_ZIPBUFLEN], rxzbuf[H_ZIPBUFLEN];
|
|
||||||
struct stat txstat; /* file stat being transmitted */
|
struct stat txstat; /* file stat being transmitted */
|
||||||
FILE *txfp = NULL; /* file currently being transmitted */
|
FILE *txfp = NULL; /* file currently being transmitted */
|
||||||
FILE *rxfp = NULL; /* file currently being received */
|
FILE *rxfp = NULL; /* file currently being received */
|
||||||
char *inbuf, *outbuf;
|
char *inbuf, *outbuf;
|
||||||
int rxlen, txlen; /* length of receive/transmit buffer */
|
int rxlen, txlen; /* length of receive/transmit buffer */
|
||||||
unsigned long rxzlen, txzlen; /* length of receive/transmit compressed buffer */
|
|
||||||
long txwindow, rxwindow; /* window sizes */
|
long txwindow, rxwindow; /* window sizes */
|
||||||
long txpos;
|
long txpos;
|
||||||
off_t rxpos; /* file positions */
|
off_t rxpos; /* file positions */
|
||||||
@ -560,7 +558,12 @@ int hydra_batch(int role, file_list *to_send)
|
|||||||
struct timeval rxstarttime, rxendtime;
|
struct timeval rxstarttime, rxendtime;
|
||||||
struct timezone tz;
|
struct timezone tz;
|
||||||
int sverr;
|
int sverr;
|
||||||
int rcz, txcompressed, rxctries;
|
int txcompressed, rxctries;
|
||||||
|
#ifdef HAVE_ZLIB_H
|
||||||
|
static char txzbuf[H_ZIPBUFLEN], rxzbuf[H_ZIPBUFLEN];
|
||||||
|
unsigned long rxzlen, txzlen; /* length of receive/transmit compressed buffer */
|
||||||
|
int rcz, cmpblksize;
|
||||||
|
#endif
|
||||||
|
|
||||||
Syslog('h', "Hydra: resettimers");
|
Syslog('h', "Hydra: resettimers");
|
||||||
RESETTIMERS();
|
RESETTIMERS();
|
||||||
@ -573,6 +576,7 @@ int hydra_batch(int role, file_list *to_send)
|
|||||||
rxlastsync = rxsyncid = 0;
|
rxlastsync = rxsyncid = 0;
|
||||||
rxlastdatalen = 0;
|
rxlastdatalen = 0;
|
||||||
blksize = 512;
|
blksize = 512;
|
||||||
|
cmpblksize = H_UNCBLKLEN;
|
||||||
goodbytes = 0;
|
goodbytes = 0;
|
||||||
goodneeded = 1024;
|
goodneeded = 1024;
|
||||||
Syslog('h', "Hydra: set BRAIN timer %d", H_BRAINDEAD);
|
Syslog('h', "Hydra: set BRAIN timer %d", H_BRAINDEAD);
|
||||||
@ -624,8 +628,13 @@ int hydra_batch(int role, file_list *to_send)
|
|||||||
pkttype = hyrxpkt(rxbuf, &rxlen, -1);
|
pkttype = hyrxpkt(rxbuf, &rxlen, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pkttype == H_CARRIER) || (EXPIRED(TIMERNO_BRAIN))) {
|
if (EXPIRED(TIMERNO_BRAIN)) {
|
||||||
Syslog('h', "Hydra: BRAIN timer expired");
|
Syslog('+', "Hydra: BRAIN timer expired");
|
||||||
|
txstate = HTX_Abort;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (pkttype == H_CARRIER) {
|
||||||
|
Syslog('+', "Hydra: lost CARRIER");
|
||||||
txstate = HTX_Abort;
|
txstate = HTX_Abort;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -650,6 +659,12 @@ int hydra_batch(int role, file_list *to_send)
|
|||||||
if ((rpos_id == -1) && (compstate != HCMP_NONE)) {
|
if ((rpos_id == -1) && (compstate != HCMP_NONE)) {
|
||||||
Syslog('+', "Hydra: remote asked stop compression");
|
Syslog('+', "Hydra: remote asked stop compression");
|
||||||
compstate = HCMP_NONE;
|
compstate = HCMP_NONE;
|
||||||
|
/*
|
||||||
|
* Adjust blocksize for normal uncompressed transfers
|
||||||
|
*/
|
||||||
|
if (blksize > H_UNCBLKLEN) {
|
||||||
|
blksize = H_UNCBLKLEN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -663,7 +678,7 @@ int hydra_batch(int role, file_list *to_send)
|
|||||||
txpos = -2;
|
txpos = -2;
|
||||||
txstate = HTX_EOF;
|
txstate = HTX_EOF;
|
||||||
} else {
|
} else {
|
||||||
Syslog('h', "Hydra: set BRAIN timer", H_BRAINDEAD);
|
Syslog('h', "Hydra: set BRAIN timer %d", H_BRAINDEAD);
|
||||||
SETTIMER(TIMERNO_BRAIN, H_BRAINDEAD);
|
SETTIMER(TIMERNO_BRAIN, H_BRAINDEAD);
|
||||||
txstate = HTX_SkipFile;
|
txstate = HTX_SkipFile;
|
||||||
}
|
}
|
||||||
@ -695,7 +710,7 @@ int hydra_batch(int role, file_list *to_send)
|
|||||||
if (txstate == HTX_EOFACK)
|
if (txstate == HTX_EOFACK)
|
||||||
txstate = HTX_DATA;
|
txstate = HTX_DATA;
|
||||||
|
|
||||||
Syslog('h', "Hydra: set BRAIN timer", H_BRAINDEAD);
|
Syslog('h', "Hydra: set BRAIN timer %d", H_BRAINDEAD);
|
||||||
SETTIMER(TIMERNO_BRAIN, H_BRAINDEAD);
|
SETTIMER(TIMERNO_BRAIN, H_BRAINDEAD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -934,7 +949,7 @@ int hydra_batch(int role, file_list *to_send)
|
|||||||
Syslog('h', "SM 'HTX' entering 'FINFOACK'");
|
Syslog('h', "SM 'HTX' entering 'FINFOACK'");
|
||||||
if ((pkttype == HPKT_FINFOACK) && (rxlen == 4)) {
|
if ((pkttype == HPKT_FINFOACK) && (rxlen == 4)) {
|
||||||
txpos = get_long(rxbuf);
|
txpos = get_long(rxbuf);
|
||||||
Syslog('h', "Hydra: set BRAIN timer", H_BRAINDEAD);
|
Syslog('h', "Hydra: set BRAIN timer %d", H_BRAINDEAD);
|
||||||
SETTIMER(TIMERNO_BRAIN, H_BRAINDEAD);
|
SETTIMER(TIMERNO_BRAIN, H_BRAINDEAD);
|
||||||
|
|
||||||
if (to_send == NULL) {
|
if (to_send == NULL) {
|
||||||
@ -996,7 +1011,7 @@ int hydra_batch(int role, file_list *to_send)
|
|||||||
Syslog('h', "Hydra: set TX timer %d", H_MINTIMER/2);
|
Syslog('h', "Hydra: set TX timer %d", H_MINTIMER/2);
|
||||||
SETTIMER(TIMERNO_TX, H_MINTIMER/2);
|
SETTIMER(TIMERNO_TX, H_MINTIMER/2);
|
||||||
} else {
|
} else {
|
||||||
Syslog('H', "HYDRA: SET TX TIMER %D", H_MINTIMER);
|
Syslog('h', "Hydra: set TX timer %d", H_MINTIMER);
|
||||||
SETTIMER(TIMERNO_TX, H_MINTIMER);
|
SETTIMER(TIMERNO_TX, H_MINTIMER);
|
||||||
}
|
}
|
||||||
txstate = HTX_DATAACK;
|
txstate = HTX_DATAACK;
|
||||||
@ -1023,6 +1038,8 @@ int hydra_batch(int role, file_list *to_send)
|
|||||||
txstate = HTX_EOF;
|
txstate = HTX_EOF;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Syslog('h', "Hydra: set BRAIN timer %d", H_BRAINDEAD); // 03-11-2003 MB.
|
||||||
|
SETTIMER(TIMERNO_BRAIN, H_BRAINDEAD); // 03-11-2003 MB.
|
||||||
#ifdef HAVE_ZLIB_H
|
#ifdef HAVE_ZLIB_H
|
||||||
if (compstate == HCMP_GZ) {
|
if (compstate == HCMP_GZ) {
|
||||||
txzlen = H_ZIPBUFLEN - 4;
|
txzlen = H_ZIPBUFLEN - 4;
|
||||||
@ -1038,6 +1055,18 @@ int hydra_batch(int role, file_list *to_send)
|
|||||||
goodbytes += txlen;
|
goodbytes += txlen;
|
||||||
txzlen += 4;
|
txzlen += 4;
|
||||||
hytxpkt(HPKT_ZIPDATA, txzbuf, txzlen);
|
hytxpkt(HPKT_ZIPDATA, txzbuf, txzlen);
|
||||||
|
/*
|
||||||
|
* Calculate the perfect blocksize for the next block
|
||||||
|
* using the current compression ratio. This gives
|
||||||
|
* a dynamic optimal blocksize. The average maximum
|
||||||
|
* blocksize on the line will be 2048 bytes.
|
||||||
|
*/
|
||||||
|
cmpblksize = ((txlen * 4) / txzlen) * 512;
|
||||||
|
if (cmpblksize < H_UNCBLKLEN)
|
||||||
|
cmpblksize = H_UNCBLKLEN;
|
||||||
|
if (cmpblksize > H_MAXBLKLEN)
|
||||||
|
cmpblksize = H_MAXBLKLEN;
|
||||||
|
Syslog('h', "Hydra: adjusting next blocksize to %d bytes", cmpblksize);
|
||||||
} else {
|
} else {
|
||||||
txpos += txlen;
|
txpos += txlen;
|
||||||
sentbytes += txlen;
|
sentbytes += txlen;
|
||||||
@ -1066,20 +1095,31 @@ int hydra_batch(int role, file_list *to_send)
|
|||||||
txlen += 4;
|
txlen += 4;
|
||||||
hytxpkt(HPKT_DATA, txbuf, txlen);
|
hytxpkt(HPKT_DATA, txbuf, txlen);
|
||||||
}
|
}
|
||||||
|
if (goodbytes > goodneeded) {
|
||||||
|
blksize *= 2;
|
||||||
|
if (compstate != HCMP_NONE) {
|
||||||
|
if (blksize > cmpblksize) {
|
||||||
|
blksize = cmpblksize;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (blksize > H_UNCBLKLEN) {
|
||||||
|
blksize = H_UNCBLKLEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
txpos += txlen;
|
txpos += txlen;
|
||||||
sentbytes += txlen;
|
sentbytes += txlen;
|
||||||
goodbytes += txlen;
|
goodbytes += txlen;
|
||||||
txlen += 4;
|
txlen += 4;
|
||||||
hytxpkt(HPKT_DATA, txbuf, txlen);
|
hytxpkt(HPKT_DATA, txbuf, txlen);
|
||||||
#endif
|
|
||||||
// FIXME: here to decide in PLZ mode to use larger blocks.
|
|
||||||
if (goodbytes > goodneeded) {
|
if (goodbytes > goodneeded) {
|
||||||
blksize *= 2;
|
blksize *= 2;
|
||||||
if (blksize > H_UNCBLKLEN) {
|
if (blksize > H_UNCBLKLEN) {
|
||||||
blksize = H_UNCBLKLEN;
|
blksize = H_UNCBLKLEN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1180,7 +1220,7 @@ int hydra_batch(int role, file_list *to_send)
|
|||||||
case HTX_EOFACK:
|
case HTX_EOFACK:
|
||||||
Syslog('h', "SM 'HTX' entering 'EOFACK'");
|
Syslog('h', "SM 'HTX' entering 'EOFACK'");
|
||||||
if ((pkttype == HPKT_EOFACK) && (rxlen == 0)) {
|
if ((pkttype == HPKT_EOFACK) && (rxlen == 0)) {
|
||||||
Syslog('h', "Hydra: set BRAIN timer", H_BRAINDEAD);
|
Syslog('h', "Hydra: set BRAIN timer %d", H_BRAINDEAD);
|
||||||
SETTIMER(TIMERNO_BRAIN, H_BRAINDEAD);
|
SETTIMER(TIMERNO_BRAIN, H_BRAINDEAD);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1352,7 +1392,7 @@ int hydra_batch(int role, file_list *to_send)
|
|||||||
put_long(txbuf, 0);
|
put_long(txbuf, 0);
|
||||||
hytxpkt(HPKT_FINFOACK, txbuf, 4);
|
hytxpkt(HPKT_FINFOACK, txbuf, 4);
|
||||||
|
|
||||||
Syslog('h', "Hydra: set BRAIN timer", H_BRAINDEAD);
|
Syslog('h', "Hydra: set BRAIN timer %d", H_BRAINDEAD);
|
||||||
SETTIMER(TIMERNO_BRAIN, H_BRAINDEAD);
|
SETTIMER(TIMERNO_BRAIN, H_BRAINDEAD);
|
||||||
rxstate = HRX_DONE;
|
rxstate = HRX_DONE;
|
||||||
}
|
}
|
||||||
@ -1417,7 +1457,7 @@ int hydra_batch(int role, file_list *to_send)
|
|||||||
}
|
}
|
||||||
hytxpkt(HPKT_FINFOACK, txbuf, 4);
|
hytxpkt(HPKT_FINFOACK, txbuf, 4);
|
||||||
|
|
||||||
Syslog('h', "Hydra: set BRAIN timer", H_BRAINDEAD);
|
Syslog('h', "Hydra: set BRAIN timer %d", H_BRAINDEAD);
|
||||||
SETTIMER(TIMERNO_BRAIN, H_BRAINDEAD);
|
SETTIMER(TIMERNO_BRAIN, H_BRAINDEAD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1510,7 +1550,7 @@ int hydra_batch(int role, file_list *to_send)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (rxpos >= 0) {
|
if (rxpos >= 0) {
|
||||||
Syslog('+', "Hydra: received bad rxpos");
|
Syslog('+', "Hydra: received bad rxpos %d", rxpos);
|
||||||
}
|
}
|
||||||
rxstate = HRX_BadPos;
|
rxstate = HRX_BadPos;
|
||||||
}
|
}
|
||||||
@ -1574,7 +1614,7 @@ int hydra_batch(int role, file_list *to_send)
|
|||||||
|
|
||||||
pkttype = H_NOPKT; /* packet has already been processed */
|
pkttype = H_NOPKT; /* packet has already been processed */
|
||||||
} else if ((pkttype == HPKT_IDLE) && (rxlen == 0) && (hdxlink == FALSE)) {
|
} else if ((pkttype == HPKT_IDLE) && (rxlen == 0) && (hdxlink == FALSE)) {
|
||||||
Syslog('h', "Hydra: set BRAIN timer", H_BRAINDEAD);
|
Syslog('h', "Hydra: set BRAIN timer %d", H_BRAINDEAD);
|
||||||
SETTIMER(TIMERNO_BRAIN, H_BRAINDEAD);
|
SETTIMER(TIMERNO_BRAIN, H_BRAINDEAD);
|
||||||
|
|
||||||
pkttype = H_NOPKT; /* packet has already been processed */
|
pkttype = H_NOPKT; /* packet has already been processed */
|
||||||
@ -1675,7 +1715,7 @@ int hydra_batch(int role, file_list *to_send)
|
|||||||
|
|
||||||
pkttype = H_NOPKT; /* packet has already been processed */
|
pkttype = H_NOPKT; /* packet has already been processed */
|
||||||
} else if ((pkttype == HPKT_IDLE) && (rxlen == 0)) {
|
} else if ((pkttype == HPKT_IDLE) && (rxlen == 0)) {
|
||||||
Syslog('h', "Hydra: set BRAIN timer", H_BRAINDEAD);
|
Syslog('h', "Hydra: set BRAIN timer %d", H_BRAINDEAD);
|
||||||
SETTIMER(TIMERNO_BRAIN, H_BRAINDEAD);
|
SETTIMER(TIMERNO_BRAIN, H_BRAINDEAD);
|
||||||
|
|
||||||
pkttype = H_NOPKT; /* packet has already been processed */
|
pkttype = H_NOPKT; /* packet has already been processed */
|
||||||
|
@ -64,6 +64,17 @@ char *ttystat[]= {(char *)"Ok",
|
|||||||
(char *)"Hangup",
|
(char *)"Hangup",
|
||||||
(char *)"Empty"};
|
(char *)"Empty"};
|
||||||
|
|
||||||
|
int tty_resettimer(int tno);
|
||||||
|
void tty_resettimers(void);
|
||||||
|
int tty_settimer(int,int);
|
||||||
|
int tty_expired(int);
|
||||||
|
int tty_running(int);
|
||||||
|
|
||||||
|
#define RESETTIMER(x) tty_resettimer(x)
|
||||||
|
#define RESETTIMERS() tty_resettimers()
|
||||||
|
#define SETTIMER(x,y) tty_settimer(x,y)
|
||||||
|
#define EXPIRED(x) tty_expired(x)
|
||||||
|
#define RUNNING(x) tty_running(x)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -153,7 +164,6 @@ int tty_running(int tno)
|
|||||||
/*
|
/*
|
||||||
* private r/w functions
|
* private r/w functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int tty_read(char *buf, int size, int tot)
|
static int tty_read(char *buf, int size, int tot)
|
||||||
{
|
{
|
||||||
time_t timeout, now;
|
time_t timeout, now;
|
||||||
@ -168,7 +178,7 @@ static int tty_read(char *buf, int size, int tot)
|
|||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
timeout = (time_t)300; /* maximum of 5 minutes */
|
timeout = (time_t)300; /* maximum of 5 minutes */
|
||||||
|
|
||||||
for (i = 0; i < TIMERNO_TX; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
if (timer[i]) {
|
if (timer[i]) {
|
||||||
if (now >= timer[i]) {
|
if (now >= timer[i]) {
|
||||||
tty_status=STAT_TIMEOUT;
|
tty_status=STAT_TIMEOUT;
|
||||||
|
@ -3,12 +3,9 @@
|
|||||||
#ifndef TTYIO_H
|
#ifndef TTYIO_H
|
||||||
#define TTYIO_H
|
#define TTYIO_H
|
||||||
|
|
||||||
/*
|
#define TIMERNO_BRAIN 0 /* BRAIN timerno */
|
||||||
* Timer numbers for Hydra
|
#define TIMERNO_RX 1 /* Receiver timerno */
|
||||||
*/
|
#define TIMERNO_TX 2 /* Transmitter timerno */
|
||||||
#define TIMERNO_BRAIN 0
|
|
||||||
#define TIMERNO_RX 1
|
|
||||||
#define TIMERNO_TX 2
|
|
||||||
|
|
||||||
#define RESETTIMER(x) tty_resettimer(x)
|
#define RESETTIMER(x) tty_resettimer(x)
|
||||||
#define RESETTIMERS() tty_resettimers()
|
#define RESETTIMERS() tty_resettimers()
|
||||||
@ -164,6 +161,11 @@
|
|||||||
|
|
||||||
extern int tty_status;
|
extern int tty_status;
|
||||||
|
|
||||||
|
extern int tty_resettimer(int tno);
|
||||||
|
extern void tty_resettimers(void);
|
||||||
|
extern int tty_settimer(int,int);
|
||||||
|
extern int tty_expired(int);
|
||||||
|
extern int tty_running(int);
|
||||||
extern int tty_check(void);
|
extern int tty_check(void);
|
||||||
extern int tty_waitputget(int);
|
extern int tty_waitputget(int);
|
||||||
extern int tty_ungetc(int);
|
extern int tty_ungetc(int);
|
||||||
@ -176,10 +178,5 @@ extern int tty_putget(char**,int*,char**,int*);
|
|||||||
extern void tty_flushout(void);
|
extern void tty_flushout(void);
|
||||||
extern void tty_flushin(void);
|
extern void tty_flushin(void);
|
||||||
extern void sendbrk(void);
|
extern void sendbrk(void);
|
||||||
extern int tty_resettimer(int tno);
|
|
||||||
extern void tty_resettimers(void);
|
|
||||||
extern int tty_settimer(int,int);
|
|
||||||
extern int tty_expired(int);
|
|
||||||
extern int tty_running(int);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user