-2
I’ll send the assignment. Objective: to identify the value of the MTU used in the TCP/IP network local, dynamically and with some heuristic to, in this way, minimize the number of iterations in determining that value
Binary search only makes sense in ordered vectors. A vector v[0.. n-1] is in ascending order if: v[0] <= v[1] <= ... <= v[n - 1].
Algorithm: #defines NAOEXIST -1 // Receives a number x and a crescent vector // v[e.. d] with n >= 0. Returns j such that v[j] == x // or returns NAOEXIST if such a j does not exist.
int bb(int x, int v[], int e, int d) { if (e > d) NAOEXIST Return; Else { int m. m = (e + d)/2; if (v[m] == x) Return m; if (v[m] < x) Return bb(x, v, m+1, d); Else Return bb(x, v, e, m-1); } }
. The activity is to elaborate an algorithm that makes use of the referred heuristics, to minimize the amount of iterations required in determining the MTU. . The idea is to use a repeat loop to execute the ping command with different amounts of data (increasing or decreasing this quantity) and always with the option of active nonfragmentation, so as to mislead sending error. Identification of error indicating need fragmentation, can be used to determine the MTU value for the link technology of your network.
Now the code I’m doing in whatever you can help, thank you...
echo "Laboratório de Redes de Computadores"
echo "------------------------------------"
echo "Nome completo: Marcelo"
echo "------------------------------------"
aux1=`ifconfig | grep "inet " | awk '{print $3'\t'$4'\t'$5'\t'$6}'`
echo "${aux1}"
echo "Determinacao do valor do MTU "
echo
i=0
for i in {1471..1473}; do
echo "ping com 1 pacote Nao Fragmentado com a QUANTIDADEdeDADOS:${i} 192.168.0.1"
echo
AUX=`ping -c 1 -s ${i} -M do 192.168.0.1 | grep "local error" | awk '{print}'`
echo "${AUX}" #Esse aux não printa na tela não sei pq
# if [ -f $AUX ] #daí não consigo fazer esse if
# then
echo
echo "maximo de bytes por pacote na rede: ${i}"
# sleep 4s
# exit
# fi
done