void Logging::logUcLinkTransmission(stc_frame f) { //#time,src,frame_id,mac_src, mac_dst,time_sent,time_ack,retransmissions #ifndef PERFORMANCE_LOGGING_UC_LINK_FRAMES return; #endif string entry = getIntAsString(getMillisecondsTime()) + ","; /* src hostname */ entry += f.hostname_source + ","; /* frame id */ entry += getIntAsString(f.frame_id) + ","; /* mac src */ entry += ","; /* mac dst */ entry += getMacAsStr(f.mac) + ","; /* time_sent*/ entry += getIntAsString(f.ts) + ","; /* time_ack*/ entry += getIntAsString(getMillisecondsTime()) + ","; /*retransmissions*/ entry += getIntAsString(f.retransmitted) + ","; entries_link_frames.push_back(entry); }
void Logging::logRRequestIntermediate(RouteRequest* r) { #ifndef PERFORMANCE_LOGGING return; #endif /*rreq_intermediate.csv (log upon every received route request): #time,rreq_id,src,rcvd_from time : timestamp (ms) rreq_id : ID of the route request src : source of the route request rcvd_from : robot the route request was received from*/ std::string entry = ""; /* time stamp */ entry += getIntAsString(getMillisecondsTime()) + ","; /* rreq_id */ entry += getIntAsString(r->header_.id) + ","; /* src host */ entry += r->hostname_source_ + ","; /* rcvd_from */ entry += getMacAsStr(r->eh_h_.eh_source).c_str(); entries_rreq_interm.push_back(entry); }
Packet::Packet(RoutedFrame frame) { this->id_ = frame.header_.packet_id; this->size_ = frame.header_.packet_size; this->data_type_ = frame.header_.payload_type; this->ts_ = getMillisecondsTime(); this->frames_l_.clear(); this->topic_ = frame.topic_; this->hostname_source_ = frame.hostname_source_; this->mc_group_ = frame.mc_g_name_; this->missed_sequences_l_.clear(); highest_seq = 0; ts_last_frame_request = 0; }
void Logging::logRRequestReceiver(std::string h_src, uint32_t id, uint16_t counter, uint16_t hobs, bool selected, std::list<mac> path_l) { #ifndef PERFORMANCE_LOGGING return; #endif /*rreq_receiver.csv (log upon every received route request): #time,rreq_id,counter,route_length,selected,route time : timestamp (ms) rreq_id : The unique ID of the route request * src counter : the 'counter' received route request route_length : If route received, length of the route selected : If this route is selected and returned to the source route : The route received in the form 'src|robot_A|robot_B|dst' */ std::string entry = ""; /* time stamp */ entry += getIntAsString(getMillisecondsTime()) + ","; /* rreq_id */ entry += getIntAsString(id) + ","; /* src host */ entry += h_src + ","; /* counter */ entry += getIntAsString(counter) + ","; /* route_length */ entry += getIntAsString(hobs) + ","; /* selected */ if (selected) entry += "1,"; else entry += "0,"; /* path list */ entry += getPathAsStr(path_l); entries_rreq_recv.push_back(entry); }
void Logging::logRoutingTable(std::list<routing_entry>* u_entries, std::list<McTree*>* m_entries) { #ifndef PERFORMANCE_LOGGING return; #endif uint32_t num_cr_entries = 0, num_unicast_entries = 0, num_multicast_entries = m_entries->size(); std::size_t size = 0; for (std::list<routing_entry>::iterator i = u_entries->begin(); i != u_entries->end(); i++) { routing_entry r = *i; size += sizeof (r); if (r.cr_entry) num_cr_entries++; else { num_unicast_entries++; } } for (std::list<McTree*>::iterator i = m_entries->begin(); i != m_entries->end(); i++) { McTree* m = *i; size += sizeof (*m); } entries_r_table.push_back(getIntAsString(getMillisecondsTime()) + "," + getIntAsString(num_cr_entries) + "," + getIntAsString(num_unicast_entries) + "," + getIntAsString(num_multicast_entries) + "," + getIntAsString(size)); }
void Logging::logTransportFrame(stc_RoutedFrame* f, routing_entry* route, unsigned long start_time, unsigned long end_time, bool success) { // #time,id,dst,retransmissions,start_time,end_time,success,route_length,route,multicast ; string entry = getIntAsString(getMillisecondsTime()) + ","; /* id */ entry += getIntAsString(f->frame.header_.frame_id) + ","; /* dst */ entry += route->hostname_destination + ","; /* retransmissions */ entry += getIntAsString(f->retransmitted)+","; /* start_time */ entry += getIntAsString(start_time) + ","; /* end_time */ entry += getIntAsString(end_time) + ","; /* success */ entry += getBoolAsString(success) + ","; /*route_length*/ entry += getIntAsString(route->hobs) + ","; /* route*/ entry += getPathAsStr(route->mac_path_l) + ","; /* multicast */ entry += getIntAsString(f->frame.mc_flag) + ","; entries_transport_frames.push_back(entry); }
bool Packet::addFrame(RoutedFrame f) { /* Description: * Add the frame to the frame list of the packet, if the frame belongs to * the packet. * This method is needed to build up the packet on the receiver side. * The method also checks, if frames are received in the right order. * * * Returns: * (true) if packet is complete and ready to publish * * (false) in every other case */ this->ts_ = getMillisecondsTime(); if (this->size_ == this->frames_l_.size()) return true; if (this->highest_seq < f.header_.packet_sequence_num) this->highest_seq = f.header_.packet_sequence_num; if (this->isMcFrame() && this->frameAlreadyExsits(f) == true) { this->refreshLists(); return false; } if (frames_l_.size() == 0 && f.header_.packet_sequence_num != 0) { for (uint32_t mis_seq = 0; mis_seq < f.header_.packet_sequence_num; mis_seq++) missed_sequences_l_.push_back(mis_seq); } if (f.header_.packet_id != this->id_) { ROS_ERROR("packet error"); exit(22); } if ((unsigned)frames_l_.size() < size_) { bool missed_sequence_frame = false; /* check if frame is on with a missed sequence*/ for (std::list<uint32_t>::iterator it = missed_sequences_l_.begin(); it != missed_sequences_l_.end(); ++it) { if (f.header_.packet_sequence_num == *it) { // ROS_ERROR("Frame was in missed squ // %u",f.header_.packet_sequence_num); missed_sequence_frame = true; missed_sequences_l_.erase(it); // todo try remove break; } } if (!missed_sequence_frame) { // std::list<RoutedFrame>::reverse_iterator iter = // frames_l_.rbegin(); //points to the last instered frame RoutedFrame &last_frame(*frames_l_.rbegin()); /*Check if the new frame has the expected sequence*/ if (last_frame.header_.packet_sequence_num == f.header_.packet_sequence_num - 1 || frames_l_.size() == 0) { frames_l_.push_back(f); } else if (last_frame.header_.packet_sequence_num < f.header_.packet_sequence_num) { /*Insert all sequence numbers between the current incoming frame * and the last inserted one*/ for (uint32_t i = 1; i < f.header_.packet_sequence_num - last_frame.header_.packet_sequence_num; i++) { missed_sequences_l_.push_front( last_frame.header_.packet_sequence_num + i); } frames_l_.push_back(f); } else { // this->refreshLists(); // return this->addFrame(f); } } /*Missed sequence frame*/ else { frames_l_.push_front(f); } if (frames_l_.size() == size_) { this->wrong_sequence_ = true; sortFrameList(); return frames_l_.size() == size_; } else return false; } return false; }
void Logging::logUcPacketsSummary(unsigned long interval_ms) { #ifndef PERFORMANCE_LOGGING return; #endif #ifndef PERFORMANCE_LOGGING_UC_LINK_SUMMARY return; #endif while (ros::ok()) { sleepMS(interval_ms); string entry = getIntAsString(getMillisecondsTime()) + ","; { boost::unique_lock<boost::mutex> lock(Logging::mtx_logging); uint32_properties["num_total_frames_sent"] = 0; uint32_properties["num_total_frames_received"] = 0; } /* num_unique_data_frames_sent */ entry += getIntAsString(getProperty("num_unique_data_frames_sent")) + ","; increaseProperty("num_total_frames_sent", getProperty("num_unique_data_frames_sent")); /* getProperty("num_unique_data_frames_forwarded*/ entry += getIntAsString(getProperty("num_unique_data_frames_forwarded")) + ","; increaseProperty("num_total_frames_sent", getProperty("num_unique_data_frames_forwarded")); /* num_data_frames_resent*/ entry += getIntAsString(getProperty("num_data_frames_resent")) + ","; increaseProperty("num_total_frames_sent", getProperty("num_data_frames_resent")); /* num_data_frames_reforwarded*/ entry += getIntAsString(getProperty("num_data_frames_reforwarded")) + ","; increaseProperty("num_total_frames_sent", getProperty("num_data_frames_reforwarded")); /* num_data_frames_relayed*/ entry += getIntAsString(getProperty("num_data_frames_relayed")) + ","; increaseProperty("num_total_frames_sent", getProperty("num_data_frames_relayed")); /*num_acknowledgments_sent */ entry += getIntAsString(getProperty("num_acknowledgments_sent")) + ","; increaseProperty("num_total_frames_sent", getProperty("num_acknowledgments_sent")); /* getProperty("num_acknowledgments_relayed*/ entry += getIntAsString(getProperty("num_acknowledgments_relayed")) + ","; increaseProperty("num_total_frames_sent", getProperty("num_acknowledgments_relayed")); /* num_rreq_sent*/ entry += getIntAsString(getProperty("num_rreq_sent")) + ","; increaseProperty("num_total_frames_sent", getProperty("num_rreq_sent")); /* num_rrep_sent*/ entry += getIntAsString(getProperty("num_rrep_sent")) + ","; increaseProperty("num_total_frames_sent", getProperty("num_rrep_sent")); /*num_beacons_sent */ entry += getIntAsString(getProperty("num_beacons_sent")) + ","; increaseProperty("num_total_frames_sent", getProperty("num_beacons_sent")); /*num_relay_selection_sent */ entry += getIntAsString(getProperty("num_relay_selection_sent")) + ","; increaseProperty("num_total_frames_sent", getProperty("num_relay_selection_sent")); /*num_relay_detection_sent */ entry += getIntAsString(getProperty("num_relay_detection_sent")) + ","; increaseProperty("num_total_frames_sent", getProperty("num_relay_detection_sent")); /*num_total_frames_sent */ entry += getIntAsString(getProperty("num_total_frames_sent")) + ","; // num_total_frames_received = 0; /*num_unique_data_frames_received_directly */ entry += getIntAsString(getProperty("num_unique_data_frames_received_directly")) + ","; /*num_unique_data_frames_received_relay */ increaseProperty("num_total_frames_received", getProperty("num_unique_data_frames_received_relay")); entry += getIntAsString(getProperty("num_unique_data_frames_received_relay")) + ","; /*num_data_frames_received_directly */ increaseProperty("num_total_frames_received", getProperty("num_data_frames_received_directly")); entry += getIntAsString(getProperty("num_data_frames_received_directly")) + ","; /*num_data_frames_received_relay */ increaseProperty("num_total_frames_received", getProperty("num_data_frames_received_relay")); entry += getIntAsString(getProperty("num_data_frames_received_relay")) + ","; /*num_acknowledgments_received_directly */ increaseProperty("num_total_frames_received", getProperty("num_acknowledgments_received_directly")); entry += getIntAsString(getProperty("num_acknowledgments_received_directly")) + ","; /*num_acknowledgments_received_relay */ increaseProperty("num_total_frames_received", getProperty("num_acknowledgments_received_relay")); entry += getIntAsString(getProperty("num_acknowledgments_received_relay")) + ","; /*num_rreq_received */ increaseProperty("num_total_frames_received", getProperty("num_rreq_received")); entry += getIntAsString(getProperty("num_rreq_received")) + ","; /*num_rrep_received */ increaseProperty("num_total_frames_received", getProperty("num_rrep_received")); entry += getIntAsString(getProperty("num_rrep_received")) + ","; /*num_relay_selection_received */ increaseProperty("num_total_frames_received", getProperty("num_relay_selection_received")); entry += getIntAsString(getProperty("num_relay_selection_received")) + ","; /*num_relay_detection_received */ increaseProperty("num_total_frames_received", getProperty("num_relay_detection_received")); entry += getIntAsString(getProperty("num_relay_detection_received")) + ","; /*num_duplicate_frames_received */ increaseProperty("num_total_frames_received", getProperty("num_duplicate_frames_received")); entry += getIntAsString(getProperty("num_duplicate_frames_received")) + ","; /*num_beacons_received */ increaseProperty("num_total_frames_received", getProperty("num_beacons_received")); entry += getIntAsString(getProperty("num_beacons_received")) + ","; /*um_total_frames_received */ entry += getIntAsString(getProperty("num_total_frames_received")) + ","; /*num_total_bytes_sent */ entry += getIntAsString(getProperty("num_total_bytes_sent")) + ","; /*num_total_bytes_received */ entry += getIntAsString(getProperty("num_total_bytes_received")) + ","; entries_uc_frames.push_back(entry); } }
void Logging::logMemoryConsumptionPackets(unsigned long interval_ms, boost::mutex* mtx_pack, list<Packet>* packets, boost::mutex* mtx_cached_mc, list<Packet>* cached_mc, boost::mutex* mtx_unack_link_frames, list<stc_frame>* unack_link_frames, boost::mutex* mtx_unack_cr_frames, list<ack_cr_info>* unack_cr_frames) { #ifndef PERFORMANCE_LOGGING return; #endif while (ros::ok()) { sleepMS(interval_ms); string entry = getIntAsString(getMillisecondsTime()) + ","; std::size_t size_uc_pack = 0, size_mc_pack = 0, size_cached_mc_packets = 0, size_unack_l_f = 0, size_unack_cr_f = 0; { /* size_cached_multicast_packets complete */ boost::unique_lock<boost::mutex> lock_g(*mtx_cached_mc); for (list<Packet>::iterator i = cached_mc->begin(); i != cached_mc->end(); i++) { size_cached_mc_packets += (*i).getSize(); } entry += getIntAsString(size_cached_mc_packets) + ","; } { /* size_multicast_packets_incomplete + size_unicast_packets_incomplete */ boost::unique_lock<boost::mutex> lock_g(*mtx_pack); for (list<Packet>::iterator i = packets->begin(); i != packets->end(); i++) { if ((*i).isMcFrame()) size_mc_pack += (*i).getSize(); else size_uc_pack += (*i).getSize(); } entry += getIntAsString(size_mc_pack) + ","; entry += getIntAsString(size_uc_pack) + ","; } { /* size unack link frames */ boost::unique_lock<boost::mutex> lock_g(*mtx_unack_link_frames); for (list<stc_frame>::iterator i = unack_link_frames->begin(); i != unack_link_frames->end(); i++) size_unack_l_f += sizeof (*i); entry += getIntAsString(size_unack_l_f) + ","; } { /* size unack cr frames */ boost::unique_lock<boost::mutex> lock_g(*mtx_unack_cr_frames); for (list<ack_cr_info>::iterator i = unack_cr_frames->begin(); i != unack_cr_frames->end(); i++) size_unack_cr_f += sizeof (*i); entry += getIntAsString(size_unack_cr_f) + ","; } entry += getIntAsString(getProperty("running_unicast_link_threads")) + ","; entry += getIntAsString(getProperty("running_multicast_threads")) + ","; entry += getIntAsString(getProperty("running_unicast_cr_threads")) + ","; entry += getIntAsString(getProperty("running_unicast_transport_threads")) + ","; entries_mem_consumption.push_back(entry); } }
void Logging::logRRequestInitiater(route_request* req, routing_entry* route) { #ifndef PERFORMANCE_LOGGING return; #endif /*rreq_initiater.csv (log upon every initiated route request): #time,rreq_id,dst,start_time,end_time,num_rrep_rcvd,num_rreq_sent,route_length,route, multicast time : timestamp (ms) rreq_id : The unique ID of the route request dst : destination of the route request start_time : Time the rreq was sent (ms) end_time : Time the rrep was received (if any, otherwise empty/0) num_rrep_rcvd : Number of received routes num_rreq_sent : Number of route request sent, if multiple where unsuccessful route_length : If route received, length of the route route : The route selected in the form of the mac path multicast : true if multicast, unicast false*/ std::string entry = ""; /* time stamp */ entry += getIntAsString(getMillisecondsTime()) + ","; /* rreq_id */ entry += getIntAsString(req->id) + ","; /* dst */ entry += req->hostname_destination + ","; /* time sent */ entry += getIntAsString(req->ts) + ","; /* time recv */ if (route != NULL) entry += getIntAsString(route->ts) + ","; else entry += ","; /* num_rrep_rcvd */ entry += "1,"; /* num_rreq_sent */ entry += getIntAsString(req->retransmitted) + ","; /* route len */ if (route != NULL) entry += getIntAsString(route->hobs) + ","; else entry += ","; /* path list */ if (route != NULL) { entry += getPathAsStr(route->mac_path_l); } /* multicast*/ entry += "," + getIntAsString(req->is_mc); entries_rreq_initi.push_back(entry); }
void Logging::logServiceCalls(string service_name, unsigned long time_call, unsigned long time_res, unsigned long size, bool ret_val) { entries_service_calls.push_back(getIntAsString(getMillisecondsTime()) + "," + service_name.c_str() + "," + getIntAsString(time_call) + "," + getIntAsString(time_res) + "," + getIntAsString(size) + "," + getIntAsString(ret_val)); }
void Logging::logMcPacketsSummary(unsigned long interval_ms) { #ifndef PERFORMANCE_LOGGING return; #endif #ifndef PERFORMANCE_LOGGING_MC_LINK_SUMMARY return; #endif while (ros::ok()) { sleepMS(interval_ms); string entry = getIntAsString(getMillisecondsTime()) + ","; /*num_mc_unique_data_frames_sent */ entry += getIntAsString(getProperty("num_mc_unique_data_frames_sent")) + ","; increaseProperty("num_mc_total_frames_sent", getProperty("num_mc_unique_data_frames_sent")); /* num_mc_unique_data_frames_forwarded*/ entry += getIntAsString(getProperty("num_mc_unique_data_frames_forwarded")) + ","; increaseProperty("num_mc_total_frames_sent", getProperty("num_mc_unique_data_frames_forwarded")); /* num_mc_data_frames_resent*/ entry += getIntAsString(getProperty("num_mc_data_frames_resent")) + ","; increaseProperty("num_mc_total_frames_sent", getProperty("num_mc_data_frames_resent")); /* num_mc_data_frames_reforwarded*/ entry += getIntAsString(getProperty("num_mc_data_frames_reforwarded")) + ","; increaseProperty("num_mc_total_frames_sent", getProperty("num_mc_data_frames_reforwarded")); /* num_mc_data_frames_relayed*/ entry += getIntAsString(getProperty("num_mc_data_frames_relayed")) + ","; increaseProperty("num_mc_total_frames_sent", getProperty("num_mc_data_frames_relayed")); /*num_mc_acknowledgments_sent */ entry += getIntAsString(getProperty("num_mc_acknowledgments_sent")) + ","; increaseProperty("num_mc_total_frames_sent", getProperty("num_mc_acknowledgments_sent")); /* num_mc_acknowledgments_relayed*/ entry += getIntAsString(getProperty("num_mc_acknowledgments_relayed")) + ","; increaseProperty("num_mc_total_frames_sent", getProperty("num_mc_acknowledgments_relayed")); /* num_mc_rreq_sent*/ entry += getIntAsString(getProperty("num_mc_rreq_sent")) + ","; increaseProperty("num_mc_total_frames_sent", getProperty("num_mc_rreq_sent")); /* num_mc_rrep_sent*/ entry += getIntAsString(getProperty("num_mc_rrep_sent")) + ","; increaseProperty("num_mc_total_frames_sent", getProperty("num_mc_rrep_sent")); /*num_mc_ract_sent */ entry += getIntAsString(getProperty("num_mc_ract_sent")) + ","; increaseProperty("num_mc_total_frames_sent", getProperty("num_mc_ract_sent")); /*num_mc_relay_selection_sent */ entry += getIntAsString(getProperty("num_mc_relay_selection_sent")) + ","; increaseProperty("num_mc_total_frames_sent", getProperty("num_mc_relay_selection_sent")); /*num_mc_total_frames_sent */ entry += getIntAsString(getProperty("num_mc_total_frames_sent")) + ","; /*num_mc_unique_data_frames_received_directly */ increaseProperty("num_mc_total_frames_received", getProperty("num_mc_unique_data_frames_received_directly")); entry += getIntAsString(getProperty("num_mc_unique_data_frames_received_directly")) + ","; /*num_mc_unique_data_frames_received_relay */ increaseProperty("num_mc_total_frames_received", getProperty("num_mc_unique_data_frames_received_relay")); entry += getIntAsString(getProperty("num_mc_unique_data_frames_received_relay")) + ","; /*num_mc_data_frames_received_directly */ increaseProperty("num_mc_total_frames_received", getProperty("num_mc_data_frames_received_directly")); entry += getIntAsString(getProperty("num_mc_data_frames_received_directly")) + ","; /*num_mc_data_frames_received_relay */ increaseProperty("num_mc_total_frames_received", getProperty("num_mc_data_frames_received_relay")); entry += getIntAsString(getProperty("num_mc_data_frames_received_relay")) + ","; /*num_mc_acknowledgments_received_directly */ increaseProperty("num_mc_total_frames_received", getProperty("num_mc_acknowledgments_received_directly")); entry += getIntAsString(getProperty("num_mc_acknowledgments_received_directly")) + ","; /*num_mc_acknowledgments_received_relay */ increaseProperty("num_mc_total_frames_received", getProperty("num_mc_acknowledgments_received_relay")); entry += getIntAsString(getProperty("num_mc_acknowledgments_received_relay")) + ","; /*num_mc_rreq_received */ increaseProperty("num_mc_total_frames_received", getProperty("num_mc_rreq_received")); entry += getIntAsString(getProperty("num_mc_rreq_received")) + ","; /*num_mc_rrep_received */ increaseProperty("num_mc_total_frames_received", getProperty("num_mc_rrep_received")); entry += getIntAsString(getProperty("num_mc_rrep_received")) + ","; /*num_mc_ract_received */ increaseProperty("num_mc_total_frames_received", getProperty("num_mc_ract_received")); entry += getIntAsString(getProperty("num_mc_ract_received")) + ","; /*num_mc_relay_selection_received */ increaseProperty("num_mc_total_frames_received", getProperty("num_mc_relay_selection_received")); entry += getIntAsString(getProperty("num_mc_relay_selection_received")) + ","; /*num_mc_duplicate_frames_received */ increaseProperty("num_mc_total_frames_received", getProperty("num_mc_duplicate_frames_received")); entry += getIntAsString(getProperty("num_mc_duplicate_frames_received")) + ","; /*num_mc_total_frames_received */ entry += getIntAsString(getProperty("num_mc_total_frames_received")) + ","; /*num_mc_total_frames_received */ entry += getIntAsString(getProperty("num_mc_total_bytes_sent")) + ","; /*num_mc_total_frames_received */ entry += getIntAsString(getProperty("num_mc_total_bytes_received")) + ","; entries_mc_frames.push_back(entry); } }