comparison common-channel.c @ 448:9c61e7af0156

Rearrange the channel buffer sizes into three neat use-editable values in options.h. Increasing RECV_MAX_WINDOW gives big network performance increases - even with the present buffers (which haven't changed) it performs a lot better. Next step is to make the window size a cmdline option.
author Matt Johnston <matt@ucc.asn.au>
date Tue, 24 Jul 2007 15:40:23 +0000
parents ab370c629d36
children 3e6c536bc023
comparison
equal deleted inserted replaced
447:278805938dcf 448:9c61e7af0156
148 newchan->errfd = FD_CLOSED; /* this isn't always set to start with */ 148 newchan->errfd = FD_CLOSED; /* this isn't always set to start with */
149 newchan->initconn = 0; 149 newchan->initconn = 0;
150 newchan->await_open = 0; 150 newchan->await_open = 0;
151 newchan->flushing = 0; 151 newchan->flushing = 0;
152 152
153 newchan->writebuf = cbuf_new(RECV_MAXWINDOW); 153 newchan->writebuf = cbuf_new(RECV_MAX_WINDOW);
154 newchan->extrabuf = NULL; /* The user code can set it up */ 154 newchan->extrabuf = NULL; /* The user code can set it up */
155 newchan->recvwindow = RECV_MAXWINDOW; 155 newchan->recvwindow = RECV_MAX_WINDOW;
156 newchan->recvdonelen = 0; 156 newchan->recvdonelen = 0;
157 newchan->recvmaxpacket = RECV_MAXPACKET; 157 newchan->recvmaxpacket = RECV_MAX_PAYLOAD_LEN;
158 158
159 ses.channels[i] = newchan; 159 ses.channels[i] = newchan;
160 ses.chancount++; 160 ses.chancount++;
161 161
162 TRACE(("leave newchannel")) 162 TRACE(("leave newchannel"))
419 send_msg_channel_window_adjust(channel, channel->recvdonelen); 419 send_msg_channel_window_adjust(channel, channel->recvdonelen);
420 channel->recvwindow += channel->recvdonelen; 420 channel->recvwindow += channel->recvdonelen;
421 channel->recvdonelen = 0; 421 channel->recvdonelen = 0;
422 } 422 }
423 423
424 dropbear_assert(channel->recvwindow <= RECV_MAXWINDOW); 424 dropbear_assert(channel->recvwindow <= RECV_MAX_WINDOW);
425 dropbear_assert(channel->recvwindow <= cbuf_getavail(channel->writebuf)); 425 dropbear_assert(channel->recvwindow <= cbuf_getavail(channel->writebuf));
426 dropbear_assert(channel->extrabuf == NULL || 426 dropbear_assert(channel->extrabuf == NULL ||
427 channel->recvwindow <= cbuf_getavail(channel->extrabuf)); 427 channel->recvwindow <= cbuf_getavail(channel->extrabuf));
428 428
429 TRACE(("leave writechannel")) 429 TRACE(("leave writechannel"))
708 len -= buflen; 708 len -= buflen;
709 } 709 }
710 710
711 dropbear_assert(channel->recvwindow >= datalen); 711 dropbear_assert(channel->recvwindow >= datalen);
712 channel->recvwindow -= datalen; 712 channel->recvwindow -= datalen;
713 dropbear_assert(channel->recvwindow <= RECV_MAXWINDOW); 713 dropbear_assert(channel->recvwindow <= RECV_MAX_WINDOW);
714 714
715 TRACE(("leave recv_msg_channel_data")) 715 TRACE(("leave recv_msg_channel_data"))
716 } 716 }
717 717
718 /* Increment the outgoing data window for a channel - the remote end limits 718 /* Increment the outgoing data window for a channel - the remote end limits
725 725
726 channel = getchannel(); 726 channel = getchannel();
727 727
728 incr = buf_getint(ses.payload); 728 incr = buf_getint(ses.payload);
729 TRACE(("received window increment %d", incr)) 729 TRACE(("received window increment %d", incr))
730 incr = MIN(incr, MAX_TRANS_WIN_INCR); 730 incr = MIN(incr, TRANS_MAX_WIN_INCR);
731 731
732 channel->transwindow += incr; 732 channel->transwindow += incr;
733 channel->transwindow = MIN(channel->transwindow, MAX_TRANS_WINDOW); 733 channel->transwindow = MIN(channel->transwindow, TRANS_MAX_WINDOW);
734 734
735 } 735 }
736 736
737 /* Increment the incoming data window for a channel, and let the remote 737 /* Increment the incoming data window for a channel, and let the remote
738 * end know */ 738 * end know */
767 /* get the packet contents */ 767 /* get the packet contents */
768 type = buf_getstring(ses.payload, &typelen); 768 type = buf_getstring(ses.payload, &typelen);
769 769
770 remotechan = buf_getint(ses.payload); 770 remotechan = buf_getint(ses.payload);
771 transwindow = buf_getint(ses.payload); 771 transwindow = buf_getint(ses.payload);
772 transwindow = MIN(transwindow, MAX_TRANS_WINDOW); 772 transwindow = MIN(transwindow, TRANS_MAX_WINDOW);
773 transmaxpacket = buf_getint(ses.payload); 773 transmaxpacket = buf_getint(ses.payload);
774 transmaxpacket = MIN(transmaxpacket, MAX_TRANS_PAYLOAD_LEN); 774 transmaxpacket = MIN(transmaxpacket, TRANS_MAX_PAYLOAD_LEN);
775 775
776 /* figure what type of packet it is */ 776 /* figure what type of packet it is */
777 if (typelen > MAX_NAME_LEN) { 777 if (typelen > MAX_NAME_LEN) {
778 goto failure; 778 goto failure;
779 } 779 }
968 CHECKCLEARTOWRITE(); 968 CHECKCLEARTOWRITE();
969 969
970 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_OPEN); 970 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_OPEN);
971 buf_putstring(ses.writepayload, type->name, strlen(type->name)); 971 buf_putstring(ses.writepayload, type->name, strlen(type->name));
972 buf_putint(ses.writepayload, chan->index); 972 buf_putint(ses.writepayload, chan->index);
973 buf_putint(ses.writepayload, RECV_MAXWINDOW); 973 buf_putint(ses.writepayload, RECV_MAX_WINDOW);
974 buf_putint(ses.writepayload, RECV_MAXPACKET); 974 buf_putint(ses.writepayload, RECV_MAX_PAYLOAD_LEN);
975 975
976 TRACE(("leave send_msg_channel_open_init()")) 976 TRACE(("leave send_msg_channel_open_init()"))
977 return DROPBEAR_SUCCESS; 977 return DROPBEAR_SUCCESS;
978 } 978 }
979 979