fig1 shows the main units of a monitoring , diagnostics and maintenance agent mechanism 1 ( herein called agent ) according to an embodiment of the invention . agent 1 is embedded in an existing network device ( router or switch ) and is always present . the agents described here are not just client agents , but rather they are in a client - server relationship with all neighboring agents they communicate with . a neighboring agent here is an agent located on a network device physically connected to the device hosting the agent under consideration . each agent exchanges with neighboring agents data relevant to the network device operation , for enabling detection or faulty operation and also for enabling consolidation of messaging with the nms ( network management system ). in this specification , the term ‘ data ’ is used to specify any type of information relevant to operation of the router , including performance monitoring data , messaging , alarms , etc . it is to be understood that this data is not limited to the above examples , but can be any type of information that the network provider or user may wish to be considered . also , in this specification the network device may be referred as a router ; it is to be understood that the invention is applicable to network devices operating at layer - 2 and above . by distributing the tasks of monitoring , diagnostics and maintenance between routers , the nms tasks are reduced , enabling more efficient and faster management of the network , while the overhead messaging between the nms and the routers diminishes significantly . in addition , an agent 1 does not need to know the network topology ; rather it can discover and report the network topology , which makes it very well suited to mobile and ad - hoc networks . in order to enable communication with other agents , agent 1 is provided with a receiver 6 and a transmitter 18 . preferably , the agent 1 also uses decryption and encryption units 7 and respectively 16 for data authentication necessary for security reasons . for the forward direction , agent 1 receives monitoring and diagnostics data from other agents via the receive block 6 using the normal network communication protocols , such as ip . the decryption block 7 authenticates and decrypts the data which is then placed into an agent request queue 8 . the agent process 10 continuously monitors the agent request queue 9 and processes the data in the order established by the queue 9 , at the first available opportunity . when a request is taken for processing , the agent process 10 decodes the data and applies the logic requested by that specific data , after consulting a rule base 15 and a policy database 20 . the rule base 15 includes a plurality of rules that define the correct operation of the router . the router policy database 20 maintains a plurality of policies applicable to the respective particular router . various methods of detecting router behaviors may be envisaged and provided in the rule base 15 and router policy database 20 , respectively . statistics may also be collected for enabling the nms / operator to detect certain systematic abnormalities or potential for errors , in order to advise the respective network provider or user of the problem . for example , such statistics may identify the router responsible with the worst routing practices , enabling the provider / user to take any suitable corrective measures . the agent process 10 forwards the information relevant to the respective data , hereinafter called the processed data , to a correlation module 12 . module 12 correlates this processed data with equivalent data stored in a local database 25 to detect any inconsistencies . the accuracy of the detection must be sufficient to provide the nms / operator with enough relevant information . the data output by correlation module 12 , hereinafter called the correlated data , and that do not specify errors is forwarded on to a next hop selector 14 to continue through the network . next hop selector 14 chooses a neighboring device ( router , switch ) and implicitly the respective neighboring agent to consult . preferably , this selection is performed via a random path selection or random multiple path selection mechanism . a variety of next hop selection mechanisms can be used , the invention is not limited to any particular such mechanism . after the next hop device is identified , the data is encrypted in encryption block 16 so that it can be forward to the next agent in a secure manner and then transmitted to the next agent using transmitter 18 . if there is a problem , an error generation module 13 is consulted to send an error message to the central management system . the error message may contain a simple indication of an error , or may provide additional information on the particulars of the error , with various degrees of sophistication . before transmission at 18 , the error information is preferably encrypted at shown at 16 . fig2 shows the distributed agent at work . in this example , the network devices are routers denoted with r 1 - r 5 . the dotted lines indicate a “ traveling ” agent 30 thereby the routers exchange their operational data with a neighboring router . in this example , data from agent 1 hosted on router r 1 travels to neighboring agent 2 hosted on router r 2 , etc . as discussed previously , r 2 is the next hop from r 1 , selected by the agent 1 on r 1 using the respective selection mechanism 14 ( see fig1 ). if any of the agents 1 - 5 detects an error , the error message is transmitted to the central management so that the operator may take appropriate action . as an example , let &# 39 ; s assume that the functionality that is monitored and analyzed by the agent 1 is the routing behavior of the routers in sub - network 100 of fig2 . particularly , let us assume that the bgp ( border gateway protocol ) routing table contents and evolution is of interest . bgp is a routing protocol whose aim is to exchange routing ( prefixes + next hop , etc . . . .) information between autonomous systems ( as &# 39 ; s ). an autonomous system or routing domain is a group of internet protocol ( ip ) routers or label switching routers ( lsrs ) exchanging routing information using a common routing protocol such as igp ( interior gateway protocol ) and controlled by a common network administrator on behalf of a single administrative entity . an autonomous system shares routing information with other autonomous systems using the bgp . the primary objective in this case is to give operators the most pertinent information on any erroneous , abnormal or suspicious routing table content . for example , suspicious or error source behaviors could be lack of aggregation , non - conformance to rir &# 39 ; s allocation policies , multi - homing ( addressing scheme in is - is routing that supports assignment of multiple area addresses ), etc . each router r 1 - r 5 of the sub - network 100 is equipped with a respective agent 1 - 5 , the agents monitoring and analyzing , in this example , the routing behavior of the router r 1 . as indicated above , the agents 1 - 5 on r 1 - r 5 perform the respective local analysis of the bgp routing table content and evolution , using the rule base 15 and the router policy database 20 . then , the agents also perform the correlation with the respective routing data received from the neighboring agents , and transmit any error detected as a result of the correlation to the nms . however , some of the tasks performed by the agent may be more resource consuming than others . for example , early analysis showed that it is unrealistic in terms of available resources to analyze bgp messages to detect suspicious behaviors . the growth of the routing table size is not always caused by the growth of the network , but also comes from usual practices in bgp configuration . although these configuration policies are locally relevant , they often impact the entire network ( internet ), since the bgp does not offer any efficient mechanism to restrict diffusion of a route . the objective of the embedded routing monitoring of this example is to detect lack of aggregation , multi - homing and load balancing with a view to reducing the content of the forwarding information base ( fib ). also , the embedded routing monitoring in this example allows operators to have a “ real - time ” view of the behavior of the respective routers and as &# 39 ; s . in other words , each embedded agent may provide a local view of the bgp behaviors . it is to be noted that detection of such cases does not necessarily means an error in operation , but could signal a mode of operation due to application of various valid bgp policies . this allows a better use of hardware resources , which are expensive and critical in the context of high - speed networks . while waste coming from lack of aggregation can be easily fixed , this is not the case for load balancing or multi - homing . up to now , all of these practices are not only tolerated , but they are also exported in the whole internet . furthermore , the agents may be designed to monitor and analyze the router behavior in a multiple stage process , the stages being triggered by the data output by an earlier stage only when needed . for example , the first monitoring and analysis stage continuously runs to perform basic tasks , selected to consume low router resources . the output of the first stage is used to trigger a second stage , based on the type and level of error or abnormality detected by the first stage , if any . since the analysis performed in the second stage is specialized and more complex than that of the basic stage , the cost of operating this stage is higher due to higher resource consumption . the cost of operating the agent may be reduced since the second stage operates only if necessary ( as pre - set by the network provider or user ) and based on the output of the first stage . additional specialized and more complex stages may also be used ; this architecture can be extended to any level . fig3 shows a two - stage mechanism . in this example , the first stage 40 provides global monitoring , which as indicated above , uses fewer resources and runs continuously . the output 35 of stage 40 triggers the second stage 50 , using e . g . pre - set thresholds . stage 50 performs specific analysis of data 35 . and as such is more resource consuming ; it also operates on a subset of data identified during the first stage . the operator may receive error messages from the first stage directly , or from both the first and the second stage . various methods may be used to perform the analysis of e . g . the routing data , such as monitoring prefix repartition by size , or detection of prefix non - conformance with allocation policies , etc . if any of the results of stage 40 indicates routing table abnormalities , the suspicious data is provided to stage 50 , for in - depth analysis . again , there are various methods available in this second stage , such as address fragmentation count , determining lack of aggregation rate , load balancing or multi - homing , etc . these methods are described briefly next . load balancing is characterized by the fact that a route advertised for a prefix has the same origin as a route for a neighboring prefix , but the paths for these prefixes are different . two prefixes are considered as neighbors if the sets of the respective covered addresses are adjacent . therefore , load balancing is detected if there exists a prefix pb neighbor with a prefix pa , or pb covers pa , such that the respective routes have the same origin but distinct physical paths . multi - homing is characterized by the fact that a prefix is advertised by a network device through several providers . in fact , the example considers a ‘ provider aggregate - able ’ allocated prefixes approximation , which is justified by the way the prefixes are allocated to independent providers in ipv4 . with this approximation , multi - homing creates ‘ holes ’ in the routing base because the customer advertises its prefixes separately from the prefix of its provider . a ‘ hole ’ is a prefix whose route has different characteristics ( at least the origin of the path ) than the route of its covering prefix . there should be no hole for single - homed prefixes , because the customer doesn &# 39 ; t need to announce this prefixes beyond its provider . therefore , multi - homing is detected if there exists a prefix pb covering pa , and having different . lack of aggregation is characterized by the fact that a prefix is advertised by a network device with the same characteristics ( mainly the physical path ) as a neighbor and aggregate - able prefix . therefore , lack of aggregation for a prefix x / n is detected if the bit of level n for x is 1 and there exists a nlri y / n ( y being x with bit level n = 0 ) such that the physical paths for the best routes are similar .