Collect some more TCP statistics.

git-svn-id: svn://kolibrios.org@5442 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2015-02-21 15:07:30 +00:00
parent f6f01fd6de
commit b23bd6c7e3
5 changed files with 71 additions and 26 deletions

View File

@ -98,9 +98,9 @@ struct TCP_SOCKET IP_SOCKET
;---------------------- ;----------------------
; Transmit timing stuff ; Transmit timing stuff
t_idle dd ? t_idle dd ?
t_rtt dd ? t_rtt dd ? ; round trip time
t_rtseq dd ? t_rtseq dd ?
t_srtt dd ? t_srtt dd ? ; smoothed round trip time
t_rttvar dd ? t_rttvar dd ?
t_rttmin dd ? t_rttmin dd ?
max_sndwnd dd ? max_sndwnd dd ?
@ -1974,14 +1974,8 @@ SOCKET_free:
jnz .no_tcp jnz .no_tcp
mov ebx, eax mov ebx, eax
cmp [ebx + STREAM_SOCKET.rcv.start_ptr], 0
je @f
stdcall kernel_free, [ebx + STREAM_SOCKET.rcv.start_ptr] stdcall kernel_free, [ebx + STREAM_SOCKET.rcv.start_ptr]
@@:
cmp [ebx + STREAM_SOCKET.snd.start_ptr], 0
je @f
stdcall kernel_free, [ebx + STREAM_SOCKET.snd.start_ptr] stdcall kernel_free, [ebx + STREAM_SOCKET.snd.start_ptr]
@@:
mov eax, ebx mov eax, ebx
.no_tcp: .no_tcp:

View File

@ -394,13 +394,18 @@ endl
pop ecx pop ecx
cmp eax, TCP_PAWS_IDLE cmp eax, TCP_PAWS_IDLE
jle .drop_after_ack ; TODO: update stats jle .paws_drop
push ecx push ecx
mov [ebx + TCP_SOCKET.ts_recent], 0 ; timestamp was invalid, fix it. mov [ebx + TCP_SOCKET.ts_recent], 0 ; timestamp was invalid, fix it.
.no_paws: .no_paws:
jmp .opt_loop jmp .opt_loop
.paws_drop:
inc [TCPS_rcvduppack] ; update stats
add [TCPS_rcvdupbyte], ecx
inc [TCPS_pawsdrop]
jmp .drop_after_ack
.no_options: .no_options:
pop ecx pop ecx
@ -630,6 +635,8 @@ endl
or [ebx + TCP_SOCKET.t_flags], TF_ACKNOW or [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
mov eax, ecx mov eax, ecx
inc [TCPS_rcvpartduppack]
;;; TODO: update stats ;;; TODO: update stats
;----------------------------------------------- ;-----------------------------------------------
@ -662,7 +669,7 @@ endl
mov eax, ebx mov eax, ebx
call TCP_close call TCP_close
;;; TODO: update stats inc [TCPS_rcvafterclose]
jmp .respond_seg_reset jmp .respond_seg_reset
;---------------------------------------- ;----------------------------------------
@ -985,17 +992,14 @@ endl
mov eax, [edx + TCP_header.AckNumber] mov eax, [edx + TCP_header.AckNumber]
cmp eax, [ebx + TCP_SOCKET.SND_MAX] cmp eax, [ebx + TCP_SOCKET.SND_MAX]
jbe @f jbe @f
inc [TCPS_rcvacktoomuch]
;;; TODO: update stats
jmp .drop_after_ack jmp .drop_after_ack
@@: @@:
mov edi, [edx + TCP_header.AckNumber] mov edi, [edx + TCP_header.AckNumber]
sub edi, [ebx + TCP_SOCKET.SND_UNA] ; now we got the number of acked bytes in edi sub edi, [ebx + TCP_SOCKET.SND_UNA] ; now we got the number of acked bytes in edi
inc [TCPS_rcvackpack]
;;; TODO: update stats add [TCPS_rcvackbyte], edi
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: acceptable ACK for %u bytes\n", edi DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: acceptable ACK for %u bytes\n", edi
;------------------------------------------ ;------------------------------------------
@ -1209,6 +1213,8 @@ align 4
test [edx + TCP_header.Flags], TH_SYN test [edx + TCP_header.Flags], TH_SYN
jz .drop jz .drop
inc [TCPS_accepts] ; update stats
;;; TODO: check if it's a broadcast or multicast, and drop if so ;;; TODO: check if it's a broadcast or multicast, and drop if so
push dword [edi] ; Ipv4 source addres push dword [edi] ; Ipv4 source addres

View File

@ -90,10 +90,9 @@ endl
cmp ebx, [eax + STREAM_SOCKET.snd.size] cmp ebx, [eax + STREAM_SOCKET.snd.size]
jae @f jae @f
and dl, not (TH_FIN) and dl, not (TH_FIN)
@@: @@:
inc ecx inc ecx
jmp .no_force jmp .no_force
@ -113,7 +112,6 @@ endl
@@: @@:
sub esi, ebx sub esi, ebx
;------------------------ ;------------------------
; check for window shrink (107) ; check for window shrink (107)
@ -146,7 +144,6 @@ endl
cmp esi, [eax + TCP_SOCKET.t_maxseg] cmp esi, [eax + TCP_SOCKET.t_maxseg]
jbe @f jbe @f
mov esi, [eax + TCP_SOCKET.t_maxseg] mov esi, [eax + TCP_SOCKET.t_maxseg]
or [temp_bits], TCP_BIT_SENDALOT or [temp_bits], TCP_BIT_SENDALOT
@@: @@:
@ -160,7 +157,6 @@ endl
cmp edi, [eax + STREAM_SOCKET.snd.size] cmp edi, [eax + STREAM_SOCKET.snd.size]
jae @f jae @f
and dl, not (TH_FIN) and dl, not (TH_FIN)
@@: @@:
;------------------------------- ;-------------------------------
@ -403,6 +399,50 @@ endl
or [temp_bits], TCP_BIT_SENDALOT or [temp_bits], TCP_BIT_SENDALOT
.no_overflow: .no_overflow:
; Update stats
test esi, esi
jz .zero_data
cmp [eax + TCP_SOCKET.t_force], 1
jne @f
cmp esi, 1
jne @f
inc [TCPS_sndprobe]
jmp .eos
@@:
mov ebx, [eax + TCP_SOCKET.SND_NXT]
cmp ebx, [eax + TCP_SOCKET.SND_MAX]
jae @f
inc [TCPS_sndrexmitpack]
add [TCPS_sndrexmitbyte], esi
jmp .eos
@@:
inc [TCPS_sndpack]
add [TCPS_sndbyte], esi
jmp .eos
.zero_data:
test [eax + TCP_SOCKET.t_flags], TF_ACKNOW
jz @f
inc [TCPS_sndacks]
jmp .eos
@@:
test dl, TH_SYN + TH_FIN + TH_RST
jz @f
inc [TCPS_sndctrl]
jmp .eos
@@:
mov ebx, [eax + TCP_SOCKET.SND_UP]
cmp ebx, [eax + TCP_SOCKET.SND_UNA]
jb @f
inc [TCPS_sndurg]
jmp .eos
@@:
inc [TCPS_sndwinup]
.eos:
;---------------------------------------------------- ;----------------------------------------------------
; Calculate the receive window. ; Calculate the receive window.
; Dont shrink window, but avoid silly window syndrome ; Dont shrink window, but avoid silly window syndrome
@ -469,8 +509,8 @@ endl
call IPv4_output call IPv4_output
jz .ip_error jz .ip_error
;----------------------------------------- ;------------------------------------------
; Move TCP header from stack to TCP packet ; Move TCP header from stack to TCP segment
push ecx push ecx
mov ecx, [esp + 4] mov ecx, [esp + 4]
@ -504,7 +544,7 @@ endl
test ecx, ecx test ecx, ecx
jz .nodata jz .nodata
mov edx, [eax + TCP_SOCKET.SND_NXT] mov edx, [eax + TCP_SOCKET.SND_NXT]
add [eax + TCP_SOCKET.SND_NXT], ecx ; update sequence number <<< CHECKME add [eax + TCP_SOCKET.SND_NXT], ecx ; update sequence number
sub edx, [eax + TCP_SOCKET.SND_UNA] ; offset sub edx, [eax + TCP_SOCKET.SND_UNA] ; offset
add eax, STREAM_SOCKET.snd add eax, STREAM_SOCKET.snd
call SOCKET_ring_read call SOCKET_ring_read
@ -536,7 +576,7 @@ endl
je @f je @f
mov [eax + TCP_SOCKET.t_rtt], 1 ; nope, start transmission timer mov [eax + TCP_SOCKET.t_rtt], 1 ; nope, start transmission timer
mov [eax + TCP_SOCKET.t_rtseq], edi mov [eax + TCP_SOCKET.t_rtseq], edi
;TODO: update stats inc [TCPS_segstimed]
@@: @@:
; set retransmission timer if not already set, and not doing an ACK or keepalive probe ; set retransmission timer if not already set, and not doing an ACK or keepalive probe
@ -584,6 +624,7 @@ endl
call NET_ptr_to_num4 call NET_ptr_to_num4
inc [TCP_segments_tx + edi] inc [TCP_segments_tx + edi]
inc [TCPS_sndtotal]
; update advertised receive window ; update advertised receive window
test ecx, ecx test ecx, ecx

View File

@ -54,6 +54,8 @@ local .exit
; call TCP_output ;; ; call TCP_output ;;
pop ebx pop ebx
inc [TCPS_delack] ; update stats
jmp .loop jmp .loop
.exit: .exit:

View File

@ -89,6 +89,8 @@ TCP_connect:
test [eax + SOCKET.state], SS_ISCONNECTED test [eax + SOCKET.state], SS_ISCONNECTED
jnz .eisconn jnz .eisconn
inc [TCPS_connattempt] ; update stats
push eax edx push eax edx
lea ecx, [eax + SOCKET.mutex] lea ecx, [eax + SOCKET.mutex]
call mutex_lock call mutex_lock