botnet_comm_processor.cpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. #include "botnet_comm_processor.h"
  2. /**
  3. * Creates a new botnet_comm_processor object.
  4. * The abstract python messages are converted to easier-to-handle C++ data structures.
  5. * @param messages_pyboost The abstract communication messages
  6. * represented as (python) list containing (python) dicts.
  7. */
  8. botnet_comm_processor::botnet_comm_processor(const py::list &messages_pyboost){
  9. set_messages(messages_pyboost);
  10. }
  11. /**
  12. * Creates a new and empty botnet_comm_processor object.
  13. */
  14. botnet_comm_processor::botnet_comm_processor(){
  15. }
  16. /**
  17. * Set the messages of this communication processor.
  18. * @param messages_pyboost The abstract communication messages
  19. * represented as (python) list containing (python) dicts.
  20. */
  21. void botnet_comm_processor::set_messages(const py::list &messages_pyboost){
  22. messages.clear();
  23. for (int i = 0; i < len(messages_pyboost); i++){
  24. py::dict msg_pyboost = py::extract<py::dict>(messages_pyboost[i]);
  25. unsigned int src_id = std::stoi(py::extract<std::string>(msg_pyboost["Src"]));
  26. unsigned int dst_id = std::stoi(py::extract<std::string>(msg_pyboost["Dst"]));
  27. unsigned short type = (unsigned short) std::stoi(py::extract<std::string>(msg_pyboost["Type"]));
  28. double time = std::stod(py::extract<std::string>(msg_pyboost["Time"]));
  29. int line_no = std::stoi(py::extract<std::string>(msg_pyboost.get("LineNumber", "-1")));
  30. abstract_msg msg = {src_id, dst_id, type, time, line_no};
  31. messages.push_back(std::move(msg));
  32. }
  33. }
  34. /**
  35. * Retrieve input information about message count.
  36. * @return the number of existing messages.
  37. */
  38. int botnet_comm_processor::get_message_count(){
  39. return messages.size();
  40. }
  41. /**
  42. * Processes an XML attribute assignment. The result is reflected in the respective change of the given message.
  43. * @param msg The message this attribute refers to.
  44. * @param assignment The XML attribute assignment in notation: attribute="value"
  45. */
  46. void botnet_comm_processor::process_xml_attrib_assign(abstract_msg &msg, const std::string &assignment) {
  47. std::size_t split_pos = assignment.find("=");
  48. if (split_pos != std::string::npos){
  49. std::string key = assignment.substr(0, split_pos);
  50. std::string value = assignment.substr(split_pos + 2, assignment.length() - 1);
  51. process_kv(msg, key, value);
  52. }
  53. }
  54. /**
  55. * Processes a key-value pair. The result is reflected in the respective change of the given message.
  56. * @param msg The message this kv pair refers to.
  57. * @param key The key of the attribute.
  58. * @param value The value of the attribute.
  59. */
  60. void botnet_comm_processor::process_kv(abstract_msg &msg, const std::string &key, const std::string &value){
  61. if (key == "Src")
  62. msg.src = std::stoi(value);
  63. else if (key == "Dst")
  64. msg.dst = std::stoi(value);
  65. else if (key == "Type")
  66. msg.type = (unsigned short) std::stoi(value);
  67. else if (key == "Time")
  68. msg.time = std::stod(value);
  69. else if (key == "LineNumber")
  70. msg.line_no = std::stoi(value);
  71. }
  72. /**
  73. * Parses the packets contained in the given CSV to program structure.
  74. * @param filepath The filepath where the CSV is located.
  75. * @return The number of messages (or lines) contained in the CSV file.
  76. */
  77. unsigned int botnet_comm_processor::parse_csv(const std::string &filepath){
  78. std::ifstream input(filepath);
  79. int line_no = 1; // the first line has number 1
  80. messages.clear();
  81. // iterate over every line
  82. for (std::string line; std::getline(input, line); ){
  83. std::istringstream line_stream(line);
  84. abstract_msg cur_msg;
  85. cur_msg.line_no = line_no;
  86. // iterate over every key:value entry
  87. for (std::string pair; std::getline(line_stream, pair, ','); ){
  88. boost::replace_all(pair, " ", "");
  89. std::size_t split_pos = pair.find(":");
  90. if (split_pos != std::string::npos){
  91. std::string key = pair.substr(0, split_pos);
  92. std::string value = pair.substr(split_pos + 1, pair.length());
  93. process_kv(cur_msg, key, value);
  94. }
  95. }
  96. messages.push_back(std::move(cur_msg));
  97. line_no++;
  98. }
  99. return messages.size();
  100. }
  101. /**
  102. * Parses the packets contained in the given XML to program structure.
  103. * @param filepath The filepath where the XML is located.
  104. * @return The number of messages contained in the XML file.
  105. */
  106. unsigned int botnet_comm_processor::parse_xml(const std::string &filepath){
  107. std::ifstream input(filepath);
  108. std::string cur_word = "";
  109. abstract_msg cur_msg;
  110. char c;
  111. int read_packet_open = 0, read_slash = 0;
  112. messages.clear();
  113. // iterate over every character
  114. while (input.get(c)){
  115. if(c == '/') // hints ending of tag
  116. read_slash = 1;
  117. else if (c == '>'){ // definitely closes tag
  118. if (read_packet_open && read_slash){ // handle oustanding attribute
  119. read_slash = 0;
  120. process_xml_attrib_assign(cur_msg, cur_word);
  121. messages.push_back(cur_msg);
  122. read_packet_open = 0;
  123. }
  124. cur_word = "";
  125. }
  126. else if (c == ' '){
  127. if (read_packet_open && cur_word != ""){ // handle new attribute
  128. process_xml_attrib_assign(cur_msg, cur_word);
  129. }
  130. else if (cur_word == "<packet")
  131. read_packet_open = 1;
  132. cur_word = "";
  133. }
  134. else
  135. cur_word += c;
  136. }
  137. return messages.size();
  138. }
  139. /**
  140. * Writes the communication messages contained in the class member messages into an XML file (with respective notation).
  141. * @param out_dir The directory the file is to be put in.
  142. * @param basename The actual name of the file without directories or extension.
  143. * @return The filepath of the written XML file.
  144. */
  145. std::string botnet_comm_processor::write_xml(const std::string &out_dir, const std::string &basename){
  146. std::string filepath;
  147. if (out_dir[out_dir.length() - 1] == '/')
  148. filepath = out_dir + basename + ".xml";
  149. else
  150. filepath = out_dir + "/" + basename + ".xml";
  151. std::ofstream xml_file;
  152. xml_file.open(filepath);
  153. // set number of digits after dot to 11
  154. xml_file << std::fixed << std::setprecision(11);
  155. xml_file << "<trace name=\"" << basename << "\">";
  156. for (const auto &msg : messages){
  157. xml_file << "<packet ";
  158. xml_file << "Src=\"" << msg.src << "\" Dst=\"" << msg.dst << "\" ";
  159. xml_file << "Type=\"" << msg.type << "\" Time=\"" << msg.time << "\" ";
  160. xml_file << "LineNumber=\"" << msg.line_no << "\" />";
  161. }
  162. xml_file << "</trace>";
  163. xml_file.close();
  164. return filepath;
  165. }
  166. /**
  167. * Retrieves all messages contained in the interval between start_idx and end_idx in Python representation.
  168. * @param start_idx The inclusive first index of the interval.
  169. * @param end_idx The inclusive last index of the interval.
  170. * @return A (Python) list of (Python) dicts containing the desired information.
  171. */
  172. py::list botnet_comm_processor::get_messages(unsigned int start_idx, unsigned int end_idx){
  173. py::list py_messages;
  174. for (std::size_t i = start_idx; i <= end_idx; i++){
  175. if (i >= messages.size())
  176. break;
  177. py::dict py_msg;
  178. py_msg["Src"] = messages[i].src;
  179. py_msg["Dst"] = messages[i].dst;
  180. py_msg["Type"] = messages[i].type;
  181. py_msg["Time"] = messages[i].time;
  182. py_msg["LineNumber"] = messages[i].line_no;
  183. py_messages.append(py_msg);
  184. }
  185. return py_messages;
  186. }
  187. /**
  188. * Finds the time interval(s) of maximum the given seconds with the most overall communication
  189. * (i.e. requests and responses) that has at least number_ids communicating initiators in it.
  190. * @param number_ids The number of initiator IDs that have to exist in the interval(s).
  191. * @param max_int_time The maximum time period of the interval.
  192. * @return A (python) list of (python) dicts, where each dict (keys: 'IDs', Start', 'End') represents an interval with its
  193. * list of initiator IDs, a start index and an end index. The indices are with respect to the first abstract message.
  194. */
  195. py::list botnet_comm_processor::find_optimal_interval(int number_ids, double max_int_time){
  196. unsigned int logical_thread_count = std::thread::hardware_concurrency();
  197. std::vector<std::thread> threads;
  198. std::vector<std::future<std::vector<comm_interval> > > futures;
  199. // create as many threads as can run concurrently and assign them respective sections
  200. for (std::size_t i = 0; i < logical_thread_count; i++){
  201. unsigned int start_idx = (i * messages.size() / logical_thread_count);
  202. unsigned int end_idx = (i + 1) * messages.size() / logical_thread_count;
  203. std::promise<std::vector<comm_interval> > p; // use promises to retrieve return values
  204. futures.push_back(p.get_future());
  205. threads.push_back(std::thread(&botnet_comm_processor::find_optimal_interval_helper, this, std::move(p), number_ids, max_int_time, start_idx, end_idx));
  206. }
  207. // synchronize all threads
  208. for (auto &t : threads){
  209. t.join();
  210. }
  211. // accumulate results
  212. std::vector<std::vector<comm_interval> > acc_possible_intervals;
  213. for (auto &f : futures){
  214. acc_possible_intervals.push_back(f.get());
  215. }
  216. // find overall most communicative interval
  217. std::vector<comm_interval> possible_intervals;
  218. unsigned int cur_highest_sum = 0;
  219. for (const auto &single_poss_interval : acc_possible_intervals){
  220. if (single_poss_interval.size() > 0 && single_poss_interval[0].comm_sum >= cur_highest_sum){
  221. // if there is more than one interval, all of them have the same comm_sum
  222. if (single_poss_interval[0].comm_sum > cur_highest_sum){
  223. cur_highest_sum = single_poss_interval[0].comm_sum;
  224. possible_intervals.clear();
  225. }
  226. for (const auto &interval : single_poss_interval){
  227. possible_intervals.push_back(std::move(interval));
  228. }
  229. }
  230. }
  231. // return the result converted into python data structures
  232. return convert_intervals_to_py_repr(possible_intervals);
  233. }
  234. /**
  235. * Finds the time interval(s) of maximum the given seconds within the given start and end index having the most
  236. * overall communication (i.e. requests and responses) as well as at least number_ids communicating initiators in it.
  237. * @param p An rvalue to a promise to return the found intervals.
  238. * @param number_ids The number of initiator IDs that have to exist in the interval(s).
  239. * @param max_int_time The maximum time period of the interval.
  240. * @param start_idx The index of the first message to process with respect to the class member 'messages'.
  241. * @param end_idx The upper index boundary where the search is stopped at (i.e. exclusive index).
  242. */
  243. void botnet_comm_processor::find_optimal_interval_helper(std::promise<std::vector<comm_interval> > && p, int number_ids, double max_int_time, int start_idx, int end_idx){
  244. // setup initial variables
  245. unsigned int idx_low = start_idx, idx_high = start_idx; // the indices spanning the interval
  246. unsigned int comm_sum = 0; // the communication sum of the current interval
  247. unsigned int cur_highest_sum = 0; // the highest communication sum seen so far
  248. double cur_int_time = 0; // the time of the current interval
  249. std::deque<unsigned int> init_ids; // the initiator IDs seen in the current interval in order of appearance
  250. std::vector<comm_interval> possible_intervals; // all intervals that have cur_highest_sum of communication and contain enough IDs
  251. // Iterate over all messages from start to finish and process the info of each message.
  252. // Similar to a Sliding Window approach.
  253. while (1){
  254. if (idx_high < messages.size())
  255. cur_int_time = messages[idx_high].time - messages[idx_low].time;
  256. // if current interval time exceeds maximum time period or all messages have been processed,
  257. // process information of the current interval
  258. if (greater_than(cur_int_time, max_int_time) || idx_high >= messages.size()){
  259. std::set<unsigned int> interval_ids;
  260. for (std::size_t i = 0; i < init_ids.size(); i++)
  261. interval_ids.insert(init_ids[i]);
  262. // if the interval contains enough initiator IDs, add it to possible_intervals
  263. if (interval_ids.size() >= (unsigned int) number_ids){
  264. comm_interval interval = {interval_ids, comm_sum, idx_low, idx_high - 1};
  265. // reset possible intervals if new maximum of communication is found
  266. if (comm_sum > cur_highest_sum){
  267. possible_intervals.clear();
  268. possible_intervals.push_back(std::move(interval));
  269. cur_highest_sum = comm_sum;
  270. }
  271. // append otherwise
  272. else if (comm_sum == cur_highest_sum)
  273. possible_intervals.push_back(std::move(interval));
  274. }
  275. // stop if all messages have been processed
  276. if (idx_high >= messages.size())
  277. break;
  278. }
  279. // let idx_low "catch up" so that the current interval time fits into the maximum time period again
  280. while (greater_than(cur_int_time, max_int_time)){
  281. if (idx_low >= (unsigned int) end_idx)
  282. goto end;
  283. abstract_msg &cur_msg = messages[idx_low];
  284. // if message was not a timeout, delete the first appearance of the initiator ID
  285. // of this message from the initiator list and update comm_sum
  286. if (cur_msg.type != TIMEOUT){
  287. comm_sum--;
  288. init_ids.pop_front();
  289. }
  290. idx_low++;
  291. cur_int_time = messages[idx_high].time - messages[idx_low].time;
  292. }
  293. // consume the new message at idx_high and process its information
  294. abstract_msg &cur_msg = messages[idx_high];
  295. // if message is request, add src to initiator list
  296. if (msgtype_is_request(cur_msg.type)){
  297. init_ids.push_back(cur_msg.src);
  298. comm_sum++;
  299. }
  300. // if message is response, add dst to initiator list
  301. else if (msgtype_is_response(cur_msg.type)){
  302. init_ids.push_back(cur_msg.dst);
  303. comm_sum++;
  304. }
  305. idx_high++;
  306. }
  307. end: p.set_value(possible_intervals);
  308. }
  309. /**
  310. * Finds the time interval of maximum the given seconds starting at the given index. If it does not have at least number_ids
  311. * communicating initiators in it or the index is out of bounds, an empty dict is returned.
  312. * @param start_idx the starting index of the returned interval
  313. * @param number_ids The number of initiator IDs that have to exist in the interval.
  314. * @param max_int_time The maximum time period of the interval.
  315. * @return A (python) dict (keys: 'IDs', Start', 'End'), which represents an interval with its list of initiator IDs,
  316. * a start index and an end index. The indices are with respect to the first abstract message.
  317. */
  318. py::dict botnet_comm_processor::find_interval_from_startidx(int start_idx, int number_ids, double max_int_time){
  319. // setup initial variables
  320. unsigned int cur_idx = start_idx; // the current iteration index
  321. double cur_int_time = 0; // the time of the current interval
  322. std::deque<unsigned int> init_ids; // the initiator IDs seen in the current interval in order of appearance
  323. py::dict comm_interval_py; // the communication interval that is returned
  324. if ((unsigned int) start_idx >= messages.size()){
  325. return comm_interval_py;
  326. }
  327. // Iterate over all messages starting at start_idx until the duration or the current index exceeds a boundary
  328. while (1){
  329. if (cur_idx < messages.size())
  330. cur_int_time = messages[cur_idx].time - messages[start_idx].time;
  331. // if current interval time exceeds maximum time period or all messages have been processed,
  332. // process information of the current interval
  333. if (greater_than(cur_int_time, max_int_time) || cur_idx >= messages.size()){
  334. std::set<unsigned int> interval_ids;
  335. for (std::size_t i = 0; i < init_ids.size(); i++)
  336. interval_ids.insert(init_ids[i]);
  337. // if the interval contains enough initiator IDs, convert it to python representation and return it
  338. if (interval_ids.size() >= (unsigned int) number_ids){
  339. py::list py_ids;
  340. for (const auto &id : interval_ids){
  341. py_ids.append(id);
  342. }
  343. comm_interval_py["IDs"] = py_ids;
  344. comm_interval_py["Start"] = start_idx;
  345. comm_interval_py["End"] = cur_idx - 1;
  346. return comm_interval_py;
  347. }
  348. else {
  349. return comm_interval_py;
  350. }
  351. }
  352. // consume the new message at cur_idx and process its information
  353. abstract_msg &cur_msg = messages[cur_idx];
  354. // if message is request, add src to initiator list
  355. if (msgtype_is_request(cur_msg.type))
  356. init_ids.push_back(cur_msg.src);
  357. // if message is response, add dst to initiator list
  358. else if (msgtype_is_response(cur_msg.type))
  359. init_ids.push_back(cur_msg.dst);
  360. cur_idx++;
  361. }
  362. }
  363. /**
  364. * Finds the time interval of maximum the given seconds ending at the given index. If it does not have at least number_ids
  365. * communicating initiators in it or the index is out of bounds, an empty dict is returned.
  366. * @param end_idx the ending index of the returned interval (inclusive)
  367. * @param number_ids The number of initiator IDs that have to exist in the interval.
  368. * @param max_int_time The maximum time period of the interval.
  369. * @return A (python) dict (keys: 'IDs', Start', 'End'), which represents an interval with its list of initiator IDs,
  370. * a start index and an end index. The indices are with respect to the first abstract message.
  371. */
  372. py::dict botnet_comm_processor::find_interval_from_endidx(int end_idx, int number_ids, double max_int_time){
  373. // setup initial variables
  374. int cur_idx = end_idx; // the current iteration index
  375. double cur_int_time = 0; // the time of the current interval
  376. std::deque<unsigned int> init_ids; // the initiator IDs seen in the current interval in order of appearance
  377. py::dict comm_interval_py; // the communication interval that is returned
  378. if (end_idx < 0){
  379. return comm_interval_py;
  380. }
  381. // Iterate over all messages starting at end_idx until the duration or the current index exceeds a boundary
  382. while (1){
  383. if (cur_idx >= 0)
  384. cur_int_time = messages[end_idx].time - messages[cur_idx].time;
  385. // if current interval time exceeds maximum time period or all messages have been processed,
  386. // process information of the current interval
  387. if (greater_than(cur_int_time, max_int_time) || cur_idx < 0){
  388. std::set<unsigned int> interval_ids;
  389. for (std::size_t i = 0; i < init_ids.size(); i++)
  390. interval_ids.insert(init_ids[i]);
  391. // if the interval contains enough initiator IDs, convert it to python representation and return it
  392. if (interval_ids.size() >= (unsigned int) number_ids){
  393. py::list py_ids;
  394. for (const auto &id : interval_ids){
  395. py_ids.append(id);
  396. }
  397. comm_interval_py["IDs"] = py_ids;
  398. comm_interval_py["Start"] = cur_idx + 1;
  399. comm_interval_py["End"] = end_idx;
  400. return comm_interval_py;
  401. }
  402. else {
  403. return comm_interval_py;
  404. }
  405. }
  406. // consume the new message at cur_idx and process its information
  407. abstract_msg &cur_msg = messages[cur_idx];
  408. // if message is request, add src to initiator list
  409. if (msgtype_is_request(cur_msg.type))
  410. init_ids.push_back(cur_msg.src);
  411. // if message is response, add dst to initiator list
  412. else if (msgtype_is_response(cur_msg.type))
  413. init_ids.push_back(cur_msg.dst);
  414. cur_idx--;
  415. }
  416. }
  417. /**
  418. * Finds all initiator IDs contained in the interval spanned by the two indices.
  419. * @param start_idx The start index of the interval.
  420. * @param end_idx The last index of the interval (inclusive).
  421. * @return A (python) list containing all initiator IDs of the interval.
  422. */
  423. py::list botnet_comm_processor::get_interval_init_ids(int start_idx, int end_idx){
  424. // setup initial variables
  425. unsigned int cur_idx = start_idx; // the current iteration index
  426. std::set<unsigned int> interval_ids;
  427. py::list py_ids; // the communication interval that is returned
  428. if ((unsigned int) start_idx >= messages.size()){
  429. return py_ids;
  430. }
  431. // Iterate over all messages starting at start_idx until the duration or the current index exceeds a boundary
  432. while (1){
  433. // if messages have been processed
  434. if (cur_idx >= messages.size() || cur_idx > (unsigned int) end_idx){
  435. for (const auto &id : interval_ids)
  436. py_ids.append(id);
  437. return py_ids;
  438. }
  439. // consume the new message at cur_idx and process its information
  440. abstract_msg &cur_msg = messages[cur_idx];
  441. // if message is request, add src to initiator list
  442. if (msgtype_is_request(cur_msg.type))
  443. interval_ids.insert(cur_msg.src);
  444. // if message is response, add dst to initiator list
  445. else if (msgtype_is_response(cur_msg.type))
  446. interval_ids.insert(cur_msg.dst);
  447. cur_idx++;
  448. }
  449. }
  450. /**
  451. * Checks whether the given message type corresponds to a request.
  452. * @param mtype The message type to check.
  453. * @return true(1) if the message type is a request, false(0) otherwise.
  454. */
  455. int botnet_comm_processor::msgtype_is_request(unsigned short mtype){
  456. return mtype == SALITY_HELLO || mtype == SALITY_NL_REQUEST;
  457. }
  458. /**
  459. * Checks whether the given message type corresponds to a response.
  460. * @param mtype The message type to check.
  461. * @return true(1) if the message type is a response, false(0) otherwise.
  462. */
  463. int botnet_comm_processor::msgtype_is_response(unsigned short mtype){
  464. return mtype == SALITY_HELLO_REPLY || mtype == SALITY_NL_REPLY;
  465. }
  466. /**
  467. * Converts the given vector of communication intervals to a python representation
  468. * using (python) lists and (python) tuples.
  469. * @param intervals The communication intervals to convert.
  470. * @return A boost::python::list containing the same interval information using boost::python::dict for each interval.
  471. */
  472. py::list botnet_comm_processor::convert_intervals_to_py_repr(const std::vector<comm_interval> &intervals){
  473. py::list py_intervals;
  474. for (const auto &interval : intervals){
  475. py::list py_ids;
  476. for (const auto &id : interval.ids){
  477. py_ids.append(id);
  478. }
  479. py::dict py_interval;
  480. py_interval["IDs"] = py_ids;
  481. py_interval["Start"] = interval.start_idx;
  482. py_interval["End"] = interval.end_idx;
  483. py_intervals.append(py_interval);
  484. }
  485. return py_intervals;
  486. }
  487. // void botnet_comm_processor::print_message(const abstract_msg &message){
  488. // std::cout << "Src: " << message.src << " Dst: " << message.dst << " Type: " << message.type << " Time: " << message.time << " LineNumber: " << message.line_no << std::endl;
  489. // }
  490. /*
  491. * Comment out if executable should be build & run
  492. * Comment in if library should be build
  493. */
  494. using namespace boost::python;
  495. BOOST_PYTHON_MODULE (libbotnetcomm) {
  496. class_<botnet_comm_processor>("botnet_comm_processor")
  497. .def(init<list>())
  498. .def(init<>())
  499. .def("find_interval_from_startidx", &botnet_comm_processor::find_interval_from_startidx)
  500. .def("find_interval_from_endidx", &botnet_comm_processor::find_interval_from_endidx)
  501. .def("find_optimal_interval", &botnet_comm_processor::find_optimal_interval)
  502. .def("get_interval_init_ids", &botnet_comm_processor::get_interval_init_ids)
  503. .def("get_messages", &botnet_comm_processor::get_messages)
  504. .def("get_message_count", &botnet_comm_processor::get_message_count)
  505. .def("parse_csv", &botnet_comm_processor::parse_csv)
  506. .def("parse_xml", &botnet_comm_processor::parse_xml)
  507. .def("set_messages", &botnet_comm_processor::set_messages)
  508. .def("write_xml", &botnet_comm_processor::write_xml);
  509. }