Skip navigation.
Home
A virtual network infrastructure
PlanetLab logo
Powered by PlanetLab

ClickGenerator.rb

ClickGenerator Class

External Methods

printConfig(node)

Given the virtual topology defined by the experimenter (i.e., interrelated Node and Link objects), creates a Click configuration file for running Click beneath UML and the uml_switch on node. The output file is called click.cfg.

The Click configuration can be a bit confusing at first. Basically, there is a MAC table that looks at the MAC addresses of each packet and decide where to send it (e.g., into a tunnel, up to UML). When Click forwarding is enabled, a special MAC address is defined corresponding to Click's IPv4 forwarding engine (element _xorp_rt4; the MAC table sends packets with this MAC destination to the forwarding engine. Files destined to the OpenVPN server or the NAT egress are handled specially.

The best way to understand how this Click configuration works is in two phases. First, build a topology with Click forwarding disabled. In this case, all packets pass through the the MAC table and IPv4 forwarding occurs inside the UML kernel. Once you understand how things are working, enable Click forwarding. This optimization adds the _xorp_rt4 table to the configuration and some new paths through the Click graph to avoid doing IPv4 forwarding in UML.

Internal Methods

printAddresses(node)

Prints an AddressInfo element containing labels used to refer to addresses in the rest of the configuration. Only information for this node and nodes immediately adjacent in the topology are printed.

printHeader(node)

Print some comments containing the node name and date/time the file was generated.

printIPForwarding(node)

If Click forwarding is configured for this node, prints the _xorp_rt4 IPv4 forwarding table for this node. Local destinations (e.g., tap0, UML interfaces), and forwarding entries to the immediate neighbors in the topology, are hard-coded into this table. Other remote destinations will be inserted by the routing software.

printIPOutputs(node)

Handles packets from the _xorp_rt4 output ports. The first N output ports correspond to the N network interfaces defined in UML; a packet output on port i is handled in the same way as a packet forwarded by UML to interface ethi when Click IP forwarding is not used. Output ports with indices greater than N are used to forward IP packets to local destinations such as interfaces in UML or the tap0 device.

Packets output on port 0 go to the OpenVPN server. This server assigns addresses to clients from the same /24 as UML's eth0 interface; in other words, UML's eth0 and the OpenVPN server and clients can be thought of as on the same virtual subnet.

printMacOutputs(node)

Handles packets from the mac_table outputs. Entries in the mac_table are commented with the ultimate destination of packets that are emitted on each output; this function connects the outputs with the destinations.

printMacTable(node)

Prints the mac_table, a statically-generated table that forwards packets based on their MAC source/destination addresses. First the destination MAC address is checked to see if it matches the MAC address of a local UML interface. If so, it is forwarded on the output leading to UML.

If the destination MAC does not match, then the source MAC is checked to see which interface it is coming from, and on this basis the packet is output on a port leading to the appropriate destination. For example, a packet coming from the local UML interface eth2 will get pushed to the tunnel corresponding to that interface. This source-MAC-based forwarding handles cases like link-level broadcast and IP multicast, where the MAC destination in the packet does not match any specific interface MAC address.

printNAPTElements(node)

Prints a big elementclass called NaptEgress that performs network address and port translation for TCP/UDP/ICMP packets.

printOpenVPNOutput(node)

If the node has been configured to run OpenVPN, prints a path enabling communication with the OpenVPN server via a Unix domain socket.