Developing lightweight computation at the DSG edge
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Quick Mesh Project
qMp packages
Commits
074b4988
Commit
074b4988
authored
Nov 15, 2011
by
p4u
Browse files
New feature Bandwidth test in tools tab of web interface
parent
457f3f4d
Changes
11
Hide whitespace changes
Inline
Side-by-side
packages/bmx6-luci/files/usr/lib/lua/luci/view/bmx6/neighbours.htm
View file @
074b4988
...
...
@@ -74,7 +74,7 @@
<
%
for
i
,
o
in
ipairs
(
originators
)
do
%
>
<tr>
<td><
%=
o.name
%
></td>
<td>
<td
style=
"text-align:left;"
>
<
%
if
o.desc.DESC_ADV
~=
nil
then
%
>
<
%
for
j
,
h
in
ipairs
(
o.desc.DESC_ADV.extensions
[2].
HNA6_EXTENSION
)
do
%
>
<
%=
h.address
%
>
...
...
packages/qmp-small-node/files/etc/config/qmp
View file @
074b4988
...
...
@@ -41,6 +41,7 @@ config 'qmp' 'networks'
option 'babel_mesh_prefix48' 'fd03:0:0'
option 'netserver' '1'
config 'qmp' 'tunnels'
option 'search_ipv4_tunnel' '0.0.0.0/0'
...
...
packages/qmp-small-node/files/etc/init.d/qmp_autoconf
View file @
074b4988
...
...
@@ -46,16 +46,20 @@ configure() {
ifup
-a
/etc/init.d/dnsmasq restart
touch
"
$CONTROL_FILE
"
# echo "Done, rebooting system to complete configuration"
# reboot
}
#This function is executed in each boot
startup
()
{
$QMP_DIR
/qmp_control.sh apply_netserver
}
start
()
{
if
[
!
-f
"
$CONTROL_FILE
"
]
;
then
configure
else
echo
"QMP configured. Remove
$CONTROL_FILE
to force reconfiguration"
fi
startup
if
[
!
-f
"
$CONTROL_FILE
"
]
;
then
configure
else
echo
"QMP configured. Remove
$CONTROL_FILE
to force reconfiguration"
fi
}
stop
()
{
...
...
packages/qmp-small-node/files/etc/qmp/qmp_control.sh
View file @
074b4988
...
...
@@ -23,6 +23,7 @@ QMP_PATH="/etc/qmp"
.
$QMP_PATH
/qmp_functions.sh
.
$QMP_PATH
/qmp_gw.sh
.
$QMP_PATH
/qmp_wireless.sh
.
$QMP_PATH
/qmp_network.sh
offer_default_gw
()
{
qmp_gw_offer_default
...
...
@@ -50,6 +51,10 @@ apply_network() {
/etc/init.d/firewall restart
}
apply_netserver
()
{
[
"
$(
qmp_uci_get networks.netserver
)
"
==
"1"
]
&&
qmp_enable_netserver
||
qmp_disable_netserver
}
help
()
{
echo
"Use:
$0
<function> [params]"
echo
""
...
...
@@ -58,6 +63,7 @@ help() {
echo
" search_default_gw : Search for a default gw in the network"
echo
" apply_wifi : Apply current wifi configuration"
echo
" apply_network : Apply current network configuration"
echo
" apply_netserver : Start/stop nerserver depending on qmp configuration"
echo
""
}
...
...
packages/qmp-small-node/files/etc/qmp/qmp_network.sh
0 → 100644
View file @
074b4988
# Copyright (C) 2011 Fundacio Privada per a la Xarxa Oberta, Lliure i Neutral guifi.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# The full GNU General Public License is included in this distribution in
# the file called "COPYING".
##############################
# Global variable definition
##############################
QMP_PATH
=
"/etc/qmp"
TMP
=
"/tmp"
QMPINFO
=
"/etc/qmp/qmpinfo"
#######################
# Importing files
######################
SOURCE_NET
=
1
[
-z
"
$SOURCE_COMMON
"
]
&&
.
$QMP_PATH
/qmp_common.sh
qmp_enable_netserver
()
{
qmp_uci_set networks.netserver 1
killall
-9
netserver
netserver
-6
-p
12865
}
qmp_disable_netserver
()
{
qmp_uci_set networks.netserver 0
killall
-9
netserver
}
packages/qmp-small-node/files/etc/qmp/qmpinfo
View file @
074b4988
...
...
@@ -32,6 +32,8 @@ function print_help()
print
(
" channels <dev> : supported channels and supported HT40 type (+/-) "
)
print
(
" ipv4 : print all ipv4 from this computer (excluding localhost)"
)
print
(
" hostname : print device hostname"
)
print
(
" bwtest <ipv6> : perform a bandwidth test"
)
print
(
" nodes : list all nodes on MESH network"
)
print
(
""
)
end
...
...
@@ -48,7 +50,7 @@ end
function
print_channels
()
local
partial
local
output
=
""
local
data
=
qmp
.
get_channels
(
dev
)
local
data
=
qmp
.
get_channels
(
op1
)
for
_
,
d
in
ipairs
(
data
)
do
output
=
d
.
channel
if
d
.
ht40p
then
output
=
output
..
" ht40+"
end
...
...
@@ -59,7 +61,7 @@ function print_channels()
end
function
print_txpower
()
local
data
=
qmp
.
get_txpower
(
dev
)
local
data
=
qmp
.
get_txpower
(
op1
)
for
_
,
v
in
ipairs
(
data
)
do
print
(
v
)
end
...
...
@@ -76,13 +78,35 @@ function print_hostname()
print
(
qmp
.
get_hostname
())
end
function
bw_test
()
if
#
op1
<
5
then
print_help
()
os.exit
(
1
)
end
local
bwt
=
qmpinfo
.
bandwidth_test
(
op1
)
if
bwt
==
nil
then
print
(
"Cannot connecto to "
..
op1
..
" netserver"
)
else
print
(
"Bandwidth: "
..
bwt
..
" Mbit/s"
)
end
end
function
nodes
()
for
_
,
n
in
ipairs
(
qmpinfo
.
nodes
())
do
if
#
n
==
2
then
print
(
n
[
1
]
..
" "
..
n
[
2
])
end
end
end
if
#
arg
<
1
then
print_help
()
os.exit
(
1
)
end
local
question
=
arg
[
1
]
dev
=
arg
[
2
]
op1
=
arg
[
2
]
if
question
==
"modes"
then
print_modes
()
...
...
@@ -94,6 +118,10 @@ elseif question == "ipv4" then
print_ipv4
()
elseif
question
==
"hostname"
then
print_hostname
()
elseif
question
==
"bwtest"
then
bw_test
()
elseif
question
==
"nodes"
then
nodes
()
else
print_help
()
end
...
...
packages/qmp-small-node/files/etc/qmp/qmpinfo.lua
View file @
074b4988
...
...
@@ -149,4 +149,28 @@ function qmpinfo.get_uname()
return
uname
end
function
qmpinfo
.
bandwidth_test
(
ip
)
local
bwtest
=
util
.
trim
(
util
.
exec
(
"netperf -6 -p 12865 -H "
..
ip
..
" -fm -v0 -P0"
))
local
result
=
nil
if
#
bwtest
<
10
then
result
=
bwtest
end
return
result
end
function
qmpinfo
.
nodes
()
local
nodes
=
util
.
split
(
util
.
exec
(
'bmx6 -c --originators | awk \'
{
print
$
1
"|"
$
3
}
\
' | grep -e ".*:.*:"'
))
local
ni
result
=
{}
for
_
,
n
in
ipairs
(
nodes
)
do
if
n
~=
""
then
ni
=
util
.
split
(
n
,
"|"
)
ni
[
1
]
=
util
.
split
(
ni
[
1
],
"."
)[
1
]
table.insert
(
result
,
ni
)
end
end
return
result
end
return
qmpinfo
packages/qmp-small-node/files/usr/bin/qmpinfo
0 → 120000
View file @
074b4988
/etc/qmp/qmpinfo
\ No newline at end of file
packages/qmp-small-node/files/usr/lib/lua/luci/controller/qmp.lua
View file @
074b4988
...
...
@@ -39,6 +39,7 @@ function index()
entry
({
"qmp"
,
"network"
},
cbi
(
"qmp/config"
),
"Network"
,
5
).
dependent
=
false
entry
({
"qmp"
,
"wireless"
},
cbi
(
"qmp/wireless"
),
"Wireless"
,
6
).
dependent
=
false
entry
({
"qmp"
,
"splash"
},
call
(
"action_splash"
),
"Splash"
,
7
).
dependent
=
false
entry
({
"qmp"
,
"tools"
},
call
(
"action_tools"
),
"Tools"
,
8
).
dependent
=
false
end
function
action_status
()
...
...
@@ -51,6 +52,13 @@ function action_status()
luci
.
template
.
render
(
"qmp/overview"
,{
ipv4
=
ipv4
,
hostname
=
hostname
,
uname
=
uname
})
end
function
action_tools
()
package.path
=
package.path
..
";/etc/qmp/?.lua"
local
qmp
=
require
"qmpinfo"
local
nodes
=
qmp
.
nodes
()
luci
.
template
.
render
(
"qmp/tools"
,{
nodes
=
nodes
})
end
function
action_splash
()
luci
.
template
.
render
(
"qmp/splash"
)
end
packages/qmp-small-node/files/usr/lib/lua/luci/view/qmp/tools.htm
0 → 100644
View file @
074b4988
<
%+
header
%
>
<script
type=
"text/javascript"
>
function
do_bwtest
(
ip
,
index
)
{
var
output
=
document
.
getElementById
(
'
output_
'
+
index
);
if
(
output
)
{
output
.
innerHTML
=
'
<%:Collecting data...%><img src="/luci-static/resources/icons/loading.gif" height="20px" alt="Loading" style="vertical-align:middle"/>
'
;
output
.
style
.
display
=
'
inline
'
;
var
result
=
new
XMLHttpRequest
();
result
.
open
(
"
GET
"
,
"
/cgi-bin/bwtest?
"
+
ip
,
true
);
result
.
onreadystatechange
=
function
()
{
if
(
result
.
readyState
==
4
)
{
output
.
innerHTML
=
parse_result
(
result
.
responseText
);
}
}
result
.
send
(
null
);
}
}
function
parse_result
(
txt
)
{
var
t
=
new
String
(
txt
);
if
(
t
.
indexOf
(
"
Cannot
"
)
>=
0
)
return
(
"
<font color='#f00'><%:Cannot connecto to netserver%></font>
"
);
else
return
(
"
<font color='#0a0'>
"
+
txt
+
"
</font>
"
);
}
</script>
<h2>
Bandwidth test
</h2>
<p><strong>
Nodes found in the network:
</strong></p>
<form>
<
%
for
i
,
n
in
ipairs
(
nodes
)
do
%
>
<div
style=
"height:30px;width:550px;float:left"
>
<input
type=
"button"
value=
"<%=n[1]%>"
onclick=
"do_bwtest('<%=n[2]%>',<%=i%>)"
/>
<
%=
n
[2]%
>
<span
style=
"display:none;margin-left:5px;border:1px solid #000;padding:0.1em 0.4em"
id=
"output_<%=i%>"
></span>
</div>
<
%
end
%
>
<div
style=
"clear:both;height:30px;float:left"
>
<strong>
Specify Custom ip:
</strong>
<input
type=
"text"
name=
"custom"
/>
<input
type=
"button"
value=
"Start"
onclick=
'do_bwtest(this.form.custom.value,"custom")'
/>
<
%=
n
%
>
<span
style=
"display:none;margin-left:5px;border:1px solid #000;padding:0.1em 0.4em"
id=
"output_custom"
></span>
</div>
</form>
<
%+
footer
%
>
packages/qmp-small-node/files/www/cgi-bin/bwtest
0 → 100755
View file @
074b4988
#!/bin/sh
echo
"content-type: text/plain"
echo
""
#TODO: Securize Query
QUERY
=
"
$QUERY_STRING
"
[
!
-z
"
$QUERY
"
]
&&
{
/etc/qmp/qmpinfo bwtest
$QUERY
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment