PPS = PACKET PER SECOND HOW TO CHECK IN LINUX SERVER


Sometimes you need know how many pps send or recive server in duration time .
This is simple script using multithreaded for read information and save information from all network interfaces ( every interface have individual thread) .
On any linux system sholuld working. Script read stats from /sys/class/net//statistics/tx_packets

What doing script.
1. Check numbers interface.
2. Create thread one for one interface
3. Save output .csv exaple eth0.csv
4. Retuen (eneter) break script and close ald children procces

Parameter verbose script.sh verbose give oupput to screen


#!/bin/bash
echo "Renturn , Enter close aplication\n\n"

p1=$1
flag=$(date +"%d-%m-%y %H:%M:%S")
fork_for_interface(){
        while true
        do
        Rx1=`multithreaded `
        Tx1=`cat /sys/class/net/$line/statistics/tx_packets`
        sleep $INTERVAL
        Rx2=`cat /sys/class/net/$line/statistics/rx_packets`
        Tx2=`cat /sys/class/net/$line/statistics/tx_packets`
        TXPPS=`expr $Tx2 - $Tx1`
        RXPPS=`expr $Rx2 - $Rx1`
        if [ "$p1" = "verbose" ];
         then
                echo "$(date +"%d-%m-%y %H:%M:%S") ,TX $1: $TXPPS pkts/s RX $line: $RXPPS pkts/s" ;
        fi
        echo "$(date +"%d-%m-%y %H:%M:%S"), $TXPPS,$RXPPS" >> $line.csv
        done
}
INTERVAL="1"  # update interval in seconds
IFS=" "
IF=$1
interfaces=$(ls /sys/class/net/)
PIDLIST=()
K=0
while read -r line; do
        fork_for_interface &
        PIDLIST[$K]=$!
        touch $line.csv
        K=$K+1;
done <<<"$interfaces"
echo "List chlidren precces "
for i in "${PIDLIST[@]}"
        do
        echo $i
        echo
done
unset IFS
while true; do
read key
        if [ $? -eq 0 ] && [ -z "$key" ]
        then
            for i in "${PIDLIST[@]}"; do echo "closing PID $i "; kill -9 $i; done
        break
        fi
done

How many package can you send over you interface or mediaconverter .
Is simple and depend of type package example Multi Protocol Label Switching (MPLS) have 96 bytes

framve vlan=Figure2

1Gbps = 1,000,000,000 bits/s = (1,000,000,000 bits/s) / (8 bits/byte)= 125,000,000 bytes/s

PPS = (125,000,000 bytes/s) / (88 bytes/packet) = 1,302,083 pps.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s