CoAP o e Bundle P o ocol
Bachelo ’s Deg ee Thesis
Submi ed o he Facul y a he
Escola Tècnica Supe io
d'Enginye ia de Telecomunicació de Ba celona
de la Uni e si a Poli ècnica de Ca alunya
by
Max Lampu lanés Rosell
In pa ial ul illmen
o he equi emen s o he
DEGREE IN TELECOMUNICATION TECHNOLOGIES AND SERVICES ENGINEERING
Ad iso : Anna Cal e as Augé
Ba celona, Janua y 2025
ETSETB – Deg ee in Telecomunica ion Technologies and Se ices Enginee ing
-2-
-3-
Summa y
Resum______________________________
Aques eball ac a sob e l’es udi d’una implemen ació de la capa d’aplicació CoAP
sob e la capa Bundle en una a qui ec u a de xa xa basada en DTN. Els objec ius del
p ojec e són la co ec a ansmissió de paque s CoAP a a és de una xa xa DTN amb
memò ia pe sis en .
S’ha eali za un es udi p àc ic d’una implemen ació de la capa de ni ell d’aplicació
CoAP sob e la capa Bundle c ean una capa in e mèdia pe la se a co ec a in e acció.
El desen olupamen d’aques a capa in e mèdia és la g an pa del p ojec e. Pe la
eali zació d’aques es udi s’han u ili za les llib e ies aiocoap i µd3 n, i el llengua ge
de p og amació Py hon.
____________________________Resumen
Es e abajo a a sob e el es udio de una implemen ación de la capa de aplicación
CoAP sob e la capa Bundle en una a qui ec u a de ed basada en DTN. Los obje i os
del p oyec o son la co ec a ansmisión de paque es CoAP a a és de una ed DTN
con memo ia pe sis en e.
Se ha ealizado un es udio p ác ico de una implemen ación de la capa de ni el
aplicación CoAP sob e la capa Bundle c eando una capa in e media pa a su co ec a
in e acción. El desa ollo de es a capa in e media es la g an pa e del p oyec o. Pa a
la ealización de es e es udio se han usado las lib e ías aiocoap y µd3 n, y el lenguaje
de p og amación Py hon.
-4-
Summa y____________________________
This wo k ocuses on he s udy and implemen a ion o he CoAP applica ion laye o e
he Bundle laye in a ne wo k a chi ec u e based on DTN. The objec i es o he p ojec
a e he co ec ansmission o CoAP packe s h ough a DTN ne wo k wi h pe sis en
s o age.
A p ac ical s udy was conduc ed on implemen ing he CoAP applica ion laye o e he
Bundle laye by c ea ing an in e media e laye o ensu e p ope in e ac ion.
De eloping his in e media e laye cons i u es a signi ican pa o he p ojec . Fo his
s udy, he aiocoap and µd3 n lib a ies, along wi h he Py hon p og amming language,
we e used.
-5-
Acknowledgemen s
This wo k was unded in pa by he Spanish
MCIU/AEI/10.13039/501100011033/FEDER/UE h ough p ojec PID2023-146378NB-I00,
and by Sec e a ia d'Uni e si a s i Rece ca del depa amen d'Emp esa i Coneixemen de la
Gene ali a de Ca alunya wi h he g an numbe 2021 SGR 00330.
I wan o hank Anna Cal e as Augé o us ing me wi h his p ojec and assis ing me
du ing he p ocess.
-6-
Re ision his o y and app o al eco d
Re ision
Da e
Au ho (s)
Desc ip ion
1.0
20/12/2024
ML
Documen c ea ion
1.1
07/01/2025
ML, AC
E o co ec ion
2.0
17/01/2025
ML
Re ised a e e iew
3.0
19/01/2025
ML, AC
Final e sion
LLISTA DE DISTRIBUCIÓ DEL DOCUMENT
Role
Su name(s) and Name
S uden
Lampu lanés Rosell, Max (ML)
P ojec Supe iso
Cal e as Augé, Anna (AC)
W i en by:
Re iewed and app o ed by:
Da e
20/12/2024
Da e
19/01/2025
Name
Max Lampu lanés Rosell
Nome
Anna Cal e as Augé
Role
P ojec Au ho
Role
P ojec Supe iso
-7-
Con en s
Summa y .......................................................................................................................................................................... 3
Acknowledgemen s ..................................................................................................................................................... 5
Re ision his o y and app o al eco d ................................................................................................................. 6
Con en s ............................................................................................................................................................................ 7
Lis o Figu es ................................................................................................................................................................. 9
Lis o Tables ............................................................................................................................................................... 11
Abb e ia ions .............................................................................................................................................................. 12
1.1. Wo k goals ................................................................................................................................................ 14
1.2. Requi emen s and speci ica ions .................................................................................................... 15
1.3. Me hods and p ocedu es .................................................................................................................... 15
1.4. Wo k plan .................................................................................................................................................. 16
2. S a e o he a o he echnology used o applied in his hesis ................................................. 18
2.1. DTN .............................................................................................................................................................. 18
2.1.1. De ini ion and backg ound ...................................................................................................... 18
2.1.2. Co e concep s................................................................................................................................. 19
2.1.3. Applica ions example ................................................................................................................. 21
2.1.4. Challenges and Limi a ions...................................................................................................... 21
2.2. CoAP A chi ec u e ................................................................................................................................. 21
2.2.1. De ini ion and o e iew............................................................................................................ 21
2.2.2. Co e Fea u es ................................................................................................................................. 22
2.2.3. Applica ion examples ................................................................................................................. 24
2.3. Used so wa e and ools...................................................................................................................... 24
2.3.1. Py hon ............................................................................................................................................... 24
2.3.2. Wi esha k ........................................................................................................................................ 24
2.3.3. aiocoap .............................................................................................................................................. 25
2.3.4. µd3 n ................................................................................................................................................. 25
3. Me hodology / p ojec de elopmen ...................................................................................................... 27
3.1. DTN Ne wo k de elopmen .............................................................................................................. 27
Con en s
-8-
3.2. CoAP app de elopmen ....................................................................................................................... 30
3.3. AAP2.0 py hon applica ion ................................................................................................................ 33
4. Resul s .................................................................................................................................................................. 40
4.1. Expe imen s and Tes s ........................................................................................................................ 40
4.2. Da a Analysis ........................................................................................................................................... 41
4.2.1. Scena io 1: Two nodes µd3 n Ne wo k .............................................................................. 41
4.2.2. Scena io 2: CoAP aiocoap scena io ...................................................................................... 42
4.2.3. Scena io 3: De eloped encapsula ion/decapsula ion using AAP2.0 and aiocoap
44
4.2.4. Scena io 4: De eloped encapsula ion/decapsula ion using AAP2.0 and aiocoap
wi h pe sis en s o age ................................................................................................................................. 45
5. Sus ainabili y Analysis and E hical Implica ions ............................................................................... 47
5.1. Sus ainabili y Ma ix ............................................................................................................................ 47
5.1.1. En i onmen al impac ............................................................................................................... 47
5.1.2. Economic impac .......................................................................................................................... 48
5.1.3. Social impac .................................................................................................................................. 49
5.2. E hical implica ions .............................................................................................................................. 49
6.1 Conclusions ...................................................................................................................................................... 50
6.2 Fu u e Di ec ions .......................................................................................................................................... 50
Bibliog aphy ................................................................................................................................................................ 51
Appendix A ................................................................................................................................................................... 53
-9-
Lis o Figu es
Figu e 1: Wo k plan diag am. .............................................................................................................................. 16
Figu e 2: Wo k plan Gan diag am. .................................................................................................................. 17
Figu e 3: DTN ne wo k s ack in a he e ogenous ne wo k. Sou ce [8] ............................................... 20
Figu e 4: Componen s o a Bundle Node. Sou ce [10]. ............................................................................. 20
Figu e 5: Abs ac Laye ing o CoAP. Sou ce [13]. ...................................................................................... 22
Figu e 6: CoAP message o ma Sou ce [14] ................................................................................................. 22
Figu e 7: A GET eques wi h imed esponse. Sou ce [15].................................................................... 23
Figu e 8: A eques and esponse wi h NON. Sou ce [16]. ...................................................................... 23
Figu e 9: Wi esha k example ............................................................................................................................... 24
Figu e 10: The e ined a chi ec u e o he µD3TN de elopmen ee. Sou ce [19]. .................... 26
Figu e 11: Node A and Node B scheme ............................................................................................................ 27
Figu e 12: Compila ion o he µd3 n lib a y. ................................................................................................ 28
Figu e 13: Node A deploymen ............................................................................................................................ 28
Figu e 14: Node B deploymen ............................................................................................................................ 28
Figu e 15: Deploymen o he communica ion ............................................................................................. 29
Figu e 16: A achmen o he ecei e s in each node ................................................................................ 29
Figu e 17: Sending o a message om each node ....................................................................................... 29
Figu e 18: Recei ed messages in each node.................................................................................................. 29
Figu e 19: CoAP App scheme ............................................................................................................................... 30
Figu e 20: CoAP empe a u e se e esou ce ............................................................................................ 30
Figu e 21: CoAP se e s a code. .................................................................................................................... 31
Figu e 22: CoAP empe a u e clien .................................................................................................................. 32
Figu e 23: Resul s o he CoAP applica ion. ................................................................................................... 32
Figu e 24: Applica ion de eloped scheme. .................................................................................................... 33
Figu e 25: A chi ec u e s ack o de eloped applica ion. ......................................................................... 33
Figu e 26: Bundle wi h CoAP in he payload example. ............................................................................. 34
Figu e 27: Example o CoAP Message c ea ion, encoding and encapsula ion. ............................... 34
-16-
1.4. Wo k plan
The p ojec has been di ided in ou h wo k packages as seen in he ollowing diag am.
Figu e 1: Wo k plan diag am.
The wo k packages seen in Figu e 1 a e di ided in di e en asks, he e I will
summa ize hese asks:
• WP1: This wo k package ocuses on he esea ch o he exis en documen a ion,
and i has 4 di e en asks. Task 1 is CoAP esea ch, Task 2 is Bundle P o ocol
esea ch, Task 3 is esea ch o e he exis en documen a ion o CoAP o e
Bundle P o ocol, and he las one is Task 4 summa izing o he necessa y
in o ma ion.
• WP2: This wo k package ocuses on he de elopmen o he es bed o ansmi
CoAP messages o e Bundle P o ocol di ided in h ee asks. Task 1 is he
de elopmen o a DTN en i onmen , Task 2 is he de elopmen o a CoAP
applica ion and implemen a ion in he DTN Ne wo k, and Task 3 is o es he
de eloped applica ion.
• WP3: This wo k package ocuses on he expansion o numbe o nodes in he
DTN Ne wo k and he es s o di e en scena ios. I has wo asks, Task 1 he
expansion o nodes used in he DTN Ne wo k, and Task 2 is o analyses he
esul s o he implemen a ion and conside he inal esul s and conclusions.
• WP4: This is he wo k package ela ed wi h all he documen a ion o be
deli e ed. I has h ee asks, Task 1 is he w i ing and e ision o P ojec
-17-
P oposal and Wo k Plan, Task 2 is he w i ing and e ision o C i ical Re iew
documen , and Task 3 is w i ing and e ision o he TFG Final documen .
The wo k packages speci ied in Figu e 1 we e dis ibu ed as he p ojec au ho
es ima ed as seen in he ollowing ime diag am.
Figu e 2: Wo k plan Gan diag am.
The e ha e been no majo inciden s in he in ended planning o he p ojec , as he ime
o each wo k package included a ma gin o delays.
-18-
2. S a e o he a o he echnology used o applied in his hesis
____________________________________________________________ CHAPTER
2
S a e o he a o he echnology
This sec ion desc ibes he s a e o he a o he echnologies ela ed o he p ojec .
2.1. DTN
2.1.1. De ini ion and backg ound
DTN is a ne wo king a chi ec u e designed o add ess challenges in en i onmen s
whe e adi ional In e ne p o ocols ail due o la ge numbe o disconnec ions, long
p opaga ion delays and high e o a es. The basis o his a chi ec u e lies wi h ha
o he In e plane a y In e ne , which ocused p ima ily on he issue o deep space
communica ion in high-delay en i onmen s. O igina ing om esea ch in o
in e plane a y communica ions by NASA and DARPA in he ea ly 2000s, DTN was
o malized h ough he publica ion o RFC 4838, which de ined i s undamen al
a chi ec u e.
I is de ined as an end- o-end message-o ien ed o e lay called he "bundle laye " ha
exis s a a laye abo e he anspo (o o he ) laye s o he ne wo ks on which i is
hos ed, and below applica ions. De ices implemen ing he bundle laye a e called DTN
nodes. The bundle laye o ms an o e lay ha employs pe sis en s o age o help
comba ne wo k in e up ion. I includes a hop-by-hop ans e o eliable deli e y
esponsibili y and op ional end- o-end acknowledgemen . I also includes a numbe
o diagnos ic and managemen ea u es. Fo in e ope abili y, i uses a lexible naming
scheme (based on Uni o m Resou ce Iden i ie s (URI) explained in RFC3986 [7])
capable o encapsula ing di e en naming and add essing schemes in he same o e all
naming syn ax. I also has a basic secu i y model, op ionally enabled, aimed a
p o ec ing in as uc u e om unau ho ized use.
-19-
2.1.2. Co e concep s
DTN ha e some co e concep s ha a e impo an o unde s and how he a chi ec u e
wo ks, hose a e desc ibed below:
• Bundle P o ocol: A DTN-speci ic p o ocol ha encapsula es he da a in o
bundles ha a e he packages used o he DTN ne wo ks. These bundles a e
simila o packages used in adi ional ne wo ks bu op imized o delay
ole ance.
• Bundle P o ocol Agen (BPA): The BPA o a node is he node componen ha
o e s he BP se ices and execu es he p ocedu es o he BP.
• S o e-and- o wa d: Bundles a e s o ed in he in e media e nodes un il he nex
node becomes eachable. This is enabled wi h he Pe sis en S o age capabili y
o he nodes, ha ensu es ha he node has a Da a Base accessible o s o e he
Bundles.
• Cus ody T ans e : Ensu es eliable communica ion as so he esponsibili y o
ans e ing he bundle is deli e ed o in e media e nodes. Tha was p esen in
BP e sion 6 [8] bu no included in BP e sion 7.
• Endpoin Iden i ie s (EID): The EID a e he speci ic URI schemes o he nodes
o he DTNs ne wo ks. E e y node mus ha e an EID ha iden i ies i on he
ne wo k.
• Applica ion Da a Uni (ADU): The ADUs a e he applica ion laye packages
needed o he nodes o c ea e a bundle.
• AAP2.0: The applica ion agen o he node is he componen ha u ilizes he BP
se ices o e ec communica ions, o be mo e p ecise he AAP cons uc s,
accep s deli e ies, eques s ansmissions and p ocess ADUs.
• Con e gence-Laye Adap e (CLA): A CLA is a node componen ha sends and
ecei es bundles on behal o he BPA, u ilizing he se ices o some
"in eg a ed" p o ocol s ack ha is suppo ed in one o he ne wo ks wi hin
which he node is unc ionally loca ed.
Figu e 3 shows an example o DTN ne wo k s ack in a he e ogenous ne wo k. I is
impo an o men ion ha below he Bundle P o ocol laye he e exis a Con e gence
Laye Adap e (CLA). I is a c ucial componen ha ac s as an in e media y be ween
he Bundle Laye (which is esponsible o he co e unc ionali y o BP) and he
unde lying ne wo k laye . The Con e gence Laye Adap e p o ides he necessa y
in e ace o anspo bundles (da a uni s in BP) o e di e en ypes o anspo
ne wo ks. These anspo ne wo ks can a y widely, such as: T adi ional IP-based
ne wo ks (e.g., TCP/IP o UDP), Sa elli e ne wo ks, Wi eless links, Dis up ion- ole an
ne wo ks (e.g., in e plane a y ne wo ks, ne wo ks in emo e a eas). The Con e gence
Laye Adap e essen ially "adap s" he BP o hese unde lying ne wo k echnologies
-20-
by mapping he bundle's ansmission equi emen s on o he speci ic cha ac e is ics
and capabili ies o he anspo ne wo k. In he Figu e 3 he CLA is indica ed as CL.
Figu e 3: DTN ne wo k s ack in a he e ogenous ne wo k. Sou ce [9]
Figu e 4: Componen s o a Bundle Node. Sou ce [10].
Figu e 4 shows he componen s o a Bundle Node. The ones ha a e no e explained
be o e a e he Adminis a i e Elemen ha is he node componen ha cons uc s,
eques ansmissions and ecei e Adminis a i e Reco ds, ha a e ADUs exchanged
be ween nodes o adminis a i e pu poses. The only Adminis a i e Reco d in he
Bundle P o ocol is he s a us epo s, ha a e used o he nodes o ensu e ha a
Bundle has p og essed ho ough he ne wo k.
-21-
2.1.3. Applica ions example
DTN ne wo ks ha e been implemen ed in a ious use cases. One o hem is in NASA’s
use o space communica ion wi h he In e plane a y O e lay Ne wo k (ION) [11]
implemen a ion in ended o be used in embedded en i onmen s including spacec a
ligh compu e s. Ano he example is o u al connec i i y p o iding access o emo e
a eas wi h lacking eliable in as uc u e wi h Te a [12] a Ja a implemen a ion
de eloped o e es ial DTN use.
2.1.4. Challenges and Limi a ions
Despi e ha ing a huge po en ial as seen in p e ious poin s, he DTN ne wo k p o ocol
ha e some challenges. Majo secu i y challenges ha ake he o m o nodes beha ing
as “black holes” a e one o he majo conce ning’s ela ed o he BP. Ano he limi a ion
is he lack o checksums in he BP whe e i will be impossible o de ec e o s in
bundles heade s.
2.2. CoAP A chi ec u e
2.2.1. De ini ion and o e iew
The CoAP is a ligh weigh p o ocol designed o enable e icien communica ion
be ween de ices in esou ce-cons ained en i onmen s, as IoT ne wo ks. The main
cha ac e is ics a e de ined in he RFC 7252 [1] by he In e ne Enginee ing Task Fo ce
(IETF).
CoAP is an applica ion p o ocol ha ope a es asynch onously o e UDP o minimize
o e head while main aining simila unc ionali ies as HTTP, as i is a chi ec u e
adhe es o he Rep esen a ional S a e T ans e (REST) also known as REST ul
implemen a ion. The REST model is based on Se e s ha make esou ces a ailable
unde a Uni o m Resou ce Loca o (URL), and clien s access hese esou ces using
me hods such as GET, PUT, POST, and DELETE.
The in e ac ion model o CoAP is simila o he clien /se e model o HTTP. Howe e ,
machine- o-machine in e ac ions ypically esul in a CoAP implemen a ion ac ing in
bo h clien and se e oles. A CoAP eques is equi alen o ha o HTTP and is sen
by a clien o eques an ac ion (using a Me hod Code) on a esou ce (iden i ied by a
URI) on a se e . The se e hen sends a esponse wi h a Response Code; his
esponse may include a esou ce ep esen a ion. As an abs ac explana ion o CoAP
you could hink o i as a wo-lawye p o ocol, one o hem used o in e ac wi h UDP
-22-
as an asynch onous communica ion, and ano he as he eques / esponse in e ac ions
as shown in Figu e 5.
Figu e 5: Abs ac Laye ing o CoAP. Sou ce [13].
2.2.2. Co e Fea u es
CoAP has some co e concep s ha a e use ul o unde s and i ’s a chi ec u e:
• REST ul A chi ec u e: As men ioned be o e, CoAP ollows a simila a chi ec u e
as HTTP, simila as a eques - esponse model using me hods such as GET,
POST, PUT and DELETE. Con a y a he HTTP a chi ec u e he CoAP elimina es
unnecessa y o e head making i mo e sui able o cons ained de ices.
• Resou ce s uc u e: he CoAP p o ocol in eg a es and obse e pa e n, whe e
he clien s “obse e” a esou ce on he se e , changing i o only ge ing
in o ma ion o i .
• Message o ma : CoAP is based on a compac message ha a e anspo ed o e
UDP, hese messages a e encoded in a simply bina y o ma like seen in Figu e
6.
Figu e 6: CoAP message o ma Sou ce [14]
-23-
• CoAP message ypes: he e a e wo message ypes in CoAP, Con i mable (CON)
and Non-con i mable (NON). The Con i mable messages a e esponded by he
se e wi h an ACK con aining he esponse i needed, i he se e can espond
immedia ely he message is esponded wi h an emp y ACK, when he esponse
is eady he se e sends i in a CON message. The Non-Con i mable messages
a e esponded by he se e wi h NON messages. Figu es 7 and 8 illus a e bo h
cases.
Figu e 7: A GET eques wi h imed esponse. Sou ce [15].
Figu e 8: A eques and esponse wi h NON. Sou ce [16].
• CoAP me hods: As said be o e, he e a e 4 di e en me hods in he CoAP
p o ocol. The GET me hods e ie es in o ma ion o he esou ce iden i ied by
he eques . The POST me hod unc ion is de e mined by he se e , usually
he e is a new esou ce c ea ed in he se e . The PUT me hod upda es he da a
in he esou ce indica ed in he eques . And he las me hod is he DELETE
me hod ha dele es he esou ce indica ed by he eques .
-24-
2.2.3. Applica ion examples
The e a e a ious applica ion examples o he CoAP p o ocol. One o hem is o
Indus ial IoT whe e i can acili a e he communica ion be ween senso s and
con olle s in he manu ac u ing en i onmen s. Ano he example could be o sma
homes, whe e i can con ol he mos a s, ligh s and doo locks. One las example could
be moni o ing heal h sys ems in wea able de ices ha ansmi pa ien da a.
2.3. Used so wa e and ools
In his subsec ion is discussed all he so wa e and ools used o his p ojec , and
explaining he decision o e why hese a e selec ed.
2.3.1. Py hon
Fo he p og amming language he au ho o his p ojec decided o use Py hon [17]
due o he high compa ibili y wi h he lib a ies ha will be explained below and he
expe ience ha he au ho ha e o e py hon p og amming language.
2.3.2. Wi esha k
Wi esha k [18] was he so wa e ool used by he p ojec au ho o cap u e and
analyse he packages ha we e exchanged du ing he es ing o he de eloping phase
o he code. The we e some p oblems wi h he compa ibili y o he bundle p o ocol
packages bu his was sol ed by upda ing a he la es Wi esha k e sion and adding
he compu e po s used wi h he DTN lib a y o he BP p o ocol in Wi esha k. This
po whe e added o P e e ences->P o ocols->BP->BP UDP po (s). Figu e 9 shows a
sc een sho o a BP 7 bundle.
Figu e 9: Wi esha k example cap u e.
-25-
2.3.3. aiocoap
The aiocoap lib a y was chosen by he au ho o his p ojec o implemen he CoAP
unc ionali ies in he de eloped code. This lib a y was chosen o being he mos
upda ed lib a y o he CoAP implemen a ion in py hon.
The aiocoap lib a y has some basic unc ionali ies ha make i easy o implemen . One
o hem is he basic esou ce s uc u e o he se e c ea ion, whe e a esou ce can
be c ea ed using a Resou ce class de ining in i he ac ions ha he se e mus do o
e e y ype o message ecei ed.
F om he clien side, he aiocoap lib a y enables o c ea e messages by using he
“Message” class whe e i can be speci ied he code, he des ina ion URI, all he op ions
suppo ed by he CoAP messages and i he message is CON o NON.
The aiocoap lib a y has a license BSD 3-Clause License
<h ps://gi hub.com/ch ysn/aiocoap/blob/mas e /LICENSES/BSD-3-Clause. x >.
2.3.4. µd3 n
The µd3 n lib a y was one o he main lib a ies o he p ojec and i was he one used
o deploy he DTN ne wo k using he command line. In he same lib a y he e is a
sec ion o py hon in eg a ion ha was used by he au ho o in e ac wi h he aiocoap
lib a y and he deployed ne wo k. This lib a y was de eloped by he D3TN g oup. The
licence o his lib a y is ee o use and open sou ce.
He e he e a e de ined some basic unc ionali ies ha he µd3 n lib a y p o ides:
• Deploying nodes wi h di e en EIDs and AAP2.0 socke s o in e ac wi h hese
nodes.
• Speci y he bundle p o ocol e sion and he ype o connec ion expec ed by he
nodes ( o example, i implemen s se e al BP con e gence laye s
1
, such as
MTCP, TCPCL 3, CCSDS Space Packe P o ocol, BIBE,).
• Es ablish he communica ion link be ween wo nodes and he ime when his
communica ion will be accessible. (con ac )
• The py hon in eg a ion enables o c ea e AAP2.0 agen s capable o connec o
node AAP2.0 socke s, his agen can ecei e and send messages h ough he
µd3 n deployed Ne wo k.
1
h ps://gi lab.com/d3 n/ud3 n#wha -does-%C2%B5d3 n-p o ide
-32-
case is “coap://localhos / empe a u e” wi h he excep ion o he GET all unc ionali y,
ha i s manda o y o add a “?all” a he end o he URI o he se e o ecognize his
op ion. The las wo op ions a e he “m ype” ha indica es i he CoAP Message mus
be NON o CON, in his case NON, and he payload, ha is whe e he da a a els.
When he eques is c ea ed is sen using he “ eques (). esponse” me hod om he
clien con ex , and a esponse is wai ed.
Figu e 22: CoAP empe a u e clien
Is i wo h men ioning ha all he CoAP messages payloads a e encoded in an 8-bi
Unicode T ans o ma ion Fo ma (UTF) due o he equi emen o he CoAP p o ocol.
The esul o his applica ion can be seen in he images below whe e he messages
exchanged can be seen in he clien and se e e minal, he clien ecei es he
esponse o he se e wi h he code 2.04 i he esou ce has changed (a PUT) o 2.05
i he esponse has con en on i s payload. The alida ion o he esul s will be
explained in he Expe imen s and Tes s pa o he documen .
Figu e 23: Resul s o he CoAP applica ion.
-33-
3.3. AAP2.0 py hon applica ion
The inal las and mos ele an pa o he de elopmen o his p ojec is he py hon
applica ion ha will in e ac wi h bo h he DTN Ne wo k and he CoAP Applica ion.
The code o his pa will be added o he appendixes and he e we will discuss all he
me hods used o implemen i . Figu e 24 shows he elemen s o he de elopmen
u ilized o implemen his applica ion bo h in in e ac ion wi h o he p o ocols and he
o e all schema ics.
Figu e 24: Applica ion de eloped scheme.
To design his applica ion, we had o design a new ne wo k a chi ec u e whe e a new
laye was designed in be ween he applica ion laye (CoAP) and he Bundle P o ocol
Laye . The pu pose o his laye is o encapsula e he messages om he CoAP
applica ion in a bundle al he o igin side, and decapsula e he payload o he bundles
in o CoAP messages a he des ina ion side. In he Figu e 25 i can be seen whe e his
laye si s in a 4 nodes scheme, whe e he CoAP applica ion is in Node A and Node B.
Figu e 25: A chi ec u e s ack o de eloped applica ion.
This encapsula ion me hods wo ks in di e en s eps. The i s is he encoding o he
CoAP message wi h he encode me hod o he aiocoap lib a y making i a bina y
-34-
ep esen a ion, his encoded message is encapsula ed in a bundle payload. The bundle
hen is sen o he des ina ion EID speci ied whe e he CoAP message is mean o be
send. In he igu e 23 i can be seen in o ange wha kind o message a els in e e y
link. The bundles ep esen ed in his igu e a e as seen in he igu e below.
Figu e 26: Bundle wi h CoAP in he payload example.
Figu e 27: Example o CoAP Message c ea ion, encoding and encapsula ion.
When he bundle a i es o he des ina ion node speci ied in he des ina ion EID he
payload is decoded using he aiocoap lib a y. Then i he CoAP message is a eques
his is sen o he CoAP se e ha mus be accessible o m he des ina ion node. The
esponse o he se e is ea ed he same way as speci ied be o e. In he o he case o
a esponse a i ing, his is decoded using he aiocoap lib a y and he aiocoap
applica ion ecei es he esponse en i ely.
Wi h he capabili ies o he µd3 n wi h he pyh on-ud3 n-u ils ( he py hon speci ic
in eg a ions) i can be c ea ed an APP2 in e ac i e applica ion ha will ac as an
encapsula ion/decapsula ion laye be ween he CoAP applica ion and he DTN
Ne wo k. This in e ac i e applica ion will ac as he a chi ec u e s uc u e designed
abo e.
The i s hing o conside is he op ions ha he lib a y o e s o implemen ing he
designed code. The py hon-ud3 n-u ils o e a AAP2.0 clien di e en classes, he one
chosen was he AAP2AsyncUnixClien ha is an asynch onous clien o connec ing o
a µd3 n AAP2.0 Unix socke node, ha is pe ec o he case implemen ed. Fo being
-35-
able o send and ecei e bundles wi h each node i 's manda o y o c ea e wo agen s
(AAP2AsynUnixClien ), one will be a ecei e , and he o he one will be he sende . A
his poin i is possible o send and ecei e bundles wi h each node.
Figu e 28: Recei e and sende agen code.
As seen in he image abo e he wo agen s c ea ed un in asynch onous h eads so he
AAP2.0 applica ion can send and ecei e ADUs a he same ime. The nex s ep om
he clien side is o c ea e he CoAP message and encode i using he aiocoap lib a y
unc ionali ies.
Figu e 29: CoAP message c ea ion and encapsula ion.
When c ea ed and encoded he CoAP message is pu in he Bundle payload, hen he
message is sen o he des ina ion node EID and he speci ied ecei e agen o he
node, and he code wai s o he esponse code o m he Bundle P o ocol.
-36-
When he esponse is ecei ed i s payload is decoded as a Message om he aiocoap
lib a y in which he payload o he aiocoap message will b ing he aiocoap se e
esponse. I he eques was a GET i will b ing he da a o i , and i i is a PUT i will
b ing he con i ma ion o he ope a ion.
Figu e 30: Recei e and decode o CoAP messages.
F om he se e side, he message ecei ed on he AAP2.0 applica ion ela ed o Node
B is decoded in a Message om he aiocoap lib a y, and i s emo e add ess is c ea ed
using he da a o he op ions o he CoAP Message. This is due o he new p o ocol
Con ex c ea ed o being able o send CoAP Messages. The message is sen o he
se e and he esponse is wai ed.
Figu e 31: Decapsula ion o he CoAP Message.
When he esponse o he se e a i es, i is encoded wi h he aiocoap lib a y me hod,
and hen i is encapsula ed in a new Bundle ha will be sen o he des ina ion EID o
he clien and i s ecei e agen .
-37-
Figu e 32: Encapsula ion and sending o CoAP Response.
Figu e 33: Class diag am o de eloped code.
Figu e 34: Ac i i y diag am main unc ion.
-38-
Figu e 35: Ac i i y diag am sending agen .
Figu e 36: Ac i i y diag am ecei ing agen .
A his poin he e is a clea implemen a ion o he in ended design, bu i is missing
he pe sis en s o age ea u e ha he DTN Ne wo k o e s. To add his ea u e a new
Node C will be added wi h he pe sis en s o age enabled. The new scheme o he inal
deploymen can be seen below.
-39-
Figu e 37: Final de eloped implemen a ion.
To deploy his new Node C, i is no necessa y o change any hing om Node A o Node
B, bu we mus upda e he con ac s be ween hem and add new con ac s wi h he new
node.
Figu e 38: Node C deploymen command.
Figu e 39: New con ac plan be ween nodes.
I is wo h men ioning ha in he new con ac plan when con igu ing he connec ion
o Node C om Node A and Node B, he e mus be a eachable lis o nodes om whe e
Node C has con ac . Fo example, when con igu ing he connec ion om Node A o
Node C, i mus be speci ied ha Node C could each Node B, his is impo an because
he bundles a eling om Node A o Node B mus know ha hey mus go h ough
Node C. This eachable lis o nodes is added when he connec ions a e con igu ed wi h
he op ion “- ” in he command line, i can be seen in Figu e 39.
The connec ion om Node C o Node B will s a 60 seconds la e han he o he
connec ions, making ha Node C mus sa e all he bundles ha go o Node B un il he
connec ion is es ablished.
-40-
4. Resul s
____________________________________________________________ CHAPTER
4
Resul s
4.1. Expe imen s and Tes s
To es he de eloped code, es s we e conduc ed in di e en scena ios. He e will be
discussed all o hese scena ios:
• Scena io 1: The i s scena io is a µd3 n Ne wo k wi h wo nodes, whe e wo
bundles whe e send in a bidi ec ional communica ion. In his scena io is mean
o be seen he wo bundles co ec ly a i e o he o he nodes and a el
h ough he de eloped communica ion. This scena io is only o alida e he
µd3 n implemen a ion, wi h only bundles a eling h ough i .
• Scena io 2: The second scena io is a basic es o he aiocoap lib a y, whe e a
PUT and a GET a e sen om he aiocoap clien o he aiocoap se e . In his
es i is mean o be seen one GET one PUT and wo esponses.
• Scena io 3: The hi d scena io is he es o he de eloped code, whe e di e en
CoAP messages a e sen h ough he µd3 n ne wo k wi h wo nodes. In his
scena io we will see he CoAP message encoded inside he bundles, and he
CoAP messages sen o he se e .
• Scena io 4: The ou h and las scena io is simila as he hi d one bu wi h
pe sis en s o age, whe e he ime s amps o he messages will di e om he
ones wi h and immedia e connec ion. To make his scena io mo e eal, a hi d
node will be added in be ween he wo exis en ones (Node A and Node B), ha
is Node C.
-41-
4.2. Da a Analysis
The isualiza ion and cap u ing o i , is made h ough he Wi esha k so wa e. In each
case explained abo e we will discuss all he da a cap u ed.
4.2.1. Scena io 1: Two nodes µd3 n Ne wo k
Fo he i s scena io we can see wo exchanged bundles, one om Node A o Node B,
an ano he one om Node B o Node A. The scheme o he i s es ed scena io can be
seen below whe e he da a is exchanged om he sende o each node o he ecei e
o each one.
Figu e 40: Fi s scena io.
In he image o he esul s cap u ed below i can be seen he wo bundles exchanged
be ween nodes, whe e he sou ce and des ina ion add esses a e he ones ha a e
speci ied abo e. The da a exchanged can clea ly be seen in he decoded pa o he
message on he Wi esha k cap u e.
-48-
The p esen ial mee ing whe e held a he Campus No d ins alla ions o he Uni e si a
Poli èc ica de Ca alunya, and he au ho o his p ojec is om San Sadu ní d’Anoia,
whe e he s a ed all he commu es needed o go o he mee ings. In his commu e was
used he public bus, o a dis ance o 40.6 kilome e s, wi h an emission o 93 g ams o
CO2 pe kilome e pe ip, he o al oo p in o anspo a ion is o abou 98.17
kilog ams o CO2.
Wi h all ha ake in o accoun he e is one las hing o calcula e, he o al
en i onmen al impac o he compu e use o he p ojec . This use con empla es he
in es iga ion, he coding, and he alida ion held in one compu e ha was access
emo ely and he code and documen a ion w i ing done in on lap op. T ying o make
an app oxima e calcula ion o he ene gy consumed i is es ima ed an a e age us o
he main emo e compu e o 30 hou s pe week and he seconda y compu e o he
30 hou s accessing he emo e compu e and 5 hou s a week using i bo h du ing 15
weeks. Wi h a compu e consump ion o 180 W we can es ima e a o al ene gy
consump ion o 175.5 kWh. Wi h an equi alence o 0.45 kg o CO2 o 1 kWh he o al
amoun o ca bon oo p in is 79 kilog ams o CO2.
Wi h all he calcula ions done he o al ca bon oo p in due o his p ojec is o 177.9
kilog ams o CO2.
5.1.2. Economic impac
The cos o he p ojec can be calcula ed by coun ing he equi alen sala ies o he
p ojec au ho and he p ojec supe iso . In he nex able is ga he ed he in o ma ion
necessa y o make ha calcula ion.
Posi ion
Weekly dedica ion
Wage
Junio enginee
30 hou s
12€/hou
P o esso
3 hou s
35€/hou
Table 1: Es ima ion o dedica ion and wage.
-49-
Wi h ha in o ma ion in mind and making some assump ions i ’s possible o calcula e
he o al cos o he p ojec .
Posi ion
Dedica ed
weeks
Weekly
Wage
Social Secu i y
(33.33%)
To al
Junio
enginee
15
360€
120€
7200€
P o esso
15
105€
35€
2100€
Table 2: Cos es ima ion b eakdown.
As i ’s seen in he able he o al economic cos o he p ojec is 9300€.
5.1.3. Social impac
This p ojec could ha e a di ec social impac in he u u e i he de elopmen o i is
con inued, he possible eal implemen a ions could b ing a DTN ne wo k wi h a ligh
applica ion abo e i .
5.2. E hical implica ions
The e hical implica ions o his p ojec a e posi i e due o he inal objec i e o i , he
o e all objec i e aims o make in e ne mo e accessible in dis up i e and delaying
ne wo ks. O cou se, he e is a lo o wo k o do up o he poin he e hical implica ions
can be seen, bu he inal impac can be e y posi i e.
-50-
6. Conclusion and Fu u e Wo k
____________________________________________________________ CHAPTER
6
Conclusions and Fu u e Wo k
6.1 Conclusions
To sum up, he au ho o his p ojec success ully implemen ed he CoAP o e Bundle
P o ocol, making a es bed o each p o ocol and es ing he inal implemen a ion ha
he au ho de eloped. The main esul o he wo k es ablished ha is possible o
deploy a CoAP o e Bundle P o ocol communica ion sys em i he e is an in e media e
laye be ween he wo p o ocols.
Conside ing he esul s i can be said ha he au ho o he p ojec has achie ed he
objec i es es ablished. Success ully lea ning abou he CoAP P o ocol and he Bundle
P o ocol, deploying a es bed o each p o ocol, implemen ing and es ing an
applica ion using he wo p o ocols. The only hing ha he au ho had le behind is
he uni ica ion o he UIRs ha bo h p o ocols use, o make a mo e uni ied
implemen a ion.
This p ojec could b ing some ad ances o he ield o s udy, bu i mus also be said
ha he e is a lo o wo k o do.
6.2 Fu u e Di ec ions
The ob ious nex s ep in his implemen a ion is he uni ica ion o he URIs as said
be o e, making i simple o use. I will be also in e es ing o de elop a web applica ion
o make he es simple . Ano he ob ious imp o emen will be es ing mo e alues
and di e en si ua ions ha he au ho has no hough abou . Ano he u u e
di ec ion o he p ojec is o imp o e he secu i y and e o de ec ion capabili ies o
bo h p o ocols.
-51-
Bibliog aphy
[1] Shelby, Z., Ha ke, K., and C. Bo mann, 7252, IETF Da a acke , June 2014, "The
Cons ained Applica ion P o ocol (CoAP)”, RFC 7252,
<h ps://da a acke .ie .o g/doc/h ml/ c7252>.
[2] Ce , V., Bu leigh, S., Hooke, A., To ge son, L., Du s , R., Sco , K., Fall, K., and H.
Weiss, "Delay-Tole an Ne wo king A chi ec u e”, RFC 4838, IETF Da a acke ,
Ap il 2007, <h ps://da a acke .ie .o g/doc/h ml/ c4838 - au oid-2>.
[3] Bu leigh, S., Fall, K., and E. Bi ane, III, "Bundle P o ocol Ve sion 7", RFC 9171, IETF
Da a acke , Janua y 2022, <h ps://da a acke .ie .o g/doc/ c9171/>.
[4] Ch ysn, aiocoap - Py hon CoAP lib a y o he IoT, Gi Hub, Augus 2024,
<h ps://gi hub.com/ch ysn/aiocoap? ab= eadme-o - ile >.
[5] D3TN, µd3 n - Py hon u ili ies o uD3TN, Gi Lab, Oc obe 2024,
<h ps://gi lab.com/d3 n/ud3 n/-/ ee/mas e /py hon-ud3 n-
u ils? e _ ype=heads>.
[6] Ca les Gomez and Anna Cal e as, “Cons ained Applica ion P o ocol (CoAP) o e
Bundle P o ocol (BP)”, IETF Da a acke , June 2024,
<h ps://da a acke .ie .o g/doc/h ml/d a -gomez-co e-coap-bp-02>.
Accessed Oc obe 2024.
[7] T. Be ne -Lee, R. Fielding, l. Masin e , “Uni o m Resou ce Iden i ie (URI): Gene ic
Syn ax”, RFC 3986, IETF Da a acke , Janua y 2005,
<h ps://da a acke .ie .o g/doc/h ml/ c3986>.
[8] K. Sco , S. Bu leigh, “Bundle P o ocol Speci ica ion”, RFC 5050, IETF Da a acke ,
No embe 2007, < h ps://da a acke .ie .o g/doc/h ml/ c5050>.
[9] Ronan J, Walsh K, Long D. E alua ion o a DTN con e gence laye o he AX. 25
ne wo k p o ocol. In P oceedings o he Second In e na ional Wo kshop on
Mobile Oppo unis ic Ne wo king 2010 Feb 22 (pp. 72-78).
[10] Bu leigh, S., Fall, K., and E. Bi ane, III, "Bundle P o ocol Ve sion 7", RFC 9171, DOI
10.17487/RFC9171, Janua y 2022. A ailable: < h ps://www. c-
edi o .o g/in o/ c9171>. [Accessed Janua y 2025].
[11] S. Bu leigh, K. Sco , “In e plane a y O e lay Ne wo k”, Feb ua y 2008,
<h ps://www.nasa.go /di ec o a es/somd/space-communica ions-na iga ion-
p og am/in e plane a y-o e lay-ne wo k/ >
-52-
[12] Righ Mesh, Te a - a ligh weigh and modula DTN lib a y, Gi Hub, 2019,
<h ps://gi hub.com/Righ Mesh/Te a? ab= eadme-o - ile>.
[13] Shelby, Z., Ha ke, K., and C. Bo mann, 7252, IETF Da a acke , June 2014, "The
Cons ained Applica ion P o ocol (CoAP)”, RFC 7252,
<h ps://da a acke .ie .o g/doc/h ml/ c7252 - au oid-4>.
[14] Shelby, Z., Ha ke, K., and C. Bo mann, 7252, IETF Da a acke , June 2014, "The
Cons ained Applica ion P o ocol (CoAP)”, RFC 7252, <
h ps://da a acke .ie .o g/doc/h ml/ c7252 - au oid-9>.
[15] Shelby, Z., Ha ke, K., and C. Bo mann, 7252, IETF Da a acke , June 2014, "The
Cons ained Applica ion P o ocol (CoAP)”, RFC 7252,
<h ps://da a acke .ie .o g/doc/h ml/ c7252 - au oid-5>.
[16] Shelby, Z., Ha ke, K., and C. Bo mann, 7252, IETF Da a acke , June 2014, "The
Cons ained Applica ion P o ocol (CoAP)”, RFC 7252,
<h ps://da a acke .ie .o g/doc/h ml/ c7252 - au oid-5>.
[17] Py hon So wa e Founda ion, Py hon 3, Ve sion 3.13.1, 2025, A ailable:
<h ps://www.py hon.o g/>.
[18] Wi esha k Founda ion. "Wi esha k Ne wo k P o ocol Analyze ". [Online].
A ailable: <h ps://www.wi esha k.o g/ >.
[19] M. Bi encou , F. Madei a, R. L. Oli ei a. "B inging HTTP seman ic
in e ope abili y o cons ained IoT de ices wi h CoAP". a Xi p ep in
a Xi :2407.17166, July 2024. [Online]. A ailable: <
h ps://a xi .o g/pd /2407.17166>. [Accessed: Oc obe 2024].
-53-
Appendix A
_________________________________________________________ APPENDIX A
An appendix
All he code de eloped o his p ojec is a ailable in he au ho 's Gi Hub eposi o y.
The eposi o y includes all necessa y sc ip s, lib a ies, and documen a ion ela ed o
he p ojec .
Reposi o y Link: h ps://gi hub.com/maxlampu/CoAPo e Bundle
You can access he sou ce code and any addi ional esou ces ela ed o he p ojec by
isi ing he link abo e.