Configure a Linux Bridge as a Hub




H4 will initially be configure as a linux bridge. When the ageing time is set to zero, the bridge will become a hub. h1-h3 are normal hosts.


[mininet: test_hub.htm]

#!/usr/bin/env python

from mininet.cli import CLI

from import Link,TCLink,Intf

from import Mininet

from mininet.node import RemoteController


if '__main__' == __name__:

  net = Mininet(link=TCLink)

  h1 = net.addHost('h1', mac='00:00:00:00:01:00')

  h2 = net.addHost('h2', mac='00:00:00:00:02:00')

  h3 = net.addHost('h3', mac='00:00:00:00:03:00')

  h4 = net.addHost('h4', mac='00:00:00:00:04:00')

  Link(h1, h4)

  Link(h2, h4)

  Link(h3, h4)

  h4.cmd("ifconfig h4-eth0 0")

  h4.cmd("ifconfig h4-eth1 0")

  h4.cmd("ifconfig h4-eth2 0")

  h4.cmd("brctl addbr br0")

  h4.cmd("brctl addif br0 h4-eth0")

  h4.cmd("brctl addif br0 h4-eth1")

  #h4.cmd("brctl setageing br0 0")

  h4.cmd("brctl addif br0 h4-eth2")

  h4.cmd("ifconfig br0 up")





1. When h4 is a bridge (switch).



h1 will ping h3 three times. h2 will try to capture the packets. From the following figure, we can see that h2 can only get the first packet sent by h1 (arp request packet). When the bridge learns the h1 address. h2 cannot capture any packets.


2. When h4 is configure as a hub.


From the following figure, we can see that h2 can capture all the packets between h1 and h3. (Hub behavior)


Dr. Chih-Heng Ke

Department of Computer Science and Information Engineering, National Quemoy University, Kinmen, Taiwan