mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-25 18:14:53 +00:00
Fixed congestion window bug where the pcb->cwnd variable overflowed when increased.
This commit is contained in:
parent
05b8bf216c
commit
8fe9e007c9
@ -641,7 +641,7 @@ tcp_receive(struct tcp_pcb *pcb)
|
|||||||
} else {
|
} else {
|
||||||
/* Inflate the congestion window, but not if it means that
|
/* Inflate the congestion window, but not if it means that
|
||||||
the value overflows. */
|
the value overflows. */
|
||||||
if(pcb->cwnd + pcb->mss > pcb->cwnd) {
|
if((u16_t)(pcb->cwnd + pcb->mss) > pcb->cwnd) {
|
||||||
pcb->cwnd += pcb->mss;
|
pcb->cwnd += pcb->mss;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -677,13 +677,14 @@ tcp_receive(struct tcp_pcb *pcb)
|
|||||||
ssthresh). */
|
ssthresh). */
|
||||||
if(pcb->state >= ESTABLISHED) {
|
if(pcb->state >= ESTABLISHED) {
|
||||||
if(pcb->cwnd < pcb->ssthresh) {
|
if(pcb->cwnd < pcb->ssthresh) {
|
||||||
if(pcb->cwnd + pcb->mss > pcb->cwnd) {
|
if((u16_t)(pcb->cwnd + pcb->mss) > pcb->cwnd) {
|
||||||
pcb->cwnd += pcb->mss;
|
pcb->cwnd += pcb->mss;
|
||||||
}
|
}
|
||||||
DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: slow start cwnd %u\n", pcb->cwnd));
|
DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: slow start cwnd %u\n", pcb->cwnd));
|
||||||
} else {
|
} else {
|
||||||
if(pcb->cwnd + pcb->mss * pcb->mss / pcb->cwnd > pcb->cwnd) {
|
u16_t new_cwnd = (pcb->cwnd + pcb->mss * pcb->mss / pcb->cwnd);
|
||||||
pcb->cwnd += pcb->mss * pcb->mss / pcb->cwnd;
|
if(new_cwnd > pcb->cwnd) {
|
||||||
|
pcb->cwnd = new_cwnd;
|
||||||
}
|
}
|
||||||
DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: congestion avoidance cwnd %u\n", pcb->cwnd));
|
DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: congestion avoidance cwnd %u\n", pcb->cwnd));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user