then process checks the classification rule otherwise the process proceeds to step 468 in step 468 the packet which has been identified as a discovery packet is forwarded to the control processor in step 470 the control processor or more specifically the ndos or a process therein identifies directly or indirectly the ingress port i e an external port on which the particular discovery packet was received in step 472 the control processor or more specifically the ndos or a process therein extracts the sending switch id and the egress port id from the discovery packet in step 474 the control processor or more specifically the ndos or a process therein creates a topology entry that includes i the receiving switch id which uniquely identifies the network device that received the discovery packet ii the ingress port id which uniquely identifies the external port of the network device through which the discovery packet was received iii the sending switch id and iv the egress port id of the sending switch in step 476 the network device generates a layer 2 topology using one or more topology entries in one embodiment of the invention the topology entries may be used to generate local layer 2 topologies which specifies which network entities including virtual machines and physical hosts if any are connected to each of the external ports on the network device the individual network devices may then communicate their local layer 2 topology to any other network devices to which they are directly or indirectly connected in this manner each of the network devices may receive local layer 2 topologies and using the local layer 2 topologies generate a global layer 2 topology in.