Click tutorial NITLab June 22, 2013
Introduction to Click Router Click [1] is flexible modular software architecture for creating routers. Click routers are built from fine-grained components, named elements, which support and extend the basic functions of the packet forwarding path. Each element represents a conceptually simple computation or packet processing, like header encapsulation/decapsulation, packet duplication or rejection, etc. To build a router configuration, the user chooses a collection of elements and connects them into a directed graph. The graphs edges, which are called connections, represent possible paths for packet handoff. The simplest router configuration includes three elements, named FromDevice , Queue and ToDevice , which are sequentially connected, as it is depicted in the Figure 1, and implements a router that retransmits all received packets. The boxes represent the elements and the arrows the connections. FromDevice and ToDevice are specific elements that get connected with a net-
Figure 1: Simplest configuration work interface and handle (with use of libpcap [2] library) all packets received or have to be sent through this interface. Through these elements, Click intercepts to the usual kernel packet forwarding process and implements easily and clearly a new one. More specifically, in the previous example, FromDevice receives packets from the interface and forwards them to Queue for storage, while ToDevice retrieves these packets from Queue for retransmission.
Download and build Click software Click framework is provided through a git-repository and can be downloaded using the following command: g i t c l on e g i t : // g i t h u b . c om / k o h o u ma s / c l i ck . g i t
This command downloads the click folder in your working directory. This folder contains a variety of subfolders, including the click/conf , click/elements and click/userlevel folders. •
•
•
click/userlevel includes the executable file, named click, which is produced after a successful compile click/conf includes perl (and python) files that create configurations of routers (setups of elements with appropriate connections) click/elements includes c++ files that describe the elements behavior (Also, folders click/conf and click/elements , include a subfolder named wifi that contains the files related to WiFi.)
For utilization of extra elements, like these of the Roofnet project [3] (that is a famous wireless routing protocol implemented in Click), the click-packages git-repository should be also downloaded to the same working directory with click folder, typing: g i t c l on e g i t : // g i t h u b . c om / k o h o u ma s / c l ic k - p a c ka g e s . g it
The subfolder click/elements/wifi includes some links to the subfolders click-packages/sr and click-packages/bp. If sb doesn’t want to use the elements of these subfolders, then he should delete these links. After downloading the two repositories, the next step is the configuration and compilation of the click software. Click uses also the OML [4] framework for measurement collection, that requires the liboml2-dev library. In order for sb to compile click, he/she should add “deb http://pkg.mytestbed.net/ubuntu precise/” to the “/etc/apt/sources.list” file, and run: s u do a pt - g et u p d at e s u do a pt - g et i n s ta l l l i bo m l2 - d e v
1
After this step, he/she is ready to configure and compile click, by running the following commands: c d c l ic k . / c o n f i g u r e - - e n a bl e - u s e r l e v e l - - d i s ab l e - l i n u x m o d u l e - - e n a bl e - w i f i L I B S = - l o m l 2 ma ke
Download and build Click software for NS-3 Click framework for NS-3 is provided as git-repositories and can be downloaded using the following commands: g i t c l on e g i t : // g i t h u b . c om / k o h o u ma s / c l ic k - n s 3 . g i t g i t c l on e g i t : // g i t h u b . c om / k o h o u ma s / c l ic k - p a c ka g e s . g it
The next step after downloading the two repositories is the configuration and compilation of the click software: c d c li ck - n s 3 . / c o n f i g u r e - - e n a bl e - n s c l i c k - - e n a bl e - w i f i ma ke
The NS-3 software should be downloaded by typing: c d / u s r / l o ca l / s r c g i t c l on e g i t : // g i t h u b . c om / k o h o u ma s / n s - 3 - cl i ck - m ac - d e v . g it
If it is the first time that the NS-3 project is built in this system, download and install the ns-3-allinone repository in the same directory typing (in other case ignore the following commands): h g c l on e h t tp : / / c o d e . n sn a m . o rg / n s - 3 - a l l in o n e c d n s - 3 - a l l in o n e . / b u i l d . p y - - e n a bl e - e x a m p l e s - - e n a bl e - t e s t s cd . .
Then change to the ns-3-click-mac-dev repository, configure and compile it by typing: c d n s - 3 - c li ck - m ac - d e v C X X FL A G S = " - W al l " . / w af c o n fi g u re - d d e bu g - - e n a bl e - s u d o - - e n a bl e - e x a m p l e s - - e n a bl e - t e s t s --with-nsclick=/full_path_to_click/click-ns3/ ./waf
If sb wants to create a new network simulation, he adds the appropriate .cc file in the subfolder ns-3click-mac-dev/scratch and then runs this simulation, typing: . / w af - - r un s c r at c h / f i l e _n a m e
(The file name should be without the .cc prefix.)
Create Click configuration files and run Click router in Linux machine or NS-3 environment For running either Roofnet or Enhanced-Backpressure in a Linux machine using e.g. 802.11a channel 36,
use the following commands for Roofnet (SRCR): c d c l ic k s u do p e rl . / c o nf / w i f i / b p / g e n _c o n f ig _ r o o fn e t _ bp . p l - - c h an n e l = 36 > / t m p / t mp . c l i c k s u do u s e rl e v el / c l i c k / t m p / t mp . c l i c k
2
the
or these commands for Enhanced-Backpressure (EBoW): c d c l ic k s u do p e rl . / c o nf / w i f i / b p / g e n _c o n f ig _ r o o fn e t _ bp . p l - - bp - - c h an n e l = 36 > / t m p / t mp . c l i c k s u do u s e rl e v el / c l i c k / t m p / t mp . c l i c k For running NS-3 simulations with e.g. 12 nodes,
run the following commands for Roofnet (SRCR): c d c li ck - n s 3 p e rl . / c o nf / w i f i / b p / r o of n e t _b p . p y - - n s - - c h an n el = 3 6 1 2 c d . . / ns - 3 - c l ic k - m a c - d e v . / w a f - - r u n s c r a t c h / r o o f ne t - b p - c l i c k - s i m u l a t o r
or these commands for Enhanced-Backpressure (EBoW): c d c li ck - n s 3 p e rl . / c o nf / w i f i / b p / r o of n e t _b p . p y - - n s - - bp - - c h an n e l = 36 1 2 c d . . / ns - 3 - c l ic k - m a c - d e v . / w a f - - r u n s c r a t c h / r o o f ne t - b p - c l i c k - s i m u l a t o r
(NOTE: click-ns3/conf/wifi/bp is a link to the corresponding subfolder click/conf/wifi/bp, so download of click repository is also necessary in this case.)
Description of Roofnet configuration file
Figure 2: Roofnet configuration Figure 2 describes the Roofnet-SRCR configuration, using the same notation as Kohler used in his thesis (The Click Modular Router, MIT, Feb 2001), describing the Click architecture. Keep in mind that: •
Every box is a module-element.
•
“srcr”, “srcr host” and “sniff dev” are compound elements.
•
•
•
•
Each box has at least one triangle and one square. Each triangle is an input port and each square is an output port. Full-filled triangles or squares mean that they are push ports. Empty triangles or squares are pull ports. “srcr host” is the interface between the router and the user-level applications, while “sniff dev” is the interface between the router and the wireless monitor. 3
Figure 3: “srcr” compound element Figure 3 provides a more analytical view of the compound element of “srcr ett”.
4
Bibliography [1] Click Modular Router, www.read.cs.ucla.edu/click/click . [2] Library for Network Traffic Capture, www.tcpdump.org . [3] Roofnet project, pdos.csail.mit.edu/roofnet/doku.php . [4] OML project, mytestbed.net/projects/oml/wiki/OML_Overview .
5