Code Monkey home page Code Monkey logo

Comments (8)

tbarbette avatar tbarbette commented on August 23, 2024

Don't spawn thread in Click. Use a Click thread by assigning some element with StaticThreadSched.

It seems what you want to do is to change the configuration of UDPIP6ENCAP every second. I would suggest making a script element like that :

s :: Script( TYPE ACTIVE,
label loop,
wait 1s,
set ip udpencap.saddr,
write udpencap.saddr $(add $ip 1),
goto loop);
StaticThreadSched(s 2);
Assuming the element has an saddr read/write handler. Maybe easier, just create a handler named "inc_saddr" that will add 1 to the IP address. I'm not sure of the behavior of the code above because of endianess. Then you can call "write udpencap.inc_saddr" to simply call the handler.

Tom

from fastclick.

kthkaya avatar kthkaya commented on August 23, 2024

Thanks for the response Tom.

It seems what you want to do is to change the configuration of UDPIP6ENCAP every second

It will be less than a second. If 1000 unique flows per second is requested, the config needs to change every milisecond. The change has to happen at microseconds if more than 1000 unique flows are requested.

The Script element wiki states that the wait argument has microseconds precision, but can it accept 0.001s or less?

Maybe easier, just create a handler named "inc_saddr" that will add 1 to the IP address

Yep, I will follow this approach if the Script element can wait for mili or microseconds.

from fastclick.

tbarbette avatar tbarbette commented on August 23, 2024

Milli yes, micro no. But you may create a "cron" element that is more efficient at poking some handler

from fastclick.

bcronje avatar bcronje commented on August 23, 2024

It might just be quicker/easier to extend UDPIP6Encap. Just use a Click timer to increment the address. Or if very high fps rate is required, use a tokenbucket with Click Task, see RatedSource or similar element on how to implement this.

from fastclick.

tbarbette avatar tbarbette commented on August 23, 2024

True, but I don't like elements being extended/duplicated for every feature. I think if "it" can be done with a combination of element, it's the best path.

from fastclick.

kthkaya avatar kthkaya commented on August 23, 2024

Thanks for the input guys!

from fastclick.

kthkaya avatar kthkaya commented on August 23, 2024

So here is how the code looks like

/------------Declarations-----------

//+++++DPDK0 Interface(Inside)+++++
DPDK0_OUT ::  ToDPDKDevice(0);

//+++++DPDK1 Interface(Outside)+++++
DPDK1_IN :: FromDPDKDevice(1, PROMISC true);

udpEncap :: UDPIP6Encap(2001:2001:2001:2001::1, 1234, 64:ff9b::192.168.2.5, 1234)

//--------Program Start----------
InfiniteSource(LENGTH 64, LIMIT 1500000, STOP true)
        -> NumberPacket(OFFSET 0)
	-> udpEncap
        -> EtherEncap(0x86DD, 00:04:23:D0:93:63, 00:17:cb:0d:f8:db)
        -> record :: RecordTimestamp()
        -> DPDK0_OUT;

s :: Script( TYPE ACTIVE,
	label loop,
	wait 1s,
	set ip udpEncap.src,
	write udpEncap.src $(add $ip 1),
	goto loop );

StaticThreadSched(s 2);

DPDK1_IN
        -> CheckNumberPacket(OFFSET 62, COUNT 1500000)
        -> diff :: TimestampDiff(OFFSET 62, RECORDER record)
        -> counter :: AverageCounter()
        -> Discard;
//--------Program End----------

DriverManager(wait,read diff.average, read counter.count, read counter.rate)

I get the following warning

While executing 's :: Script':
expected list of numbers

I guess add is not liking an IPv6 address as an int as it is 16 bytes?

from fastclick.

kthkaya avatar kthkaya commented on August 23, 2024

Maybe easier, just create a handler named "inc_saddr" that will add 1 to the IP address.

Ended up following this advice and it works. Thanks!

from fastclick.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.