@@ -116,7 +116,7 @@ func newSocket(sc SocketConfig, fanoutID int, num int) (*socket, error) {
116116
117117// String returns a unique string for this socket.
118118func (s * socket ) String () string {
119- return fmt .Sprintf ("[S:%v:%v]" , s .conf .SocketName , s .num )
119+ return fmt .Sprintf ("[S:%v; fid :%v]" , s .conf .SocketName , s .num )
120120}
121121
122122// getNewBlocks is a goroutine that watches for new available packet blocks,
@@ -139,6 +139,7 @@ func (s *socket) getNewBlocks() {
139139
140140func (s * socket ) reportStats () {
141141 var totalPackets , totalDrops uint64
142+ var totalNotSent float64
142143 // getting statistics returns the stats since the last invocation. We clear
143144 // counters by doing an initial read we ignore.
144145 s .stats ()
@@ -149,10 +150,20 @@ func (s *socket) reportStats() {
149150 if err != nil {
150151 log .Printf ("error getting statistics: %v" , err )
151152 } else {
152- totalPackets += uint64 (stats .tp_packets )
153- totalDrops += uint64 (stats .tp_drops )
154- vlog .V (1 , "%v stats: %d packets (%.02fpps), %d drops (%.02fpps) (%.02f%% dropped) since last log, %d packets, %d drops total (%.02f%% dropped)" , s ,
155- stats .tp_packets , float64 (stats .tp_packets )/ seconds , stats .tp_drops , float64 (stats .tp_drops )/ seconds , float64 (stats .tp_drops )/ float64 (stats .tp_drops + stats .tp_packets )* 100 ,
153+ client_status := "delivered to client"
154+ totalNotSent = float64 (stats .tp_packets ) - (float64 (stats .tp_packets ) * (float64 (len (s .currentConns )) / (float64 (s .conf .NumberOfClients * s .conf .FanoutSize ))))
155+ if len (s .currentConns ) <= 0 {
156+ client_status = "discarded by testimony"
157+ }
158+ if s .conf .NumberOfClients == 0 {
159+ vlog .V (1 , " Connected - %d clients" , len (s .currentConns ))
160+ } else {
161+ vlog .V (1 , " Connected - %d clients, still not connected - %d, therefore %v packets loosed " , len (s .currentConns ), (s .conf .NumberOfClients * s .conf .FanoutSize )- len (s .currentConns ), totalNotSent )
162+ }
163+ vlog .V (1 , " %v stats: %d packets %v (%.02fpps), %d dropped in kernel (%.02fpps) (%.02f%% dropped) since last log, %d packets, %d drops total (%.02f%% dropped)" ,
164+ s , stats .tp_packets , client_status , float64 (stats .tp_packets )/ seconds ,
165+ stats .tp_drops , float64 (stats .tp_drops )/ seconds ,
166+ float64 (stats .tp_drops )/ float64 (stats .tp_drops + stats .tp_packets )* 100 ,
156167 totalPackets , totalDrops , float64 (totalDrops )/ float64 (totalPackets + totalDrops )* 100 )
157168 }
158169 }
0 commit comments