A method for preventing loops in a network topology comprising a plurality of switch devices (301, 302, 303), the method comprising: - assigning, to each switch device (301, 302, 303), a unique switch identification number, SW-ID; - exchanging each SW-ID between all switch devices (301, 302, 303); - building, for each switch device (301, 302, 303), a routing table based on said received SW-IDs, so that switch devices (301, 302, 303) can reach each other; wherein each entry in the routing table is associated with a switch device, and includes an assigned SW-ID of the switch device; a dedicated port number and a number of hops to reach the switch device, wherein the number of hops corresponds to the shortest path to reach the switch device; the method further comprising: - when receiving, at a first switch device, a data frame, from a second switch device, that includes a source switch identification number, SS-ID, assigned to the second switch device; and the data frame is received at a port of the first switch device; - if, according to the routing table of the first switch device, the assigned SW-ID for this port is different from the SS-ID included in the data frame, discarding the data frame; otherwise, processing forward the data frame; wherein processing forward the data frame includes: - if the data frame is a broadcast frame or an unknown-unicast frame, flooding the data frame out from each port of the first switch device that is connected to other switch devices (302, 303) except from the port from which the data frame was received; and removing the SS-ID from the data frame and flooding the data frame without the SS-ID frame out from each port of the first switch device that is directly connected to at least one host node; - if the data frame is a known-unicast frame: - checking, using the routing table of the first switch device, if there is any SW-ID assigned to a port number that is associated with a Medium Access Control, MAC, destination address in the data frame; and - if there is no SW-ID, removing the SS-ID from the data frame and forwarding the data frame, out from said associated port, to its destination MAC address; and - if there is a SW-ID, forwarding the data frame to the switch device having the SW-ID. - assigning, to each switch device (301, 302, 303), a unique switch identification number, SW-ID; - exchanging each SW-ID between all switch devices (301, 302, 303); - building, for each switch device (301, 302, 303), a routing table based on said received SW-IDs, so that switch devices (301, 302, 303) can reach each other; - when receiving, at a first switch device, a data frame, from a second switch device, that includes a source switch identification number, SS-ID, assigned to the second switch device; and the data frame is received at a port of the first switch device; - if, according to the routing table of the first switch device, the assigned SW-ID for this port is different from the SS-ID included in the data frame, - if the data frame is a broadcast frame or an unknown-unicast frame, flooding the data frame out from each port of the first switch device that is connected to other switch devices (302, 303) except from the port from which the data frame was received; and removing the SS-ID from the data frame and flooding the data frame without the SS-ID frame out from each port of the first switch device that is directly connected to at least one host node; - if the data frame is a known-unicast frame: - checking, using the routing table of the first switch device, if there is any SW-ID assigned to a port number that is associated with a Medium Access Control, MAC, destination address in the data frame; and - if there is no SW-ID, removing the SS-ID from the data frame and forwarding the data frame, out from said associated port, to its destination MAC address; and - if there is a SW-ID, forwarding the data frame to the switch device having the SW-ID.