Hello, I'm trying to understand how the tool dtnsend (in openwrt) implements the priority option -p because I want to make some modifications into it and add some code that works in the same way.
Reading the code, I've found that .../api/Bundle.ccp has the function "void Bundle::setPriority(Bundle::BUNDLE_PRIORITY p)" that changes the 2 priority bits of the bundle with b.set(dtn::data::Bundle::PRIORITY_BIT[1-2], [false or true]).
And two other functions that return the priority depending of the bits:
Bundle::BUNDLE_PRIORITY https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1api_1_1Bundle.html#a2f0badce9b7e34c160827a954e67146c Bundle::getPriority https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1api_1_1Bundle.html#a66ac26c78bd5fd19e66cf63a44d86c3a() const { if (_b https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1api_1_1Bundle.html#a96b8b47b85bd01a163d9710777ff2ddc.get https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1PrimaryBlock.html#aa4cc528da3aa1ac68703a8165534e088(dtn::data::Bundle::PRIORITY_BIT1 https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1PrimaryBlock.html#aee502ede1fb8668d6112b6344b4de4cda54f814dbd4ac5954eff61f8484c31e72)) { return PRIO_MEDIUM https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1api_1_1Bundle.html#a2f0badce9b7e34c160827a954e67146ca07f864f1af2419a09ff35937b6fd105a; } if (_b https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1api_1_1Bundle.html#a96b8b47b85bd01a163d9710777ff2ddc.get https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1PrimaryBlock.html#aa4cc528da3aa1ac68703a8165534e088(dtn::data::Bundle::PRIORITY_BIT2 https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1PrimaryBlock.html#aee502ede1fb8668d6112b6344b4de4cda7dd2a6914a20caaa13bd07889d4a37e3)) { return PRIO_HIGH https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1api_1_1Bundle.html#a2f0badce9b7e34c160827a954e67146ca193b4a7bbbc0ea3efe414d7dfeb93cbd; } return PRIO_LOW https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1api_1_1Bundle.html#a2f0badce9b7e34c160827a954e67146ca0a4546077362847f2d20385bc5c530ed; }
int MetaBundle::getPriority https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1MetaBundle.html#a33826e733a1f3d5fbf0108e8764d509a() const00059 {00060 // read priority00061 if (procflags https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1MetaBundle.html#a405385dba6b10989898cc1b93b3e25d4 & dtn::data::Bundle::PRIORITY_BIT1 https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1PrimaryBlock.html#aee502ede1fb8668d6112b6344b4de4cda54f814dbd4ac5954eff61f8484c31e72)00062 {00063 return 0;00064 }00065 00066 if (procflags https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1MetaBundle.html#a405385dba6b10989898cc1b93b3e25d4 & dtn::data::Bundle::PRIORITY_BIT2 https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1PrimaryBlock.html#aee502ede1fb8668d6112b6344b4de4cda7dd2a6914a20caaa13bd07889d4a37e3)00067 {00068 return 1;00069 }00070 00071 return -1;00072 }
Whats the meaning of this two similar functions? Whats the idea of adding procflags in the condition?
On another hand, what I want to know is how the DTN node processes this priority info. For example. If you first send a file with -p 1 (normal), after this, another one with -p 0 (low) and last, another one with -p 1 (normal). If everything goes well, the last one should be shipped before the one with priority -p 0. Where is this algorithm implemented in the code? I tried to find it but the only part of the code that shows something relevant about this is in daemon/src/storage/MemoryBundleStorage.h:
private:00111 ibrcommon::Mutex https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classibrcommon_1_1Mutex.html _bundleslock;00112 std::setdtn::data::Bundle _bundles;00113 00114 struct CMP_BUNDLE_PRIORITY00115 {00116 bool operator() (const dtn::data::MetaBundle https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1MetaBundle.html& lhs, const dtn::data::MetaBundle https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1MetaBundle.html& rhs) const00117 {00118 if (lhs.getPriority https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1MetaBundle.html#a33826e733a1f3d5fbf0108e8764d509a() == rhs.getPriority https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1MetaBundle.html#a33826e733a1f3d5fbf0108e8764d509a())00119 return rhs > lhs;00120 00121 return (lhs.getPriority https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1MetaBundle.html#a33826e733a1f3d5fbf0108e8764d509a()
rhs.getPriority
https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1MetaBundle.html#a33826e733a1f3d5fbf0108e8764d509a());00122 }00123 };00124 00125 std::setdtn::data::MetaBundle, CMP_BUNDLE_PRIORITY _priority_index;00126 std::map<dtn::data::BundleID, ssize_t> _bundle_lengths;00127 00128 size_t _maxsize;00129 size_t _currentsize;
But I dont't really understand how the change in the "storage queue"is done depending if a file has a higher or a lower priority than others that are in this queue. Where in the code is the queue of files stored in the dtn node and who send them? What means rhs and lhs?
Thank you in advance.
Hello Alex!
Bundle::getPriority() and MetaBundle::getPriority() does exactly the same thing. Both read the corresponding priority encoded in the processing flags. This is defined in the bundle protocol specification (RFC 5050).
The effect is, that bundles with higher priority are delivered preferential to bundles with a lower priority. This is implemented as ordered list in the bundle storages. A storage sort all the bundles according to the priority and iterate them in this order.
That means, a routing module will process the bundles with higher priority first.
Kind regards, Johannes Morgenroth
Thank you for your fast answer Johannes.
That's the thing that bothers me, why do you have 2 implementations for the same thing? Which one are you finally using?
About what you explain how bundle priority is working, I have figured it more or less reading the code, but it would be really helpful to now where specifically in the code is this ordered list defined, or where "storage sort all the bundles according to the priority and iterate them in this order." is implemented in the code.
I found that this function has something to do about this, but I don't understand really well how it works:
ibrcommon::Mutex https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classibrcommon_1_1Mutex.html _bundleslock;00112 std::setdtn::data::Bundle _bundles;00113 00114 struct CMP_BUNDLE_PRIORITY00115 {00116 bool operator() (const dtn::data::MetaBundle https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1MetaBundle.html& lhs, const dtn::data::MetaBundle https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1MetaBundle.html& rhs) const00117 {00118 if (lhs.getPriority https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1MetaBundle.html#a33826e733a1f3d5fbf0108e8764d509a() == rhs.getPriority https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1MetaBundle.html#a33826e733a1f3d5fbf0108e8764d509a())00119 return rhs > lhs;00120 00121 return (lhs.getPriority https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1MetaBundle.html#a33826e733a1f3d5fbf0108e8764d509a()
rhs.getPriority
https://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.8.0/classdtn_1_1data_1_1MetaBundle.html#a33826e733a1f3d5fbf0108e8764d509a());00122 }00123 };00124 00125 std::setdtn::data::MetaBundle, CMP_BUNDLE_PRIORITY _priority_index;00126 std::map<dtn::data::BundleID, ssize_t> _bundle_lengths;00127 00128 size_t _maxsize;00129 size_t _currentsize;
What's the meaning of rhs and lhs? It's maybe _priority_index the ordered list are you talking about? If it's so, where is the sorting process done? I think this function works to compare the priorities, but I can't find the function that pushes forward or pull back the files in the storage sorted list.
Thanks,
Alex López.
May
2013/1/11 Johannes Morgenroth morgenroth@ibr.cs.tu-bs.de
Hello Alex!
Bundle::getPriority() and MetaBundle::getPriority() does exactly the same thing. Both read the corresponding priority encoded in the processing flags. This is defined in the bundle protocol specification (RFC 5050).
The effect is, that bundles with higher priority are delivered preferential to bundles with a lower priority. This is implemented as ordered list in the bundle storages. A storage sort all the bundles according to the priority and iterate them in this order.
That means, a routing module will process the bundles with higher priority first.
Kind regards, Johannes Morgenroth
-- !! This message is brought to you via the `ibr-dtn' mailing list. !! Please do not reply to this message to unsubscribe. To unsubscribe or adjust !! your settings, send a mail message to ibr-dtn-request@ibr.cs.tu-bs.de !! or look at https://www.ibr.cs.tu-bs.de/mailman/listinfo/ibr-dtn.
The two implementations are part of two different objects. One is the Bundle which contains the whole bundle data including all block. MetaBundle is just a summary of the bundle and used at several places where only meta-data is needed.
The sorting process is done during the insertion. You should read the documentation for std::set objects in C++. The objects in there are always sorted. This sort can customized by using a comparison method. CMP_BUNDLE_PRIORITY is such a method and implements a strict ordering based on the priority. "lhs" and "rhs" are just variables for the left and right bundle to compare.
Kind regards, Johannes
-------- Weitergeleitete Nachricht -------- Von: Alex López lopalex87@gmail.com An: Johannes Morgenroth morgenroth@ibr.cs.tu-bs.de Kopie: ibr-dtn@ibr.cs.tu-bs.de Betreff: Re: [ibr-dtn] How Priority parameter works? Datum: Fri, 11 Jan 2013 16:08:51 +0100
Thank you for your fast answer Johannes.
That's the thing that bothers me, why do you have 2 implementations for the same thing? Which one are you finally using?
About what you explain how bundle priority is working, I have figured it more or less reading the code, but it would be really helpful to now where specifically in the code is this ordered list defined, or where "storage sort all the bundles according to the priority and iterate them in this order." is implemented in the code.
I found that this function has something to do about this, but I don't understand really well how it works:
ibrcommon::Mutex _bundleslock; 00112 std::setdtn::data::Bundle _bundles; 00113 00114 struct CMP_BUNDLE_PRIORITY 00115 { 00116 bool operator() (const dtn::data::MetaBundle& lhs, const dtn::data::MetaBundle& rhs) const 00117 { 00118 if (lhs.getPriority() == rhs.getPriority()) 00119 return rhs > lhs; 00120 00121 return (lhs.getPriority() > rhs.getPriority()); 00122 } 00123 }; 00124 00125 std::set<dtn::data::MetaBundle, CMP_BUNDLE_PRIORITY> _priority_index; 00126 std::map<dtn::data::BundleID, ssize_t> _bundle_lengths; 00127 00128 size_t _maxsize; 00129 size_t _currentsize;
What's the meaning of rhs and lhs? It's maybe _priority_index the ordered list are you talking about? If it's so, where is the sorting process done? I think this function works to compare the priorities, but I can't find the function that pushes forward or pull back the files in the storage sorted list.
Thanks,
Alex López.
May
2013/1/11 Johannes Morgenroth morgenroth@ibr.cs.tu-bs.de Hello Alex!
Bundle::getPriority() and MetaBundle::getPriority() does exactly the same thing. Both read the corresponding priority encoded in the processing flags. This is defined in the bundle protocol specification (RFC 5050).
The effect is, that bundles with higher priority are delivered preferential to bundles with a lower priority. This is implemented as ordered list in the bundle storages. A storage sort all the bundles according to the priority and iterate them in this order.
That means, a routing module will process the bundles with higher priority first.
Kind regards, Johannes Morgenroth
-- !! This message is brought to you via the `ibr-dtn' mailing list. !! Please do not reply to this message to unsubscribe. To unsubscribe or adjust !! your settings, send a mail message to ibr-dtn-request@ibr.cs.tu-bs.de !! or look at https://www.ibr.cs.tu-bs.de/mailman/listinfo/ibr-dtn.
Thank you very much for your advice.
I will check it and try to understand better how it works.
Regards, Alex.
2013/1/11 Johannes Morgenroth morgenroth@ibr.cs.tu-bs.de
The two implementations are part of two different objects. One is the Bundle which contains the whole bundle data including all block. MetaBundle is just a summary of the bundle and used at several places where only meta-data is needed.
The sorting process is done during the insertion. You should read the documentation for std::set objects in C++. The objects in there are always sorted. This sort can customized by using a comparison method. CMP_BUNDLE_PRIORITY is such a method and implements a strict ordering based on the priority. "lhs" and "rhs" are just variables for the left and right bundle to compare.
Kind regards, Johannes
-------- Weitergeleitete Nachricht -------- Von: Alex López lopalex87@gmail.com An: Johannes Morgenroth morgenroth@ibr.cs.tu-bs.de Kopie: ibr-dtn@ibr.cs.tu-bs.de Betreff: Re: [ibr-dtn] How Priority parameter works? Datum: Fri, 11 Jan 2013 16:08:51 +0100
Thank you for your fast answer Johannes.
That's the thing that bothers me, why do you have 2 implementations for the same thing? Which one are you finally using?
About what you explain how bundle priority is working, I have figured it more or less reading the code, but it would be really helpful to now where specifically in the code is this ordered list defined, or where "storage sort all the bundles according to the priority and iterate them in this order." is implemented in the code.
I found that this function has something to do about this, but I don't understand really well how it works:
ibrcommon::Mutex _bundleslock; 00112 std::setdtn::data::Bundle _bundles; 00113 00114 struct CMP_BUNDLE_PRIORITY 00115 { 00116 bool operator() (const dtn::data::MetaBundle& lhs, const dtn::data::MetaBundle& rhs) const 00117 { 00118 if (lhs.getPriority() == rhs.getPriority()) 00119 return rhs > lhs; 00120 00121 return (lhs.getPriority() > rhs.getPriority()); 00122 } 00123 }; 00124 00125 std::setdtn::data::MetaBundle, CMP_BUNDLE_PRIORITY _priority_index; 00126 std::map<dtn::data::BundleID, ssize_t> _bundle_lengths; 00127 00128 size_t _maxsize; 00129 size_t _currentsize;
What's the meaning of rhs and lhs? It's maybe _priority_index the ordered list are you talking about? If it's so, where is the sorting process done? I think this function works to compare the priorities, but I can't find the function that pushes forward or pull back the files in the storage sorted list.
Thanks,
Alex López.
May
2013/1/11 Johannes Morgenroth morgenroth@ibr.cs.tu-bs.de Hello Alex!
Bundle::getPriority() and MetaBundle::getPriority() does exactly the same thing. Both read the corresponding priority encoded in the processing flags. This is defined in the bundle protocol specification (RFC 5050). The effect is, that bundles with higher priority are delivered preferential to bundles with a lower priority. This is implemented as ordered list in the bundle storages. A storage sort all the bundles according to the priority and iterate them in this order. That means, a routing module will process the bundles with higher priority first. Kind regards, Johannes Morgenroth -- !! This message is brought to you via the `ibr-dtn' mailing list. !! Please do not reply to this message to unsubscribe. To unsubscribe or adjust !! your settings, send a mail message to <ibr-dtn-request@ibr.cs.tu-bs.de> !! or look at https://www.ibr.cs.tu-bs.de/mailman/listinfo/ibr-dtn.
-- Alex Lopez
-- !! This message is brought to you via the `ibr-dtn' mailing list. !! Please do not reply to this message to unsubscribe. To unsubscribe or adjust !! your settings, send a mail message to ibr-dtn-request@ibr.cs.tu-bs.de !! or look at https://www.ibr.cs.tu-bs.de/mailman/listinfo/ibr-dtn.
participants (2)
-
Alex López
-
Johannes Morgenroth