Beispiel #1
0
float Timer::Seconds() {
  return MilliSeconds() / 1000.;
}
Beispiel #2
0
Time
RrepHeader::GetLifeTime () const
{
    Time t (MilliSeconds (m_lifeTime));
    return t;
}
ApiErrorCode
GenericOfferAnswerSession::Answer(IN const AbstractOffer &offer,
						 IN const MapOfAny &key_value_map,
						 IN csp::Time	  ring_timeout)
{
	FUNCTRACKER;

	LogDebug("enericOfferAnswerSession::Answer iwh:" << _iwCallHandle <<
		" type=" << offer.type << ", body=" << offer.body);

	if (_callState != CALL_STATE_INITIAL_OFFERED && 
		_callState != CALL_STATE_REMOTE_OFFERED		)
	{
		LogWarn("Answer:: wrong call state:" << _callState << ", iwh:" << _iwCallHandle);
		return API_WRONG_STATE;
	}


	_localOffer = offer;

	IwMessagePtr response = NULL_MSG;

	if (_uac)
	{
		MsgNewCallConnected *ack	= new MsgNewCallConnected();
		ack->stack_call_handle	= _iwCallHandle;
		ack->localOffer		    = offer;


		ApiErrorCode res = GetCurrRunningContext()->SendMessage(
			_serviceHandleId,
			IwMessagePtr(ack));

		CALL_RESET_STATE(CALL_STATE_CONNECTED);

		
		return res;
	}

	MsgCalOfferedAck *ack	= new MsgCalOfferedAck();
	ack->stack_call_handle	= _iwCallHandle;
	ack->localOffer		    = offer;


	ApiErrorCode res = GetCurrRunningContext()->DoRequestResponseTransaction(
		_serviceHandleId,
		IwMessagePtr(ack),
		response,
		MilliSeconds(GetCurrRunningContext()->TransactionTimeout()),
		"Accept GenericOfferAnswerSession TXN");

	if (IW_FAILURE(res))
	{
		return res;
	}



	

	switch (response->message_id)
	{
	case MSG_CALL_CONNECTED:
		{
			shared_ptr<MsgNewCallConnected> make_call_sucess = 
				dynamic_pointer_cast<MsgNewCallConnected>(response);

			_iwCallHandle = make_call_sucess->stack_call_handle;

			break;
		}
	default:
		{
			HangupCall();
			return API_SERVER_FAILURE;
		}
	}

	CALL_RESET_STATE(CALL_STATE_CONNECTED);

	return res;
}
Beispiel #4
0
TypeId RedQueue::GetTypeId (void)
{
  static TypeId tid = TypeId ("ns3::RedQueue")
    .SetParent<Queue> ()
    .AddConstructor<RedQueue> ()
    .AddAttribute ("Mode",
                   "Determines unit for QueueLimit",
                   EnumValue (QUEUE_MODE_PACKETS),
                   MakeEnumAccessor (&RedQueue::SetMode),
                   MakeEnumChecker (QUEUE_MODE_BYTES, "QUEUE_MODE_BYTES",
                                    QUEUE_MODE_PACKETS, "QUEUE_MODE_PACKETS"))
    .AddAttribute ("MeanPktSize",
                   "Average of packet size",
                   UintegerValue (500),
                   MakeUintegerAccessor (&RedQueue::m_meanPktSize),
                   MakeUintegerChecker<uint32_t> ())
    .AddAttribute ("IdlePktSize",
                   "Average packet size used during idle times. Used when m_cautions = 3",
                   UintegerValue (0),
                   MakeUintegerAccessor (&RedQueue::m_idlePktSize),
                   MakeUintegerChecker<uint32_t> ())
    .AddAttribute ("Wait",
                   "True for waiting between dropped packets",
                   BooleanValue (true),
                   MakeBooleanAccessor (&RedQueue::m_isWait),
                   MakeBooleanChecker ())
    .AddAttribute ("Gentle",
                   "True to increases dropping probability slowly when average queue exceeds maxthresh",
                   BooleanValue (true),
                   MakeBooleanAccessor (&RedQueue::m_isGentle),
                   MakeBooleanChecker ())
    .AddAttribute ("MinTh",
                   "Minimum average length threshold in packets/bytes",
                   DoubleValue (5),
                   MakeDoubleAccessor (&RedQueue::m_minTh),
                   MakeDoubleChecker<double> ())
    .AddAttribute ("MaxTh",
                   "Maximum average length threshold in packets/bytes",
                   DoubleValue (15),
                   MakeDoubleAccessor (&RedQueue::m_maxTh),
                   MakeDoubleChecker<double> ())
    .AddAttribute ("QueueLimit",
                   "Queue limit in bytes/packets",
                   UintegerValue (25),
                   MakeUintegerAccessor (&RedQueue::m_queueLimit),
                   MakeUintegerChecker<uint32_t> ())
    .AddAttribute ("QW",
                   "Queue weight related to the exponential weighted moving average (EWMA)",
                   DoubleValue (0.002),
                   MakeDoubleAccessor (&RedQueue::m_qW),
                   MakeDoubleChecker <double> ())
    .AddAttribute ("LInterm",
                   "The maximum probability of dropping a packet",
                   DoubleValue (50),
                   MakeDoubleAccessor (&RedQueue::m_lInterm),
                   MakeDoubleChecker <double> ())
    .AddAttribute ("Ns1Compat",
                   "NS-1 compatibility",
                   BooleanValue (false),
                   MakeBooleanAccessor (&RedQueue::m_isNs1Compat),
                   MakeBooleanChecker ())
    .AddAttribute ("LinkBandwidth", 
                   "The RED link bandwidth",
                   DataRateValue (DataRate ("1.5Mbps")),
                   MakeDataRateAccessor (&RedQueue::m_linkBandwidth),
                   MakeDataRateChecker ())
    .AddAttribute ("LinkDelay", 
                   "The RED link delay",
                   TimeValue (MilliSeconds (20)),
                   MakeTimeAccessor (&RedQueue::m_linkDelay),
                   MakeTimeChecker ())
  ;

  return tid;
}
ApiErrorCode
StreamingSession::Allocate(IN const AbstractOffer &remote_offer, 
					       IN RcvDeviceType rcvDeviceType,
						   IN SndDeviceType sndDeviceType)
{
	FUNCTRACKER;

	LogDebug("StreamingSession::Allocate dest ci:" <<  remote_offer.body  << ", Streamh:" << _streamingSessionHandle);
	
	if (_streamingSessionHandle != IW_UNDEFINED)
	{
		return API_FAILURE;
	}

	DECLARE_NAMED_HANDLE_PAIR(session_handler_pair);

	MsgStreamAllocateSessionReq *msg = new MsgStreamAllocateSessionReq();
	msg->offer = remote_offer;
	msg->session_handler = session_handler_pair;
	msg->rcv_device_type = rcvDeviceType;
	msg->snd_device_type = sndDeviceType;

	IwMessagePtr response = NULL_MSG;
	ApiErrorCode res = GetCurrRunningContext()->DoRequestResponseTransaction(
		_streamerHandleId,
		IwMessagePtr(msg),
		response,
		MilliSeconds(GetCurrRunningContext()->TransactionTimeout()),
		"Allocate Stream Connection TXN");

	if (res != API_SUCCESS)
	{
		LogWarn("Error allocating Stream connection " << res);
		return res;
	}

	switch (response->message_id)
	{
	case MSG_STREAM_ALLOCATE_SESSION_ACK:
		{


			shared_ptr<MsgStreamAllocateSessionAck> ack = 
				shared_polymorphic_cast<MsgStreamAllocateSessionAck>(response);
			_streamingSessionHandle	= ack->streamer_handle;
			_localOffer = ack->offer;
			_remoteOffer = remote_offer;
			

			StartActiveObjectLwProc(_forking,session_handler_pair,"Stream Session handler");

			LogDebug("Stream session allocated successfully, Streamh:" << _streamingSessionHandle );

			break;

		}
	case MSG_STREAM_ALLOCATE_SESSION_NACK:
		{
			LogDebug("Error allocating Stream session.");
			res = API_SERVER_FAILURE;
			break;
		}
	default:
		{
			throw;
		}
	}
	return res;

}
 MilliSeconds operator-() const {
     return MilliSeconds(-milliSeconds);
 }