[Click] OutputChooser

Douglas S. J. De Couto decouto at csail.mit.edu
Tue Apr 20 10:36:22 EDT 2004


You might try the `Switch' element.  There is also a `PullSwitch', I 
believe, and other variants.

http://www.pdos.lcs.mit.edu/click/doc/Switch.n.html

d

On 20 Apr 2004, at 07:59, Dagang wrote:

> Hello clickall,
>
> I am a new user of click (1.3pre1). Now I am trying to make some new
> elements myself. I need an element that has the simple functionality of
> pushing incoming packets onto just one of its outputs(based on the 
> value
> of a variable), therefore I call it OutputChooser. It is based on Tee.
>
> I copied the source of Tee into OutputChooser, only changing the name.
> It compiled and worked just like a Tee. Fine. Then I made some
> modification on the push() method, as shown below:
>
> ---Tee.cc--------------
> void
> Tee::push(int, Packet *p)
> {
>   int n = noutputs();
>   for (int i = 0; i < n - 1; i++)
>     if (Packet *q = p->clone())
>       output(i).push(q);
>   output(n - 1).push(p);
> }
> ------------------------
>
> ---OutputChooser.cc-----
> void
> OutputChooser::push(int, Packet *p)
> {
>    output(1).push(p);
> }
> ------------------------
>
> I used this new element in a configuration working in kernel mode as
> shown below:
>
>
> // MN.click
> ----------------------------------
> AddressInfo(
>                 mobnod  10.0.0.200        10.0.0.0/24,
>                 gatway        10.0.0.4        10.0.0.0/24,
>                 dev1        00:B0:D0:3A:39:31,
>                 dev2        00:05:5D:E2:09:A5
> );
>
> dev :: FromDevice(eth0)
>         -> cl_mn :: Classifier(12/0800 23/01,  //icmp
>                                 12/0800 23/11,  //udp
>                                 -);
>
> cl_mn[1] -> Strip(14)
>          -> CheckIPHeader
>          -> GetIPAddress(16)
>          -> ipcl_mn :: IPClassifier(src udp port 434, -);
> cl_mn[2] -> oc_sta1 :: Tee(4); // other packets
> cl_mn[0] -> oc_sta1;
> ipcl_mn[0] -> EtherEncap(0x0800, 1:1:1:1:1:1, 2:2:2:2:2:2) -> oc_sta1;
> // registration reply
> ipcl_mn[1] -> EtherEncap(0x0800, 1:1:1:1:1:1, 2:2:2:2:2:2)
>            -> oc_sta1; // other udp packets
>
> // When status is not clear
> oc_sta1[0] -> Print(uclr) -> Discard; //status unclear
> oc_sta1[3] -> Print(pend) -> Discard; //registration pending
>
> // When at home, employ ARP
> // 0. ARP Query
> // 1. ARP Response
> // 2. Other
> oc_sta1[1] -> Print(home)
>            -> cl_home :: Classifier(12/0806 20/0001,
>                                     12/0806 20/0002,
>                                     -);
> cl_home[0] -> ARPResponder(mobnod:ip dev1)
>            -> tod :: Queue(2000) -> ToDevice(eth0);
> cl_home[1] -> oc_arpq2 :: Tee(2);
> cl_home[2] -> ToHost(fake);
>
> // When not at home, discard all ARP queries
> // 0. ARP packets
> // 1. Other
> oc_sta1[2] -> Discard;
>
> // packets going outwards
> FromHost (fake, mobnod)
>                -> fromhost_cl :: Classifier(12/0806, 12/0800, -);
> fromhost_cl[0] -> ARPResponder(0.0.0.0/0 1:1:1:1:1:1) -> ToHost(fake);
> fromhost_cl[1] -> oc_sta2 :: OutputChooser(4); // IP
> fromhost_cl[2] -> Discard; // othe packets
>
> oc_sta2[0] -> Discard; // not clear
> oc_sta2[3] -> Discard; // registation pending
>
> oc_sta2[1] // at home
>            -> Strip(14)
>            -> CheckIPHeader
>            -> GetIPAddress(16)
>            -> rt1 :: LinearIPLookup(10.0.0.200/32 0,
>                                 10.0.0.0/32 0,
>                                 10.0.0.255/32 0,
>                                 255.255.255.255/32 0,
>
>         10.0.0/24 1,
>
>         0/0 gatway:ip 1);
> rt1[0] ->EtherEncap(0x0800, 1:1:1:1:1:1, 2:2:2:2:2:2) -> ToHost(fake);
> rt1[1] -> arpq1 :: ARPQuerier(mobnod:ip, dev1:eth)
>       -> tod;//dev;
> oc_arpq2[0] -> [1]arpq1;
> oc_arpq2[1] -> Discard;
>
> oc_sta2[2] -> Discard; //away
> ----------------
>
> Now comes the wierd thing: It works fine for ping, ssh, telnet, but 
> when
> I try to use a brower to visit a heavy-loaded webpage,
> www.tomshardware.com for instance, the brower stalls, and I can reach 
> no
> where since then, even for ping. Re'click-install', nework back, reload
> webpage, network gone...
>
> If I change OutputChoose back to Tee, everyting's ok.
>
> I really have no idea so I write everything down. The .click
> configuration might looks bizzard, because I comment off a lot of 
> unused
> thing to make it simpler. Any suggestion would be highly appreciated.
>
> Best regards,
> Dagang
>
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>
>
--
Douglas S. J. De Couto    <decouto at csail.mit.edu>



More information about the click mailing list