...
1. Execute the tool with highest priority if bytes received in token is greater then bytes required by the tool else execute the second highest priority tool.
2. Set the priority of executed tool to the lowest priority.
3. Decrement the number of bytes used by the tool from the token.
4. if bytes in token are greater then any tool required byes then go to step 1 else set the token to its initial value and forward to the next site.
Lets say we have an Array of *{_}N{_}* Monitoring sites *{_}M\[1...N\]_* and each site have *{_}n{_}* tools *{_}T\[1..n\]_* to execute. Let *{_}B{_}* be the bytes received by host in token and *{_}X\[1..x\]_* represent no of target to be probed with tools. Wiki Markup
Code Block |
---|
NextSite(A,i)
if i is equal to length_of(A) then
return A[1]
else return A[i+1]
|
...
Code Block |
---|
ChangePriority(A){ x = A[lengthOf(A)] for i = lengthOf(A)-1 down to 1 A[i+1] = A[i] i = i -1 A[1] = x } |
ChangePriority takes an array as argument and change its priority from N to 1 and increase the other consecutive elements priority by 1. It actually treats an index of an element as its priority. Hence, It copy A\[N\] at A\[1\] and A\[i\] at A\[i+1\ ChangePriority takes an array as argument and change its priority from N to 1 and increase the other consecutive elements priority by 1. It actually treats an index of an element as its priority. Hence, It copy A[N] at A[1] and A[i] at A[i+1] Wiki Markup
Code Block |
---|
GetMaxPriorityElement(A){ return A[lengthOf(A)] } |
Code Block |
---|
Schedule(M,T,X){ while isTokenRecieved() is false // wait 1 sec for another check totalBytes = B // B is the total no. of bytes received in Token target = GetHighestPriorityElement(X) ChangePriority(X) while totalBytes > 0 tool = GetHighestPriorityElement(T) target = GetHighestPriorityElement(X) exec (tool,target) totalBytes = totalbytes - tool.bytesRequired ChangePriority(T) ChangePriority(X) sendToken(NextSite(M,i),B) } |