예제 #1
0
bool
CsmaChannel::Detach (uint32_t deviceId)
{
  NS_LOG_FUNCTION (this << deviceId);

  if (deviceId < m_deviceList.size ())
    {
      if (!m_deviceList[deviceId].active)
        {
          NS_LOG_WARN ("CsmaChannel::Detach(): Device is already detached (" << deviceId << ")");
          return false;
        }

      m_deviceList[deviceId].active = false;

      if ((m_state == TRANSMITTING) && (m_currentSrc == deviceId))
        {
          NS_LOG_WARN ("CsmaChannel::Detach(): Device is currently" << "transmitting (" << deviceId << ")");
        }

      return true;
    } 
  else 
    {
      return false;
    }
}
예제 #2
0
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);
    }
}
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;
}
예제 #4
0
void FceApplication::DoDispose(void) {
	running = false;
	double now = Simulator::Now().GetSeconds();
	if (m_socket != NULL) {
		m_socket->Close();
	} else {
		NS_LOG_WARN("FceApplication found null socket to close in StopApplication");
	}
	OvnisApplication::DoDispose();
}
Ipv4EndPoint *
Ipv4EndPointDemux::Allocate (Ipv4Address address, uint16_t port)
{
  NS_LOG_FUNCTION (this << address << port);
  if (LookupLocal (address, port)) 
    {
      NS_LOG_WARN ("Duplicate address/port; failing.");
      return 0;
    }
  Ipv4EndPoint *endPoint = new Ipv4EndPoint (address, port);
  m_endPoints.push_back (endPoint);
  NS_LOG_DEBUG ("Now have >>" << m_endPoints.size () << "<< endpoints.");
  return endPoint;
}
void
A2A4RsrqHandoverAlgorithm::EvaluateHandover (uint16_t rnti,
                                             uint8_t servingCellRsrq)
{
  NS_LOG_FUNCTION (this << rnti << (uint16_t) servingCellRsrq);

  MeasurementTable_t::iterator it1;
  it1 = m_neighbourCellMeasures.find (rnti);

  if (it1 == m_neighbourCellMeasures.end ())
    {
      NS_LOG_WARN ("Skipping handover evaluation for RNTI " << rnti << " because neighbour cells information is not found");
    }
  else
    {
      // Find the best neighbour cell (eNB)
      NS_LOG_LOGIC ("Number of neighbour cells = " << it1->second.size ());
      uint16_t bestNeighbourCellId = 0;
      uint8_t bestNeighbourRsrq = 0;
      MeasurementRow_t::iterator it2;
      for (it2 = it1->second.begin (); it2 != it1->second.end (); ++it2)
        {
          if ((it2->second->m_rsrq > bestNeighbourRsrq)
              && IsValidNeighbour (it2->first))
            {
              bestNeighbourCellId = it2->first;
              bestNeighbourRsrq = it2->second->m_rsrq;
            }
        }

      // Trigger Handover, if needed
      if (bestNeighbourCellId > 0)
        {
          NS_LOG_LOGIC ("Best neighbour cellId " << bestNeighbourCellId);

          if ((bestNeighbourRsrq - servingCellRsrq) >= m_neighbourCellOffset)
            {
              NS_LOG_LOGIC ("Trigger Handover to cellId " << bestNeighbourCellId);
              NS_LOG_LOGIC ("target cell RSRQ " << (uint16_t) bestNeighbourRsrq);
              NS_LOG_LOGIC ("serving cell RSRQ " << (uint16_t) servingCellRsrq);

              // Inform eNodeB RRC about handover
              m_handoverManagementSapUser->TriggerHandover (rnti,
                                                            bestNeighbourCellId);
            }
        }

    } // end of else of if (it1 == m_neighbourCellMeasures.end ())

} // end of EvaluateMeasurementReport
void
A2A4RsrqHandoverAlgorithm::DoReportUeMeas (uint16_t rnti,
                                           LteRrcSap::MeasResults measResults)
{
  NS_LOG_FUNCTION (this << rnti << (uint16_t) measResults.measId);

  if (measResults.measId == m_a2MeasId)
    {
      NS_ASSERT_MSG (measResults.rsrqResult <= m_servingCellThreshold,
                     "Invalid UE measurement report");
      EvaluateHandover (rnti, measResults.rsrqResult);
    }
  else if (measResults.measId == m_a4MeasId)
    {
      if (measResults.haveMeasResultNeighCells
          && !measResults.measResultListEutra.empty ())
        {
          for (std::list <LteRrcSap::MeasResultEutra>::iterator it = measResults.measResultListEutra.begin ();
               it != measResults.measResultListEutra.end ();
               ++it)
            {
              NS_ASSERT_MSG (it->haveRsrqResult == true,
                             "RSRQ measurement is missing from cellId " << it->physCellId);
              UpdateNeighbourMeasurements (rnti, it->physCellId, it->rsrqResult);
            }
        }
      else
        {
          NS_LOG_WARN (this << " Event A4 received without measurement results from neighbouring cells");
        }
    }
  else
    {
      NS_LOG_WARN ("Ignoring measId " << (uint16_t) measResults.measId);
    }

} // end of DoReportUeMeas
Ipv4EndPoint *
Ipv4EndPointDemux::Allocate (Ipv4Address address)
{
  NS_LOG_FUNCTION (this << address);
  uint16_t port = AllocateEphemeralPort ();
  if (port == 0) 
    {
      NS_LOG_WARN ("Ephemeral port allocation failed.");
      return 0;
    }
  Ipv4EndPoint *endPoint = new Ipv4EndPoint (address, port);
  m_endPoints.push_back (endPoint);
  NS_LOG_DEBUG ("Now have >>" << m_endPoints.size () << "<< endpoints.");
  return endPoint;
}
예제 #9
0
void
FileHelper::ConfigureFile (const std::string &outputFileNameWithoutExtension,
                           enum FileAggregator::FileType fileType)
{
  NS_LOG_FUNCTION (this << outputFileNameWithoutExtension << fileType);

  // See if an aggregator has already been constructed.
  if (m_aggregator != 0)
    {
      NS_LOG_WARN ("An existing aggregator object " << m_aggregator <<
                   " may be destroyed if no references remain.");
    }

  // Store these so that they can be used to construct the aggregator.
  m_fileType = fileType;
  m_outputFileNameWithoutExtension = outputFileNameWithoutExtension;
  m_hasHeadingBeenSet = false;

  // Note that this does not construct an aggregator. It will be
  // constructed later when needed.
}
예제 #10
0
void
Socket::SetIpv6Tclass (int tclass)
{
  Address address;
  GetSockName (address);

  //If -1 or invalid values, use default
  if (tclass == -1 || tclass < -1 || tclass > 0xff)
    {
      //Print a warning
      if (tclass < -1 || tclass > 0xff)
        {
          NS_LOG_WARN ("Invalid IPV6_TCLASS value. Using default.");
        }
      m_manualIpv6Tclass = false;
      m_ipv6Tclass = 0;
    }
  else
    {
      m_manualIpv6Tclass = true;
      m_ipv6Tclass = tclass;
    }
}
예제 #11
0
bool
CsmaChannel::TransmitStart (Ptr<Packet> p, uint32_t srcId)
{
  NS_LOG_FUNCTION (this << p << srcId);
  NS_LOG_INFO ("UID is " << p->GetUid () << ")");

  if (m_state != IDLE)
    {
      NS_LOG_WARN ("CsmaChannel::TransmitStart(): State is not IDLE");
      return false;
    }

  if (!IsActive (srcId))
    {
      NS_LOG_ERROR ("CsmaChannel::TransmitStart(): Seclected source is not currently attached to network");
      return false;
    }

  NS_LOG_LOGIC ("switch to TRANSMITTING");
  m_currentPkt = p;
  m_currentSrc = srcId;
  m_state = TRANSMITTING;
  return true;
}
예제 #12
0
void
LteAnr::DoReportUeMeas (LteRrcSap::MeasResults measResults)
{
  uint8_t measId = measResults.measId;
  NS_LOG_FUNCTION (this << m_servingCellId << (uint16_t) measId);

  if (measId != m_measId)
    {
      NS_LOG_WARN (this << " Skipping unexpected measurement identity " << (uint16_t) measId);
    }
  else
    {
      if (measResults.haveMeasResultNeighCells
          && !(measResults.measResultListEutra.empty ()))
        {
          for (std::list <LteRrcSap::MeasResultEutra>::iterator it = measResults.measResultListEutra.begin ();
               it != measResults.measResultListEutra.end ();
               ++it)
            {
              // Keep new RSRQ value reported for the neighbour cell
              NS_ASSERT_MSG (it->haveRsrqResult == true,
                             "RSRQ measure missing for cellId " << it->physCellId);

              // Update Neighbour Relation Table
              NeighbourRelationTable_t::iterator itNrt = m_neighbourRelationTable.find (it->physCellId);
              if (itNrt != m_neighbourRelationTable.end ())
                {
                  // Update neighbour relation entry
                  NS_LOG_LOGIC (this << " updating NRT of cell " << m_servingCellId
                                     << " with entry of cell " << it->physCellId);
                  if (itNrt->second.noX2 == false)
                    {
                      NS_LOG_LOGIC (this << " enabling handover"
                                         << " from cell " << m_servingCellId
                                         << " to cell " << it->physCellId);
                      itNrt->second.noHo = false;
                    }
                  itNrt->second.detectedAsNeighbour = true;
                }
              else
                {
                  // Discovered new neighbour
                  NS_LOG_LOGIC (this << " inserting NRT of cell " << m_servingCellId
                                     << " with newly discovered neighbouring cell "
                                     << it->physCellId);
                  NeighbourRelation_t neighbourRelation;
                  neighbourRelation.noRemove = false;
                  neighbourRelation.noHo = true;
                  neighbourRelation.noX2 = true;
                  neighbourRelation.detectedAsNeighbour = true;
                  m_neighbourRelationTable[it->physCellId] = neighbourRelation;
                }

            } // end of for (it = measResults.measResultListEutra.begin ())

        } // end of if (measResults.haveMeasResultNeighCells && !(measResults.measResultListEutra.empty ()))
      else
        {
          NS_LOG_WARN (this << " Event A4 received without measurement results from neighbouring cells");
          /// \todo Remove neighbours in the NRT.
        }

    } // end of else of if (measId != m_measId)

} // end of DoReportUeMeas
예제 #13
0
uint32_t
TcpRfc793::GetInitialCwnd (void) const
{
  NS_LOG_WARN ("DoD TCP does not have congestion window");
  return 0;
}
예제 #14
0
void
TcpRfc793::SetInitialCwnd (uint32_t cwnd)
{
  NS_LOG_WARN ("DoD TCP does not have congestion window");
}
예제 #15
0
uint32_t
TcpRfc793::GetSSThresh (void) const
{
  NS_LOG_WARN ("DoD TCP does not perform slow start");
  return 0;
}
예제 #16
0
void
TcpRfc793::SetSSThresh (uint32_t threshold)
{
  NS_LOG_WARN ("DoD TCP does not perform slow start");
}
예제 #17
0
	void bandwidth_manager::update_quotas(time_duration const& dt)
	{
        NS_LOG_FUNCTION(this);

		if (m_abort)
        {
            NS_LOG_WARN("connection abort");
            return;
        }
		if (m_queue.empty())
        {
            return;        
        }

		INVARIANT_CHECK;

		int dt_milliseconds = total_milliseconds(dt);
		if (dt_milliseconds > 3000) dt_milliseconds = 3000;

		// for each bandwidth channel, call update_quota(dt)

		std::vector<bandwidth_channel*> channels;

		for (queue_t::iterator i = m_queue.begin();
			i != m_queue.end();)
		{
			if (i->peer->is_disconnecting())
			{
				m_queued_bytes -= i->request_size - i->assigned;

				// return all assigned quota to all the
				// bandwidth channels this peer belongs to
				for (int j = 0; j < 5 && i->channel[j]; ++j)
				{
					bandwidth_channel* bwc = i->channel[j];
					bwc->return_quota(i->assigned);
				}

				i = m_queue.erase(i);
				continue;
			}
			for (int j = 0; j < 5 && i->channel[j]; ++j)
			{
				bandwidth_channel* bwc = i->channel[j];
				bwc->tmp = 0;
			}
			++i;
		}

		for (queue_t::iterator i = m_queue.begin()
			, end(m_queue.end()); i != end; ++i)
		{
			for (int j = 0; j < 5 && i->channel[j]; ++j)
			{
				bandwidth_channel* bwc = i->channel[j];
				if (bwc->tmp == 0) channels.push_back(bwc);
				TORRENT_ASSERT(INT_MAX - bwc->tmp > i->priority);
				bwc->tmp += i->priority;
			}
		}

		for (std::vector<bandwidth_channel*>::iterator i = channels.begin()
			, end(channels.end()); i != end; ++i)
		{
			(*i)->update_quota(dt_milliseconds);
		}

		queue_t tm;

		for (queue_t::iterator i = m_queue.begin();
			i != m_queue.end();)
		{
			int a = i->assign_bandwidth();
			if (i->assigned == i->request_size
				|| (i->ttl <= 0 && i->assigned > 0))
			{
				a += i->request_size - i->assigned;
				TORRENT_ASSERT(i->assigned <= i->request_size);
				tm.push_back(*i);
				i = m_queue.erase(i);
			}
			else
			{
				++i;
			}
			m_queued_bytes -= a;
		}

		while (!tm.empty())
		{
			bw_request& bwr = tm.back();
			bwr.peer->assign_bandwidth(m_channel, bwr.assigned);
			tm.pop_back();
		}
	}
예제 #18
0
uint64_t
Implementation::GetHash64  (const char * buffer, const size_t size)
{
  NS_LOG_WARN ("64-bit hash requested, only 32-bit implementation available");
  return GetHash32 (buffer, size);
}