Ipv4EndPoint * Ipv4EndPointDemux::Allocate (uint16_t port) { NS_LOG_FUNCTION (this << port); return Allocate (Ipv4Address::GetAny (), port); }
void FileHelper::Set2dFormat (const std::string &format) { NS_LOG_FUNCTION (this << format); m_2dFormat = format; }
int64_t RedQueue::AssignStreams (int64_t stream) { NS_LOG_FUNCTION (this << stream); m_uv->SetStream (stream); return 1; }
PendingData::PendingData(const std::string& s) : size (s.length () + 1), data (0), msgSize (0), responseSize (0) { NS_LOG_FUNCTION (this << s.length () + 1); data.push_back (Create<Packet> ((uint8_t*)s.c_str (), size)); }
Ptr<FileAggregator> FileHelper::GetAggregatorSingle () { NS_LOG_FUNCTION (this); // Do a lazy construction of the single aggregator if it hasn't // already been constructed. if (!m_aggregator) { // Create the aggregator. std::string outputFileName = m_outputFileNameWithoutExtension + ".txt"; m_aggregator = CreateObject<FileAggregator> (outputFileName, m_fileType); // Set all of the format strings for the aggregator. m_aggregator->Set1dFormat (m_1dFormat); m_aggregator->Set2dFormat (m_2dFormat); m_aggregator->Set3dFormat (m_3dFormat); m_aggregator->Set4dFormat (m_4dFormat); m_aggregator->Set5dFormat (m_5dFormat); m_aggregator->Set6dFormat (m_6dFormat); m_aggregator->Set7dFormat (m_7dFormat); m_aggregator->Set8dFormat (m_8dFormat); m_aggregator->Set9dFormat (m_9dFormat); m_aggregator->Set10dFormat (m_10dFormat); // Set the heading m_aggregator->SetHeading (m_heading); // Enable logging of data for the aggregator. m_aggregator->Enable (); } return m_aggregator; }
bool PacketQueue::Enqueue (QueueEntry & entry) { NS_LOG_FUNCTION ("Enqueing packet destined for" << entry.GetIpv4Header ().GetDestination ()); Purge (); uint32_t numPacketswithdst; for (std::vector<QueueEntry>::const_iterator i = m_queue.begin (); i != m_queue.end (); ++i) { if ((i->GetPacket ()->GetUid () == entry.GetPacket ()->GetUid ()) && (i->GetIpv4Header ().GetDestination () == entry.GetIpv4Header ().GetDestination ())) { return false; } } numPacketswithdst = GetCountForPacketsWithDst (entry.GetIpv4Header ().GetDestination ()); NS_LOG_DEBUG ("Number of packets with this destination: " << numPacketswithdst); /** For Brock Paper comparision*/ if (numPacketswithdst >= m_maxLenPerDst || m_queue.size () >= m_maxLen) { NS_LOG_DEBUG ("Max packets reached for this destination. Not queuing any further packets"); return false; } else { // NS_LOG_DEBUG("Packet size while enqueing "<<entry.GetPacket()->GetSize()); entry.SetExpireTime (m_queueTimeout); m_queue.push_back (entry); return true; } }
uint32_t PendingData::SizeFromOffset (uint32_t offset) { // Find out how much data is available from offset NS_LOG_FUNCTION (this << offset); /// \todo should this return zero, or error out? if (offset > size) return 0; // No data at requested offset return size - offset; // Available data after offset }
PhyTxStatsCalculator::PhyTxStatsCalculator () : m_dlTxFirstWrite (true), m_ulTxFirstWrite (true) { NS_LOG_FUNCTION (this); }
Vector3D::Vector3D (double _x, double _y, double _z) : x (_x), y (_y), z (_z) { NS_LOG_FUNCTION (this << _x << _y << _z); }
void ByteTagList::AddAtStart (int32_t adjustment, int32_t prependOffset) { NS_LOG_FUNCTION (this << adjustment << prependOffset); if (adjustment == 0 && !IsDirtyAtStart (prependOffset)) { return; } ByteTagList list; ByteTagList::Iterator i = BeginAll (); while (i.HasNext ()) { ByteTagList::Iterator::Item item = i.Next (); item.start += adjustment; item.end += adjustment; if (item.end <= prependOffset) { continue; } else if (item.end > prependOffset && item.start < prependOffset) { item.start = prependOffset; } else { // nothing to do. } TagBuffer buf = list.Add (item.tid, item.size, item.start, item.end); buf.CopyFrom (item.buf); } *this = list; }
struct ByteTagListData * ByteTagList::Allocate (uint32_t size) { NS_LOG_FUNCTION (this << size); while (!g_freeList.empty ()) { struct ByteTagListData *data = g_freeList.back (); g_freeList.pop_back (); NS_ASSERT (data != 0); if (data->size >= size) { data->count = 1; data->dirty = 0; return data; } uint8_t *buffer = (uint8_t *)data; delete [] buffer; } uint8_t *buffer = new uint8_t [std::max (size, g_maxSize) + sizeof (struct ByteTagListData) - 4]; struct ByteTagListData *data = (struct ByteTagListData *)buffer; data->count = 1; data->size = size; data->dirty = 0; return data; }
TagBuffer ByteTagList::Add (TypeId tid, uint32_t bufferSize, int32_t start, int32_t end) { NS_LOG_FUNCTION (this << tid << bufferSize << start << end); uint32_t spaceNeeded = m_used + bufferSize + 4 + 4 + 4 + 4; NS_ASSERT (m_used <= spaceNeeded); if (m_data == 0) { m_data = Allocate (spaceNeeded); m_used = 0; } else if (m_data->size < spaceNeeded || (m_data->count != 1 && m_data->dirty != m_used)) { struct ByteTagListData *newData = Allocate (spaceNeeded); std::memcpy (&newData->data, &m_data->data, m_used); Deallocate (m_data); m_data = newData; } TagBuffer tag = TagBuffer (&m_data->data[m_used], &m_data->data[spaceNeeded]); tag.WriteU32 (tid.GetUid ()); tag.WriteU32 (bufferSize); tag.WriteU32 (start); tag.WriteU32 (end); m_used = spaceNeeded; m_data->dirty = m_used; return tag; }
ByteTagList::~ByteTagList () { NS_LOG_FUNCTION (this); Deallocate (m_data); m_data = 0; m_used = 0; }
Ipv4EndPoint * Ipv4EndPointDemux::Allocate (Ipv4Address localAddress, uint16_t localPort, Ipv4Address peerAddress, uint16_t peerPort) { NS_LOG_FUNCTION (this << localAddress << localPort << peerAddress << peerPort); for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++) { if ((*i)->GetLocalPort () == localPort && (*i)->GetLocalAddress () == localAddress && (*i)->GetPeerPort () == peerPort && (*i)->GetPeerAddress () == peerAddress) { NS_LOG_WARN ("No way we can allocate this end-point."); /* no way we can allocate this end-point. */ return 0; } } Ipv4EndPoint *endPoint = new Ipv4EndPoint (localAddress, localPort); endPoint->SetPeer (peerAddress, peerPort); m_endPoints.push_back (endPoint); NS_LOG_DEBUG ("Now have >>" << m_endPoints.size () << "<< endpoints."); return endPoint; }
Ptr<Packet> RedQueue::DoDequeue (void) { NS_LOG_FUNCTION (this); if (m_packets.empty ()) { NS_LOG_LOGIC ("Queue empty"); m_idle = 1; m_idleTime = Simulator::Now (); return 0; } else { m_idle = 0; Ptr<Packet> p = m_packets.front (); m_packets.pop_front (); m_bytesInQueue -= p->GetSize (); NS_LOG_LOGIC ("Popped " << p); NS_LOG_LOGIC ("Number packets " << m_packets.size ()); NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue); return p; } }
Vector3D::Vector3D () : x (0.0), y (0.0), z (0.0) { NS_LOG_FUNCTION (this); }
void RadvdHelper::AddAnnouncedPrefix (uint32_t interface, Ipv6Address prefix, uint32_t prefixLength) { NS_LOG_FUNCTION(this << int(interface) << prefix << int(prefixLength)); if (prefixLength != 64) { NS_LOG_WARN("Adding a non-64 prefix is generally a bad idea. Autoconfiguration might not work."); } bool prefixFound = false; if (m_radvdInterfaces.find(interface) == m_radvdInterfaces.end()) { m_radvdInterfaces[interface] = Create<RadvdInterface> (interface); } else { RadvdInterface::RadvdPrefixList prefixList = m_radvdInterfaces[interface]->GetPrefixes(); RadvdInterface::RadvdPrefixListCI iter; for (iter=prefixList.begin(); iter!=prefixList.end(); iter++) { if ((*iter)->GetNetwork() == prefix) { NS_LOG_LOGIC("Not adding the same prefix twice, skipping " << prefix << " " << int(prefixLength)); prefixFound = true; break; } } } if (!prefixFound) { Ptr<RadvdPrefix> routerPrefix = Create<RadvdPrefix> (prefix, prefixLength); m_radvdInterfaces[interface]->AddPrefix(routerPrefix); } }
void BuildingsPathlossTestCase::DoRun (void) { NS_LOG_FUNCTION (this); // the building basically occupies the negative x plane, so any node // in this area will fall in the building Ptr<Building> building1 = CreateObject<Building> (); building1->SetBoundaries (Box (-3000, -1, -4000, 4000.0, 0.0, 12)); building1->SetBuildingType (Building::Residential); building1->SetExtWallsType (Building::ConcreteWithWindows); building1->SetNFloors (3); Ptr<MobilityModel> mma = CreateMobilityModel (m_mobilityModelIndex1); Ptr<MobilityModel> mmb = CreateMobilityModel (m_mobilityModelIndex2); Ptr<HybridBuildingsPropagationLossModel> propagationLossModel = CreateObject<HybridBuildingsPropagationLossModel> (); propagationLossModel->SetAttribute ("Frequency", DoubleValue (m_freq)); propagationLossModel->SetAttribute ("Environment", EnumValue (m_env)); propagationLossModel->SetAttribute ("CitySize", EnumValue (m_city)); // cancel shadowing effect propagationLossModel->SetAttribute ("ShadowSigmaOutdoor", DoubleValue (0.0)); propagationLossModel->SetAttribute ("ShadowSigmaIndoor", DoubleValue (0.0)); propagationLossModel->SetAttribute ("ShadowSigmaExtWalls", DoubleValue (0.0)); double loss = propagationLossModel->GetLoss (mma, mmb); NS_LOG_INFO ("Calculated loss: " << loss); NS_LOG_INFO ("Theoretical loss: " << m_lossRef); NS_TEST_ASSERT_MSG_EQ_TOL (loss, m_lossRef, 0.1, "Wrong loss !"); Simulator::Destroy (); }
shared_ptr<Data> ContentStoreImpl<Policy>::Lookup(shared_ptr<const Interest> interest) { NS_LOG_FUNCTION(this << interest->getName()); typename super::const_iterator node; if (interest->getExclude().empty()) { node = this->deepest_prefix_match(interest->getName()); } else { node = this->deepest_prefix_match_if_next_level(interest->getName(), isNotExcluded(interest->getExclude())); } if (node != this->end()) { this->m_cacheHitsTrace(interest, node->payload()->GetData()); shared_ptr<Data> copy = make_shared<Data>(*node->payload()->GetData()); return copy; } else { this->m_cacheMissesTrace(interest); return 0; } }
void SpectrumInterference::AddSignal (Ptr<const SpectrumValue> spd, const Time duration) { NS_LOG_FUNCTION (this << *spd << duration); DoAddSignal (spd); Simulator::Schedule (duration, &SpectrumInterference::DoSubtractSignal, this, spd); }
uint32_t PendingData::RemoveToSeq (const SequenceNumber32& seqFront, const SequenceNumber32& seqOffset) { NS_LOG_FUNCTION (this << seqFront << seqOffset); uint32_t count = OffsetFromSeq (seqFront, seqOffset); NS_ASSERT_MSG (count <= size, "Trying to remove more data than in the buffer"); if (count == size) { Clear (); return size; } // Remove whole packets, if possible, from the front of the data // Do not perform buffer manipulations within packet; if a whole packet // cannot be removed, leave it alone std::vector<Ptr<Packet> >::iterator endI = data.begin (); uint32_t current = 0; // Any packet whose data has been completely acked can be removed for (std::vector<Ptr<Packet> >::iterator dataI = data.begin (); dataI < data.end (); dataI++) { if (current + (*dataI)->GetSize () > count) { break; } current += (*dataI)->GetSize (); ++endI; } data.erase (data.begin (), endI); size -= current; return current; }
// callback void NetDeviceFace::receiveFromNetDevice(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address& from, const Address& to, NetDevice::PacketType packetType) { NS_LOG_FUNCTION(device << p << protocol << from << to << packetType); Ptr<Packet> packet = p->Copy(); try { uint32_t type = Convert::getPacketType(p); if (type == ::ndn::tlv::Interest) { shared_ptr<const Interest> i = Convert::FromPacket<Interest>(packet); this->emitSignal(onReceiveInterest, *i); } else if (type == ::ndn::tlv::Data) { shared_ptr<const Data> d = Convert::FromPacket<Data>(packet); this->emitSignal(onReceiveData, *d); } else { NS_LOG_ERROR("Unsupported TLV packet"); } } catch (::ndn::tlv::Error&) { NS_LOG_ERROR("Unrecognized TLV packet"); } }
void FileHelper::AddProbe (const std::string &typeId, const std::string &probeName, const std::string &path) { NS_LOG_FUNCTION (this << typeId << probeName << path); // See if this probe had already been added. if (m_probeMap.count (probeName) > 0) { NS_ABORT_MSG ("That probe has already been added"); } // Prepare the factory to create an object with the requested type. m_factory.SetTypeId (typeId); // Create a base class object in order to validate the type. Ptr<Probe> probe = m_factory.Create ()->GetObject<Probe> (); if (probe == 0) { NS_ABORT_MSG ("The requested type is not a probe"); } // Set the probe's name. probe->SetName (probeName); // Set the path. Note that no return value is checked here. probe->ConnectByPath (path); // Enable logging of data for the probe. probe->Enable (); // Add this probe to the map so that its values can be used. m_probeMap[probeName] = std::make_pair (probe, typeId); }
void PacketProbe::ConnectByPath (std::string path) { NS_LOG_FUNCTION (this << path); NS_LOG_DEBUG ("Name of probe to search for in config database: " << path); Config::ConnectWithoutContext (path, MakeCallback (&ns3::PacketProbe::TraceSink, this)); }
// Check if packet p needs to be dropped due to probability mark uint32_t RedQueue::DropEarly (Ptr<Packet> p, uint32_t qSize) { NS_LOG_FUNCTION (this << p << qSize); m_vProb1 = CalculatePNew (m_qAvg, m_maxTh, m_isGentle, m_vA, m_vB, m_vC, m_vD, m_curMaxP); m_vProb = ModifyP (m_vProb1, m_count, m_countBytes, m_meanPktSize, m_isWait, p->GetSize ()); // Drop probability is computed, pick random number and act if (m_cautious == 1) { /* * Don't drop/mark if the instantaneous queue is much below the average. * For experimental purposes only. * pkts: the number of packets arriving in 50 ms */ double pkts = m_ptc * 0.05; double fraction = std::pow ((1 - m_qW), pkts); if ((double) qSize < fraction * m_qAvg) { // Queue could have been empty for 0.05 seconds return 0; } } double u = m_uv->GetValue (); if (m_cautious == 2) { /* * Decrease the drop probability if the instantaneous * queue is much below the average. * For experimental purposes only. * pkts: the number of packets arriving in 50 ms */ double pkts = m_ptc * 0.05; double fraction = std::pow ((1 - m_qW), pkts); double ratio = qSize / (fraction * m_qAvg); if (ratio < 1.0) { u *= 1.0 / ratio; } } if (u <= m_vProb) { NS_LOG_LOGIC ("u <= m_vProb; u " << u << "; m_vProb " << m_vProb); // DROP or MARK m_count = 0; m_countBytes = 0; /// \todo Implement set bit to mark return 1; // drop } return 0; // no drop/mark }
void IpL4Protocol::ReceiveIcmp (Ipv6Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo, Ipv6Address payloadSource, Ipv6Address payloadDestination, const uint8_t payload[8]) { NS_LOG_FUNCTION (this << icmpSource << static_cast<uint32_t> (icmpTtl) << static_cast<uint32_t> (icmpType) << static_cast<uint32_t> (icmpCode) << icmpInfo << payloadSource << payloadDestination << payload); }
Bar::Bar (Ptr<const Packet> bar, Mac48Address recipient, uint8_t tid, bool immediate) : bar (bar), recipient (recipient), tid (tid), immediate (immediate) { NS_LOG_FUNCTION (this << bar << recipient << static_cast<uint32_t> (tid) << immediate); }
void RedQueue::SetTh (double minTh, double maxTh) { NS_LOG_FUNCTION (this << minTh << maxTh); NS_ASSERT (minTh <= maxTh); m_minTh = minTh; m_maxTh = maxTh; }
void CachingControllerApplication::HandleClientConfigurationInput(Ptr<Socket> HandleClientConfigurationInput) { NS_LOG_FUNCTION(this); std::ostringstream buf; HandleClientConfigurationInput->Recv()->CopyData(&buf, INT_MAX); HandleNewResourceAsked(buf.str()); }
void FileHelper::SetHeading (const std::string &heading) { NS_LOG_FUNCTION (this << heading); m_hasHeadingBeenSet = true; m_heading = heading; }