Community discussions

MikroTik App
 
abvintranet
just joined
Topic Author
Posts: 10
Joined: Sat Oct 03, 2009 5:50 pm

The Dude math functions

Fri Dec 29, 2023 5:32 pm

Hello. I need to convert an SFP DDM signal from mW to dBm. This requires the following formula:
10*log10(mW)=dBm
A simple comparison using if works, but puts a load on the switch, and works intermittently if used for all ports.

Maybe someone solved a similar problem?
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3509
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: The Dude math functions

Fri Dec 29, 2023 5:50 pm

I haven't, but there is no log function AFAIK.

Another idea, not simple... but you can create an array with the dBm values inside, then use use array_element with the mW (or some multiple of mW) to fetch the pre-converted dBm value. Essentially a lookup table, using array()/array_element()functions.

e.g.
mW to dBm conversion table
Power (mW)	Power (dBm)
0+ mW	-∞ dBm
0.01 mW	-20 dBm
0.1 mW	-10 dBm
1 mW	0 dBm
2 mW	3.0103 dBm
3 mW	4.7712 dBm
4 mW	6.0206 dBm
5 mW	6.9897 dBm
6 mW	7.7815 dBm
7 mW	8.4510 dBm
8 mW	9.0309 dBm
 9 mW	9.5424 dBm
10 mW	10 dBm
100 mW	20 dBm
1000 mW	30 dBm
10000 mW	40 dBm
 100000 mW	50 dBm
 1000000 mW	60 dBm
 10000000 mW	70 dBm
100000000 mW	80 dBm
1000000000 mW	90 dBm
 10000000000 mW	100 dBm
 
abvintranet
just joined
Topic Author
Posts: 10
Joined: Sat Oct 03, 2009 5:50 pm

Re: The Dude math functions

Wed Jan 03, 2024 2:37 am

I decided to do it a little differently. With Raspberry (Orange Pi).
If I use it as a probe, everything is ok, no problems. But if I add it to the link label, Dude sends 324 requests/port per each update!!!.
?!?!?!
I have 1 switch x8 ports and 5 switches x24 ports.

Link label code:
[snmp_wireless_link_info()]Rx: [Interface.InBitRate][snmp_wireless_link_rx_rate()]
Tx: [Interface.OutBitRate][snmp_wireless_link_tx_rate()]
[if(string_find(device_property("FirstAddress"),"192.168.3.235")=0,sfp_ddm_link_rx_rate(),"")]
sfp_ddm_link_rx_rate() code:

if(
string_find(link_index(),"49153")=0,
if(
string_size(oid(concatenate("1.3.6.1.4.1.11863.6.96.1.7.1.1.6.","[Interface.Index]"), 300, 600))>4,
oid("1.3.6.1.4.1.8072.1.3.2.4.1.2.4.116.119.109.49.1",5,300,"192.168.3.233"),
""),
"")

Update interval is set for 5 sec.
And if I add code for all ports and switches, Dude sends 500,000 requests per minute......

Who is online

Users browsing this forum: No registered users and 2 guests