if [ "$1" ]
then
    if [ "$2" ]
    then
	if [ "$3" ]
	then
	    if [ "$3" == "first" ]
	    then
                mv droplist.txt droplist_$(date +"%d_%m_%Y_%I_%M_%S_%p").txt
                echo " "
	        echo "droplist.txt file will be created to drop only 1st sequence"
                echo " "
                echo "\$1#" > droplist.txt
                cat droplist.txt
                echo " "
	    elif [ "$3" == "last" ]
	    then
                mv droplist.txt droplist_$(date +"%d_%m_%Y_%I_%M_%S_%p").txt
                echo " "
	        echo "droplist.txt file will be created to drop only last sequence"
                echo " "
        
                file_size=$(wc -c $1 | awk '{print $1}')
                mtu_size=`expr $2 - 8`
                max_pkt_size=`expr $file_size / $mtu_size`
                max_pkt_size_mod=`expr $file_size % $mtu_size`
	        if [ "$max_pkt_size_mod" == "0" ]
	        then
		   max_pkt_size=`expr $max_pkt_size + 0`
	        else
		   max_pkt_size=`expr $max_pkt_size + 1`
	        fi
                echo "\$$max_pkt_size#" > droplist.txt 
                cat droplist.txt
                echo " "
	    elif [ "$3" == "all" ]
	    then
                mv droplist.txt droplist_$(date +"%d_%m_%Y_%I_%M_%S_%p").txt
                echo " "
	        echo "droplist.txt file will be created to drop all sequence"
                echo " "
        
                file_size=$(wc -c $1 | awk '{print $1}')
                mtu_size=`expr $2 - 8`
                max_pkt_size=`expr $file_size / $mtu_size`
                max_pkt_size_mod=`expr $file_size % $mtu_size`
	        if [ "$max_pkt_size_mod" == "0" ]
	        then
		   max_pkt_size=`expr $max_pkt_size + 0`
	        else
		   max_pkt_size=`expr $max_pkt_size + 1`
	        fi
                for i in `seq $max_pkt_size`; do echo -n ",$i"; done >> droplist.txt
                echo -n "#" >> droplist.txt
                sed -i 's/,/$/' droplist.txt 
		cat droplist.txt
                echo " "
                echo " "
	    elif [ "$3" == "50" ]
	    then
                mv droplist.txt droplist_$(date +"%d_%m_%Y_%I_%M_%S_%p").txt
                echo " "
	        echo "droplist.txt file will be created to drop last 50 sequence"
                echo " "
        
                file_size=$(wc -c $1 | awk '{print $1}')
                mtu_size=`expr $2 - 8`
                max_pkt_size=`expr $file_size / $mtu_size`
                max_pkt_size_mod=`expr $file_size % $mtu_size`
	        if [ "$max_pkt_size_mod" == "0" ]
	        then
		   max_pkt_size=`expr $max_pkt_size + 0`
	        else
		   max_pkt_size=`expr $max_pkt_size + 1`
	        fi
		if [ $max_pkt_size -le "$3" ]
		then
		    echo " Please choose more than 10kb file to perform this test"
		else
		    seq_start=`expr $max_pkt_size - $3`
                    for i in `seq $seq_start $max_pkt_size`; do echo -n ",$i"; done >> droplist.txt
                    echo -n "#" >> droplist.txt
                    sed -i 's/,/$/' droplist.txt 
		    cat droplist.txt
                    echo " "
                    echo " "
		fi
	    elif [ "$3" == "100" ]
	    then
                mv droplist.txt droplist_$(date +"%d_%m_%Y_%I_%M_%S_%p").txt
                echo " "
	        echo "droplist.txt file will be created to drop last 100 sequence in middle"
                echo " "
        
                file_size=$(wc -c $1 | awk '{print $1}')
                mtu_size=`expr $2 - 8`
                max_pkt_size=`expr $file_size / $mtu_size`
                max_pkt_size_mod=`expr $file_size % $mtu_size`
	        if [ "$max_pkt_size_mod" == "0" ]
	        then
		   max_pkt_size=`expr $max_pkt_size + 0`
	        else
		   max_pkt_size=`expr $max_pkt_size + 1`
	        fi
		if [ $max_pkt_size -le "$3" ]
		then
		    echo " Please choose more than 20kb file to perform this test"
		else
                    for i in `seq 11 111`; do echo -n ",$i"; done >> droplist.txt
                    echo -n "#" >> droplist.txt
                    sed -i 's/,/$/' droplist.txt 
		    cat droplist.txt
                    echo " "
                    echo " "
		fi
	    else
	        echo " "
	        echo "3rd Input is invalid to execute droplist generator"
                echo "3rd agurment can be \"all\" or \"first\" or \"last\" or \"50\" or \"100\" "
	        echo " "
	    fi
	else
            mv droplist.txt droplist_$(date +"%d_%m_%Y_%I_%M_%S_%p").txt
        
            file_size=$(wc -c $1 | awk '{print $1}')
        
            mtu_size=`expr $2 - 8`
        
            max_pkt_size=`expr $file_size / $mtu_size`
            max_pkt_size_mod=`expr $file_size % $mtu_size`
	    
	    if [ "$max_pkt_size_mod" == "0" ]
	    then
		max_pkt_size=`expr $max_pkt_size + 0`
	    else
		max_pkt_size=`expr $max_pkt_size + 1`
	    fi
        
            max_inp=200;
            rand_inp_cnt=$(shuf -i1-199 -n1)
            first_drop_pkt=$(shuf -i2-$max_pkt_size -n1)
            echo " "
            echo -n "\$$first_drop_pkt" >> droplist.txt
            for i in `seq $rand_inp_cnt`; do rand_drop_pkt=$(shuf -i2-$max_pkt_size -n1); echo -n ",$rand_drop_pkt"; done >> droplist.txt
            echo -n "#" >> droplist.txt
            cat droplist.txt
            echo " "
            echo " "
        fi
    else
	echo " "
	echo "Below inputs are missing to execute droplist generator"
        echo "1st agurment should be filename (e.x. antaris_exo_core.bin)"
        echo "2nd argument should be MTU side (e.x. 180)"
	echo " "
    fi
else
	echo " "
	echo "Below inputs are missing to execute droplist generator"
	echo "1st agurment should be filename (e.x. antaris_exo_core.bin)"
	echo "2nd argument should be MTU side (e.x. 180)"
	echo " "
fi
