librelist archives

« back to archive

Conditional Flow in Click

Conditional Flow in Click

From:
Nimantha Baranasuriya
Date:
2015-02-28 @ 12:56
Hi everyone,

I am a Click newbie and I followed some example click scripts and read the
documentation on the Click website to get familiarized with how Click
worked.

I need to implement the following flow using Click.

q :: Queue(10)

FromDevice(eth0) -> ip_classifier :: IPClassifier(condA, condB, -);

ip_classifier[0] -> Set some flag (say F) -> Discard;
ip_classifier[1] -> Reset F -> Discard;
ip_classifier[2] -> if F set then -> q -> ToDevice(eth0) else -> q;

Basically, what I want to do is, if the router receives an IP packet
matching condA, it sets a flag, and if it receives an IP packet matching
condB, the router resets the flag. For all other IP packets, the router
first checks the flag and if its set, the packet is sent to a Queue and
then sent out from the ethernet card. If the flag is not set, then packet
is queued. In simple terms, the router queues packets till a flag is set.
The moment the flag is set, the packets that were queued earlier needs to
be sent out.

Can someone please help me to write a click script to get this done? I have
looked at the Script element that can handle conditional flows, but I
couldn’t yet figure out how to use Script to implement my requirement.

Thanks in advance.

-Nimantha





-- 
Nimantha Baranasuriya
Web: http://www.nimantha.info
Blog: http://www.nimantha.info/blog
Photography: http://www.nimantha.info/photoblog;
http://www.flickr.com/photos/nimanthab

Re: [click] Conditional Flow in Click

From:
Bro, Lars
Date:
2015-03-02 @ 08:52
Hi Nimantha,

I agree that the Script element is a bit tricky, but maybe you can do 
something like this:

s::Script(
  TYPE PACKET,
  Write sw::switch $(if $(eq $input 0) 0 -1)
)

ip_classifier[0] -> 0[s]
ip_classifier[1] -> 1[s]

ip_classifier[2] -> sw::Switch() -> Queue …

If the Script element is of type PACKET, the script will run for each 
incoming packet and $input is the input port from which the packet came. 
The $(if …) statement returns 0 if the packet came from input 0 or -1 if 
the packet came from another input (1).  You can write to the “switch” 
handler of a switch element the output that you want the switch to point 
to or “-1” which means no outputs, but discard instead. So, writing “0” to
sw.switch closes the switch (makes packets pass through) and writing “-1” 
to the switch opens it (blocks packets)


Yours,
Lars Bro

From: click@librelist.com [mailto:click@librelist.com] On Behalf Of 
Nimantha Baranasuriya
Sent: 28. februar 2015 13:57
To: click@librelist.com
Subject: [click] Conditional Flow in Click

Hi everyone,

I am a Click newbie and I followed some example click scripts and read the
documentation on the Click website to get familiarized with how Click 
worked.

I need to implement the following flow using Click.

q :: Queue(10)

FromDevice(eth0) -> ip_classifier :: IPClassifier(condA, condB, -);

ip_classifier[0] -> Set some flag (say F) -> Discard;
ip_classifier[1] -> Reset F -> Discard;
ip_classifier[2] -> if F set then -> q -> ToDevice(eth0) else -> q;

Basically, what I want to do is, if the router receives an IP packet 
matching condA, it sets a flag, and if it receives an IP packet matching 
condB, the router resets the flag. For all other IP packets, the router 
first checks the flag and if its set, the packet is sent to a Queue and 
then sent out from the ethernet card. If the flag is not set, then packet 
is queued. In simple terms, the router queues packets till a flag is set. 
The moment the flag is set, the packets that were queued earlier needs to 
be sent out.

Can someone please help me to write a click script to get this done? I 
have looked at the Script element that can handle conditional flows, but I
couldn’t yet figure out how to use Script to implement my requirement.

Thanks in advance.

-Nimantha




--
Nimantha Baranasuriya
Web: http://www.nimantha.info
Blog: http://www.nimantha.info/blog
Photography: http://www.nimantha.info/photoblog; 
http://www.flickr.com/photos/nimanthab

Re: [click] Conditional Flow in Click

From:
Eddie Kohler
Date:
2015-03-02 @ 17:43
Yes! Although there were a couple syntax errors.

Even easier to understand, perhaps, would be:

ip_classifier[0] -> Script(TYPE PACKET, write sw.switch 0) -> ...
ip_classifier[1] -> Script(TYPE PACKET, write sw.switch -1) -> ...
ip_classifier[2] -> sw::Switch -> ...


On Mon, Mar 2, 2015 at 3:52 AM, Bro, Lars <lars.bro@siemens.com> wrote:
> Hi Nimantha,
>
>
>
> I agree that the Script element is a bit tricky, but maybe you can do
> something like this:
>
>
>
> s::Script(
>
>   TYPE PACKET,
>
>   Write sw::switch $(if $(eq $input 0) 0 -1)
>
> )
>
>
>
> ip_classifier[0] -> 0[s]
>
> ip_classifier[1] -> 1[s]
>
>
>
> ip_classifier[2] -> sw::Switch() -> Queue …
>
>
>
> If the Script element is of type PACKET, the script will run for each
> incoming packet and $input is the input port from which the packet came. The
> $(if …) statement returns 0 if the packet came from input 0 or -1 if the
> packet came from another input (1).  You can write to the “switch” handler
> of a switch element the output that you want the switch to point to or “-1”
> which means no outputs, but discard instead. So, writing “0” to sw.switch
> closes the switch (makes packets pass through) and writing “-1” to the
> switch opens it (blocks packets)
>
>
>
>
>
> Yours,
>
> Lars Bro
>
>
>
> From: click@librelist.com [mailto:click@librelist.com] On Behalf Of Nimantha
> Baranasuriya
> Sent: 28. februar 2015 13:57
> To: click@librelist.com
> Subject: [click] Conditional Flow in Click
>
>
>
> Hi everyone,
>
>
> I am a Click newbie and I followed some example click scripts and read the
> documentation on the Click website to get familiarized with how Click
> worked.
>
> I need to implement the following flow using Click.
>
> q :: Queue(10)
>
> FromDevice(eth0) -> ip_classifier :: IPClassifier(condA, condB, -);
>
> ip_classifier[0] -> Set some flag (say F) -> Discard;
> ip_classifier[1] -> Reset F -> Discard;
> ip_classifier[2] -> if F set then -> q -> ToDevice(eth0) else -> q;
>
> Basically, what I want to do is, if the router receives an IP packet
> matching condA, it sets a flag, and if it receives an IP packet matching
> condB, the router resets the flag. For all other IP packets, the router
> first checks the flag and if its set, the packet is sent to a Queue and then
> sent out from the ethernet card. If the flag is not set, then packet is
> queued. In simple terms, the router queues packets till a flag is set. The
> moment the flag is set, the packets that were queued earlier needs to be
> sent out.
>
> Can someone please help me to write a click script to get this done? I have
> looked at the Script element that can handle conditional flows, but I
> couldn’t yet figure out how to use Script to implement my requirement.
>
> Thanks in advance.
>
> -Nimantha
>
>
>
>
>
> --
>
> Nimantha Baranasuriya
> Web: http://www.nimantha.info
> Blog: http://www.nimantha.info/blog
>
> Photography: http://www.nimantha.info/photoblog;
> http://www.flickr.com/photos/nimanthab
>
>

Re: [click] Conditional Flow in Click

From:
Nimantha Baranasuriya
Date:
2015-03-10 @ 13:59
Hi Bro and Eddie,

Thanks a lot for your feedback. I managed to get the router implemented
using the pointers you guys gave. I managed to implement an alternative
solution by reading the Click documentation as well. I have two questions
based on that, which I hope you all will be able to help me out.

u :: Unqueue
f :: FrontDropQueue
sq :: Queue

ip_classifier[0] -> Script(TYPE PACKET, write u.active 0) -> Discard;
ip_classifier[1] -> Script(TYPE PACKET, write u.active 1) -> Discard;
ip_classifier[0] -> f -> u -> sq -> ToDevice(eth0)

1) This one works fine too in the user mode. But, when I run this in the
kernel mode (by using click-install), the switching part does not work,
i.e., the u element is always active. How can this be fixed so tha the
implementation works as expected in the kernel mode too?

2) Is there a way to do benchmarking in Click? I need to find the time
period that a packet sat in the router's queue until it was sent out.

Thanks in advance,
Nimantha

On Tue, Mar 3, 2015 at 1:43 AM, Eddie Kohler <kohler@seas.harvard.edu>
wrote:

> Yes! Although there were a couple syntax errors.
>
> Even easier to understand, perhaps, would be:
>
> ip_classifier[0] -> Script(TYPE PACKET, write sw.switch 0) -> ...
> ip_classifier[1] -> Script(TYPE PACKET, write sw.switch -1) -> ...
> ip_classifier[2] -> sw::Switch -> ...
>
>
> On Mon, Mar 2, 2015 at 3:52 AM, Bro, Lars <lars.bro@siemens.com> wrote:
> > Hi Nimantha,
> >
> >
> >
> > I agree that the Script element is a bit tricky, but maybe you can do
> > something like this:
> >
> >
> >
> > s::Script(
> >
> >   TYPE PACKET,
> >
> >   Write sw::switch $(if $(eq $input 0) 0 -1)
> >
> > )
> >
> >
> >
> > ip_classifier[0] -> 0[s]
> >
> > ip_classifier[1] -> 1[s]
> >
> >
> >
> > ip_classifier[2] -> sw::Switch() -> Queue …
> >
> >
> >
> > If the Script element is of type PACKET, the script will run for each
> > incoming packet and $input is the input port from which the packet came.
> The
> > $(if …) statement returns 0 if the packet came from input 0 or -1 if the
> > packet came from another input (1).  You can write to the “switch”
> handler
> > of a switch element the output that you want the switch to point to or
> “-1”
> > which means no outputs, but discard instead. So, writing “0” to sw.switch
> > closes the switch (makes packets pass through) and writing “-1” to the
> > switch opens it (blocks packets)
> >
> >
> >
> >
> >
> > Yours,
> >
> > Lars Bro
> >
> >
> >
> > From: click@librelist.com [mailto:click@librelist.com] On Behalf Of
> Nimantha
> > Baranasuriya
> > Sent: 28. februar 2015 13:57
> > To: click@librelist.com
> > Subject: [click] Conditional Flow in Click
> >
> >
> >
> > Hi everyone,
> >
> >
> > I am a Click newbie and I followed some example click scripts and read
> the
> > documentation on the Click website to get familiarized with how Click
> > worked.
> >
> > I need to implement the following flow using Click.
> >
> > q :: Queue(10)
> >
> > FromDevice(eth0) -> ip_classifier :: IPClassifier(condA, condB, -);
> >
> > ip_classifier[0] -> Set some flag (say F) -> Discard;
> > ip_classifier[1] -> Reset F -> Discard;
> > ip_classifier[2] -> if F set then -> q -> ToDevice(eth0) else -> q;
> >
> > Basically, what I want to do is, if the router receives an IP packet
> > matching condA, it sets a flag, and if it receives an IP packet matching
> > condB, the router resets the flag. For all other IP packets, the router
> > first checks the flag and if its set, the packet is sent to a Queue and
> then
> > sent out from the ethernet card. If the flag is not set, then packet is
> > queued. In simple terms, the router queues packets till a flag is set.
> The
> > moment the flag is set, the packets that were queued earlier needs to be
> > sent out.
> >
> > Can someone please help me to write a click script to get this done? I
> have
> > looked at the Script element that can handle conditional flows, but I
> > couldn’t yet figure out how to use Script to implement my requirement.
> >
> > Thanks in advance.
> >
> > -Nimantha
> >
> >
> >
> >
> >
> > --
> >
> > Nimantha Baranasuriya
> > Web: http://www.nimantha.info
> > Blog: http://www.nimantha.info/blog
> >
> > Photography: http://www.nimantha.info/photoblog;
> > http://www.flickr.com/photos/nimanthab
> >
> >
>



-- 
Nimantha Baranasuriya
Web: http://www.nimantha.info
Blog: http://www.nimantha.info/blog
Photography: http://www.nimantha.info/photoblog;
http://www.flickr.com/photos/nimanthab

Re: [click] Conditional Flow in Click

From:
Jeffrey Lai
Date:
2015-03-10 @ 23:34
Could you do something along the lines of settimestamp -> queue ->
settimestampdelta?

On Wed, Mar 11, 2015 at 2:59 AM, Nimantha Baranasuriya <nimanthab@gmail.com>
wrote:

> Hi Bro and Eddie,
>
> Thanks a lot for your feedback. I managed to get the router implemented
> using the pointers you guys gave. I managed to implement an alternative
> solution by reading the Click documentation as well. I have two questions
> based on that, which I hope you all will be able to help me out.
>
> u :: Unqueue
> f :: FrontDropQueue
> sq :: Queue
>
> ip_classifier[0] -> Script(TYPE PACKET, write u.active 0) -> Discard;
> ip_classifier[1] -> Script(TYPE PACKET, write u.active 1) -> Discard;
> ip_classifier[0] -> f -> u -> sq -> ToDevice(eth0)
>
> 1) This one works fine too in the user mode. But, when I run this in the
> kernel mode (by using click-install), the switching part does not work,
> i.e., the u element is always active. How can this be fixed so tha the
> implementation works as expected in the kernel mo de too?
>
> 2) Is there a way to do benchmarking in Click? I need to find the time
> period that a packet sat in the router's queue until it was sent out.
>
> Thanks in advance,
> Nimantha
>
> On Tue, Mar 3, 2015 at 1:43 AM, Eddie Kohler <kohler@seas.harvard.edu>
> wrote:
>
>> Yes! Although there were a couple syntax errors.
>>
>> Even easier to understand, perhaps, would be:
>>
>> ip_classifier[0] -> Script(TYPE PACKET, write sw.switch 0) -> ...
>> ip_classifier[1] -> Script(TYPE PACKET, write sw.switch -1) -> ...
>> ip_classifier[2] -> sw::Switch -> ...
>>
>>
>> On Mon, Mar 2, 2015 at 3:52 AM, Bro, Lars <lars.bro@siemens.com> wrote:
>> > Hi Nimantha,
>> >
>> >
>> >
>> > I agree that the Script element is a bit tricky, but maybe you can do
>> > something like this:
>> >
>> >
>> >
>> > s::Script(
>> >
>> >   TYPE PACKET,
>> >
>> >   Write sw::switch $(if $(eq $input 0) 0 -1)
>> >
>> > )
>> >
>> >
>> >
>> > ip_classifier[0] -> 0[s]
>> >
>> > ip_classifier[1] -> 1[s]
>> >
>> >
>> >
>> > ip_classifier[2] -> sw::Switch() -> Queue …
>> >
>> >
>> >
>> > If the Script element is of type PACKET, the script will run for each
>> > incoming packet and $input is the input port from which the packet
>> came. The
>> > $(if …) statement returns 0 if the packet came from input 0 or -1 if the
>> > packet came from another input (1).  You can write to the “switch”
>> handler
>> > of a switch element the output that you want the switch to point to or
>> “-1”
>> > which means no outputs, but discard instead. So, writing “0” to
>> sw.switch
>> > closes the switch (makes packets pass through) and writing “-1” to the
>> > switch opens it (blocks packets)
>> >
>> >
>> >
>> >
>> >
>> > Yours,
>> >
>> > Lars Bro
>> >
>> >
>> >
>> > From: click@librelist.com [mailto:click@librelist.com] On Behalf Of
>> Nimantha
>> > Baranasuriya
>> > Sent: 28. februar 2015 13:57
>> > To: click@librelist.com
>> > Subject: [click] Conditional Flow in Click
>> >
>> >
>> >
>> > Hi everyone,
>> >
>> >
>> > I am a Click newbie and I followed some example click scripts and read
>> the
>> > documentation on the Click website to get familiarized with how Click
>> > worked.
>> >
>> > I need to implement the following flow using Click.
>> >
>> > q :: Queue(10)
>> >
>> > FromDevice(eth0) -> ip_classifier :: IPClassifier(condA, condB, -);
>> >
>> > ip_classifier[0] -> Set some flag (say F) -> Discard;
>> > ip_classifier[1] -> Reset F -> Discard;
>> > ip_classifier[2] -> if F set then -> q -> ToDevice(eth0) else -> q;
>> >
>> > Basically, what I want to do is, if the router receives an IP packet
>> > matching condA, it sets a flag, and if it receives an IP packet matching
>> > condB, the router resets the flag. For all other IP packets, the router
>> > first checks the flag and if its set, the packet is sent to a Queue and
>> then
>> > sent out from the ethernet card. If the flag is not set, then packet is
>> > queued. In simple terms, the router queues packets till a flag is set.
>> The
>> > moment the flag is set, the packets that were queued earlier needs to be
>> > sent out.
>> >
>> > Can someone please help me to write a click script to get this done? I
>> have
>> > looked at the Script element that can handle conditional flows, but I
>> > couldn’t yet figure out how to use Script to implement my requirement.
>> >
>> > Thanks in advance.
>> >
>> > -Nimantha
>> >
>> >
>> >
>> >
>> >
>> > --
>> >
>> > Nimantha Baranasuriya
>> > Web: http://www.nimantha.info
>> > Blog: http://www.nimantha.info/blog
>> >
>> > Photography: http://www.nimantha.info/photoblog;
>> > http://www.flickr.com/photos/nimanthab
>> >
>> >
>>
>
>
>
> --
> Nimantha Baranasuriya
> Web: http://www.nimantha.info
> Blog: http://www.nimantha.info/blog
> Photography: http://www.nimantha.info/photoblog;
> http://www.flickr.com/photos/nimanthab
>
>

Re: [click] Conditional Flow in Click

From:
Bro, Lars
Date:
2015-03-11 @ 10:30
Hi Nimantha,

Does this work as expected?

TimedSource(INTERVAL 2)  -> rrs::RoundRobinSwitch();
rrs[0]->Script(TYPE PACKET, write u.active 0);
rrs[1]->Script(TYPE PACKET, write u.active 1);

RatedSource() -> u::Unqueue() -> Print() -> Discard();

It should report traffic in two seconds intervals. It works for me both in
user and kernel mode.

I don’t think you meant this:
ip_classifier[0] -> f -> u -> sq -> ToDevice(eth0)
It is second time you use ip_classifier[0], and it is a push output,


Yours,
Lars Bro
From: click@librelist.com [mailto:click@librelist.com] On Behalf Of 
Nimantha Baranasuriya
Sent: 10. marts 2015 15:00
To: click@librelist.com
Subject: Re: [click] Conditional Flow in Click

Hi Bro and Eddie,

Thanks a lot for your feedback. I managed to get the router implemented 
using the pointers you guys gave. I managed to implement an alternative 
solution by reading the Click documentation as well. I have two questions 
based on that, which I hope you all will be able to help me out.

u :: Unqueue
f :: FrontDropQueue
sq :: Queue

ip_classifier[0] -> Script(TYPE PACKET, write u.active 0) -> Discard;
ip_classifier[1] -> Script(TYPE PACKET, write u.active 1) -> Discard;
ip_classifier[0] -> f -> u -> sq -> ToDevice(eth0)

1) This one works fine too in the user mode. But, when I run this in the 
kernel mode (by using click-install), the switching part does not work, 
i.e., the u element is always active. How can this be fixed so tha the 
implementation works as expected in the kernel mo de too?

2) Is there a way to do benchmarking in Click? I need to find the time 
period that a packet sat in the router's queue until it was sent out.

Thanks in advance,
Nimantha

On Tue, Mar 3, 2015 at 1:43 AM, Eddie Kohler 
<kohler@seas.harvard.edu<mailto:kohler@seas.harvard.edu>> wrote:
Yes! Although there were a couple syntax errors.

Even easier to understand, perhaps, would be:

ip_classifier[0] -> Script(TYPE PACKET, write sw.switch 0) -> ...
ip_classifier[1] -> Script(TYPE PACKET, write sw.switch -1) -> ...
ip_classifier[2] -> sw::Switch -> ...


On Mon, Mar 2, 2015 at 3:52 AM, Bro, Lars 
<lars.bro@siemens.com<mailto:lars.bro@siemens.com>> wrote:
> Hi Nimantha,
>
>
>
> I agree that the Script element is a bit tricky, but maybe you can do
> something like this:
>
>
>
> s::Script(
>
>   TYPE PACKET,
>
>   Write sw::switch $(if $(eq $input 0) 0 -1)
>
> )
>
>
>
> ip_classifier[0] -> 0[s]
>
> ip_classifier[1] -> 1[s]
>
>
>
> ip_classifier[2] -> sw::Switch() -> Queue …
>
>
>
> If the Script element is of type PACKET, the script will run for each
> incoming packet and $input is the input port from which the packet came. The
> $(if …) statement returns 0 if the packet came from input 0 or -1 if the
> packet came from another input (1).  You can write to the “switch” handler
> of a switch element the output that you want the switch to point to or “-1”
> which means no outputs, but discard instead. So, writing “0” to sw.switch
> closes the switch (makes packets pass through) and writing “-1” to the
> switch opens it (blocks packets)
>
>
>
>
>
> Yours,
>
> Lars Bro
>
>
>
> From: click@librelist.com<mailto:click@librelist.com> 
[mailto:click@librelist.com<mailto:click@librelist.com>] On Behalf Of 
Nimantha
> Baranasuriya
> Sent: 28. februar 2015 13:57
> To: click@librelist.com<mailto:click@librelist.com>
> Subject: [click] Conditional Flow in Click
>
>
>
> Hi everyone,
>
>
> I am a Click newbie and I followed some example click scripts and read the
> documentation on the Click website to get familiarized with how Click
> worked.
>
> I need to implement the following flow using Click.
>
> q :: Queue(10)
>
> FromDevice(eth0) -> ip_classifier :: IPClassifier(condA, condB, -);
>
> ip_classifier[0] -> Set some flag (say F) -> Discard;
> ip_classifier[1] -> Reset F -> Discard;
> ip_classifier[2] -> if F set then -> q -> ToDevice(eth0) else -> q;
>
> Basically, what I want to do is, if the router receives an IP packet
> matching condA, it sets a flag, and if it receives an IP packet matching
> condB, the router resets the flag. For all other IP packets, the router
> first checks the flag and if its set, the packet is sent to a Queue and then
> sent out from the ethernet card. If the flag is not set, then packet is
> queued. In simple terms, the router queues packets till a flag is set. The
> moment the flag is set, the packets that were queued earlier needs to be
> sent out.
>
> Can someone please help me to write a click script to get this done? I have
> looked at the Script element that can handle conditional flows, but I
> couldn’t yet figure out how to use Script to implement my requirement.
>
> Thanks in advance.
>
> -Nimantha
>
>
>
>
>
> --
>
> Nimantha Baranasuriya
> Web: http://www.nimantha.info
> Blog: http://www.nimantha.info/blog
>
> Photography: http://www.nimantha.info/photoblog;
> http://www.flickr.com/photos/nimanthab
>
>



--
Nimantha Baranasuriya
Web: http://www.nimantha.info
Blog: http://www.nimantha.info/blog
Photography: http://www.nimantha.info/photoblog; 
http://www.flickr.com/photos/nimanthab

Re: [click] Conditional Flow in Click

From:
Nimantha Baranasuriya
Date:
2015-03-14 @ 04:13
Thanks for the feedback everyone. I'll try your suggestions.

Lars, yes, the last ip_classifier line contains a typo. I meant to write
ip_classifier[3].

Cheers,
Nimantha

On Wed, Mar 11, 2015 at 6:30 PM, Bro, Lars <lars.bro@siemens.com> wrote:

>  Hi Nimantha,
>
>
>
> Does this work as expected?
>
>
>
> TimedSource(INTERVAL 2)  -> rrs::RoundRobinSwitch();
>
> rrs[0]->Script(TYPE PACKET, write u.active 0);
>
> rrs[1]->Script(TYPE PACKET, write u.active 1);
>
>
>
> RatedSource() -> u::Unqueue() -> Print() -> Discard();
>
>
>
> It should report traffic in two seconds intervals. It works for me both in
> user and kernel mode.
>
>
>
> I don’t think you meant this:
>
> ip_classifier[0] -> f -> u -> sq -> ToDevice(eth0)
>
> It is second time you use ip_classifier[0], and it is a push output,
>
>
>
>
>
> Yours,
>
> Lars Bro
>
> *From:* click@librelist.com [mailto:click@librelist.com] *On Behalf Of *Nimantha
> Baranasuriya
> *Sent:* 10. marts 2015 15:00
> *To:* click@librelist.com
> *Subject:* Re: [click] Conditional Flow in Click
>
>
>
> Hi Bro and Eddie,
>
>
>
> Thanks a lot for your feedback. I managed to get the router implemented
> using the pointers you guys gave. I managed to implement an alternative
> solution by reading the Click documentation as well. I have two questions
> based on that, which I hope you all will be able to help me out.
>
>
>
> u :: Unqueue
>
> f :: FrontDropQueue
>
> sq :: Queue
>
>
>
> ip_classifier[0] -> Script(TYPE PACKET, write u.active 0) -> Discard;
>
> ip_classifier[1] -> Script(TYPE PACKET, write u.active 1) -> Discard;
>
> ip_classifier[0] -> f -> u -> sq -> ToDevice(eth0)
>
>
>
> 1) This one works fine too in the user mode. But, when I run this in the
> kernel mode (by using click-install), the switching part does not work,
> i.e., the u element is always active. How can this be fixed so tha the
> implementation works as expected in the kernel mo de too?
>
>
>
> 2) Is there a way to do benchmarking in Click? I need to find the time
> period that a packet sat in the router's queue until it was sent out.
>
>
>
> Thanks in advance,
>
> Nimantha
>
>
>
> On Tue, Mar 3, 2015 at 1:43 AM, Eddie Kohler <kohler@seas.harvard.edu>
> wrote:
>
> Yes! Although there were a couple syntax errors.
>
> Even easier to understand, perhaps, would be:
>
> ip_classifier[0] -> Script(TYPE PACKET, write sw.switch 0) -> ...
> ip_classifier[1] -> Script(TYPE PACKET, write sw.switch -1) -> ...
> ip_classifier[2] -> sw::Switch -> ...
>
>
>
> On Mon, Mar 2, 2015 at 3:52 AM, Bro, Lars <lars.bro@siemens.com> wrote:
> > Hi Nimantha,
> >
> >
> >
> > I agree that the Script element is a bit tricky, but maybe you can do
> > something like this:
> >
> >
> >
> > s::Script(
> >
> >   TYPE PACKET,
> >
> >   Write sw::switch $(if $(eq $input 0) 0 -1)
> >
> > )
> >
> >
> >
> > ip_classifier[0] -> 0[s]
> >
> > ip_classifier[1] -> 1[s]
> >
> >
> >
> > ip_classifier[2] -> sw::Switch() -> Queue …
> >
> >
> >
> > If the Script element is of type PACKET, the script will run for each
> > incoming packet and $input is the input port from which the packet came.
> The
> > $(if …) statement returns 0 if the packet came from input 0 or -1 if the
> > packet came from another input (1).  You can write to the “switch”
> handler
> > of a switch element the output that you want the switch to point to or
> “-1”
> > which means no outputs, but discard instead. So, writing “0” to sw.switch
> > closes the switch (makes packets pass through) and writing “-1” to the
> > switch opens it (blocks packets)
> >
> >
> >
> >
> >
> > Yours,
> >
> > Lars Bro
> >
> >
> >
> > From: click@librelist.com [mailto:click@librelist.com] On Behalf Of
> Nimantha
> > Baranasuriya
> > Sent: 28. februar 2015 13:57
> > To: click@librelist.com
> > Subject: [click] Conditional Flow in Click
> >
> >
> >
> > Hi everyone,
> >
> >
> > I am a Click newbie and I followed some example click scripts and read
> the
> > documentation on the Click website to get familiarized with how Click
> > worked.
> >
> > I need to implement the following flow using Click.
> >
> > q :: Queue(10)
> >
> > FromDevice(eth0) -> ip_classifier :: IPClassifier(condA, condB, -);
> >
> > ip_classifier[0] -> Set some flag (say F) -> Discard;
> > ip_classifier[1] -> Reset F -> Discard;
> > ip_classifier[2] -> if F set then -> q -> ToDevice(eth0) else -> q;
> >
> > Basically, what I want to do is, if the router receives an IP packet
> > matching condA, it sets a flag, and if it receives an IP packet matching
> > condB, the router resets the flag. For all other IP packets, the router
> > first checks the flag and if its set, the packet is sent to a Queue and
> then
> > sent out from the ethernet card. If the flag is not set, then packet is
> > queued. In simple terms, the router queues packets till a flag is set.
> The
> > moment the flag is set, the packets that were queued earlier needs to be
> > sent out.
> >
> > Can someone please help me to write a click script to get this done? I
> have
> > looked at the Script element that can handle conditional flows, but I
> > couldn’t yet figure out how to use Script to implement my requirement.
> >
> > Thanks in advance.
> >
> > -Nimantha
> >
> >
> >
> >
> >
> > --
> >
> > Nimantha Baranasuriya
> > Web: http://www.nimantha.info
> > Blog: http://www.nimantha.info/blog
> >
> > Photography: http://www.nimantha.info/photoblog;
> > http://www.flickr.com/photos/nimanthab
> >
> >
>
>
>
>
> --
>
> Nimantha Baranasuriya
> Web: http://www.nimantha.info
> Blog: http://www.nimantha.info/blog
>
> Photography: http://www.nimantha.info/photoblog;
> http://www.flickr.com/photos/nimanthab
>
>
>



-- 
Nimantha Baranasuriya
Web: http://www.nimantha.info
Blog: http://www.nimantha.info/blog
Photography: http://www.nimantha.info/photoblog;
http://www.flickr.com/photos/nimanthab