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.