iota
Collaboration between LASS community and Distributed Ledger Labortory, National Cheng Kung University, Taiwan
Please contact <jserv@ccns.ncku.edu.tw>
for further information.
Overview: LASS_and_IOTA_Integration.pdf
Tutorial: IOTA/TangleID + 空氣盒子教學
Field | Description | Values |
---|---|---|
ver_format | MQTT record format version | 3 (default) |
FAKE_GPS | GPS presence | 0 (GPS available), 1 (no GPS) |
app | app name | |
ver_app | LASS version | |
device_id | unique | |
gps_lon | longitude | |
gps_lat | latitude |
body
Huffman coding
http://cseweb.ucsd.edu/~kube/cls/100/Lectures/lec8/lec8-15.html
0. Determine the count of each symbol in the input message.
1. Create a forest of single-node trees. Each node in the initial forest represents a symbol from the set of possible symbols, and contains the count of that symbol in the message to be coded. Symbols with a count of zero are ignored (consider them to be impossible).
2. Loop while there is more than 1 tree in the forest:
2a. Remove the two trees from the forest that have the lowest count contained in their roots.
2b. Create a new node that will be the root of a new tree. This new tree will have those two trees just removed in step 2a as left and right subtrees. The count in the root of this new tree will be the sum of the counts in the roots of its subtrees. Label the edge from this new root to its left subtree “1”, and label the edge to its right subtree “0”.
2c. Insert this new tree in the forest, and go to 2.
3. Return the one tree in the forest as the Huffman code tree.
result
compressed / uncompressed size | uncompressed / compressed size | |
---|---|---|
Theoretical value | 12.94 % | 7.73 |
Experimental value | 9.784 % | 10.02 |
-50 1110101010110111001
-49 1110101010110001111
-48 1110101010110101101
-47 1110101010110111000
-46 1110101010110110000
-45 1110101010110001100
-44 1110101010110011000
-43 1110101010110111101
-42 1110101010110100101
-41 1110101010110100010
-40 1110101010110010000
-39 1110101010110010111
-38 1110101010110011001
-37 1110101010110101100
-36 1110101010110010110
-35 1110101010110111111
-34 1110101010110111100
-33 1110101010110011111
-32 1110101010110101111
-31 1110101010110110100
-30 1110101010110110101
-29 1110101010110110111
-28 1110101010110010011
-27 1110101010110101011
-26 1110101010110001001
-25 1110101010110100001
-24 1110101010110100000
-23 1110101010110100110
-22 1110101010110000011
-21 1110101010110000010
-20 1110101010110010100
-19 111010101011111110
-18 1110101010110000000
-17 1110101010111000000
-16 111010101011111101
-15 111010101011111100
-14 111010101011111010
-13 111010101011100111
-12 111010101011100110
-11 111010101011100100
-10 111010101011100010
-9 111010101011101
-8 1110101010101
-7 1110101011
-6 111010100
-5 1110100
-4 1111
-3 0101
-2 110
-1 001
0 10
1 000
2 011
3 0100
4 11100
5 111011
6 11101011
7 11101010100
8 1110101010100
9 111010101011110
10 111010101011100001
11 111010101011100011
12 111010101011100101
13 111010101011111000
14 111010101011111001
15 111010101011111011
16 1110101010110110010
17 1110101010110110011
18 1110101010111000001
19 1110101010110000001
20 111010101011111111
21 1110101010110010101
22 1110101010110011010
23 1110101010110011011
24 1110101010110100111
25 1110101010110001000
26 1110101010110101010
27 1110101010110010010
28 1110101010110101110
29 1110101010110001010
30 1110101010110110001
31 1110101010110011100
32 1110101010110100100
33 1110101010110010001
34 1110101010110000111
35 1110101010110011110
36 1110101010110111110
37 1110101010110100011
38 1110101010110110110
39 1110101010110000110
40 1110101010110101001
41 1110101010110000101
42 1110101010110001101
43 1110101010110011101
44 1110101010110101000
45 1110101010110111011
46 1110101010110001011
47 1110101010110111010
48 1110101010110000100
49 1110101010110001110
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
new_claim
Make a HTTP request
POST /tangleid_backend/api/ HTTP/1.1
Host: 140.116.82.61
Content-Type: application/json
Content-Length: 185
{"command":"new_claim","uuid": "LASSBBMBOBABKBCBWAAB","part_a":"LASSBBMBOBABKBCBWAAB","part_b":"LASSBBMBOBABKBCBWAAB","exp_date":"","claim_pic":"","msg":"3|1|PM25|live|8CE7A927|120.971042|24.801909|Wn6jsKnVQAFuqqgALdVVCtVVSRVVU"}
(WIP)
$ cat Makefile
all:
g++ main.cpp encode.h -o main
test_one:
@./main
@python3 decode.py
diff test_input.txt test_output.txt
test:
for i in `seq 1 1 1000`; \
do \
make test_one ; \
done
$ make test
for i in `seq 1 1 1000`; \
do \
make test_one ; \
done
make[1]: Entering directory '/home/bevis/IOTA_LASS'
diff test_input.txt test_output.txt
make[1]: Leaving directory '/home/bevis/IOTA_LASS'
make[1]: Entering directory '/home/bevis/IOTA_LASS'
diff test_input.txt test_output.txt
make[1]: Leaving directory '/home/bevis/IOTA_LASS'
make[1]: Entering directory '/home/bevis/IOTA_LASS'
diff test_input.txt test_output.txt
...
(WIP)
$ python3 IOTAxLASS.py BBMBOBABKBCBWAAB
{
"device_id": "8CE7A927",
"s_t0": "24",
"app": "PM25",
"FAKE_GPS": "1",
"s_d0": "32",
"s_d1": "36",
"ver_format": "3",
"s_h0": "67",
"gps_lon": "120.971042",
"ver_app": "live",
"timestamp": "2018-02-02 16:31:11",
"gps_lat": "24.801909"
}
{
"device_id": "8CE7A927",
"s_t0": "24",
"app": "PM25",
"FAKE_GPS": "1",
"s_d0": "31",
"s_d1": "32",
"ver_format": "3",
"s_h0": "66",
"gps_lon": "120.971042",
"ver_app": "live",
"timestamp": "2018-02-02 16:32:11",
"gps_lat": "24.801909"
}
{
"device_id": "8CE7A927",
"s_t0": "24",
"app": "PM25",
"FAKE_GPS": "1",
"s_d0": "32",
"s_d1": "35",
"ver_format": "3",
"s_h0": "66",
"gps_lon": "120.971042",
"ver_app": "live",
"timestamp": "2018-02-02 16:33:11",
"gps_lat": "24.801909"
}
{
"device_id": "8CE7A927",
"s_t0": "24",
"app": "PM25",
"FAKE_GPS": "1",
"s_d0": "31",
"s_d1": "34",
"ver_format": "3",
"s_h0": "67",
"gps_lon": "120.971042",
"ver_app": "live",
"timestamp": "2018-02-02 16:34:11",
"gps_lat": "24.801909"
}
{
"device_id": "8CE7A927",
"s_t0": "24",
"app": "PM25",
"FAKE_GPS": "1",
"s_d0": "32",
"s_d1": "35",
"ver_format": "3",
"s_h0": "67",
"gps_lon": "120.971042",
"ver_app": "live",
"timestamp": "2018-02-02 16:35:12",
"gps_lat": "24.801909"
}
...
2187 trytes
original : < 700 trytes
compressed (avg): 158 trytes
compressed (worst): <400 trytes