Commit 42bb59c2 authored by jehan's avatar jehan

-improve netsim

-add debug traces
parent f3233fdc
......@@ -102,6 +102,7 @@ typedef struct _RtpTransport
typedef struct _OrtpNetworkSimulatorParams{
int enabled;
float max_bandwidth; /*IP bandwidth, in bit/s*/
int max_buffer_size; /*Max number of bit buffered before being discarded*/
float loss_rate;
}OrtpNetworkSimulatorParams;
......
......@@ -39,6 +39,11 @@ void rtp_session_enable_network_simulation(RtpSession *session, const OrtpNetwor
if (params->enabled){
if (sim==NULL) sim=simulator_ctx_new();
sim->params=*params;
if (sim->params.max_bandwidth && sim->params.max_buffer_size==0) {
sim->params.max_buffer_size=sim->params.max_bandwidth;
ortp_message("Max buffer size not set for rtp session [%p], using [%i]",session,sim->params.max_buffer_size);
}
session->net_sim_ctx=sim;
}else{
if (sim!=NULL) ortp_network_simulator_destroy(sim);
......@@ -81,7 +86,7 @@ static mblk_t *simulate_bandwidth_limit(RtpSession *session, mblk_t *input){
sim->qsize+=bits;
}
/*flow control*/
while (sim->qsize>=sim->params.max_bandwidth){
while (sim->qsize>=sim->params.max_buffer_size){
ortp_message("rtp_session_network_simulate(): discarding packets.");
output=getq(&sim->q);
if (output){
......
......@@ -870,6 +870,11 @@ rtp_session_set_remote_addr_full (RtpSession * session, const char * rtp_addr, i
session->flags&=~RTP_SOCKET_CONNECTED;
session->flags&=~RTCP_SOCKET_CONNECTED;
}
ortp_message("rtp session [%p] set to rtp [%s:%i] rtcp [%s:%i]" ,session
,rtp_addr
,rtp_port
,rtcp_addr
,rtcp_port);
return 0;
}
......@@ -1459,7 +1464,7 @@ rtp_session_rtcp_recv (RtpSession * session)
{
if (session->on_network_error.count>0){
rtp_signal_table_emit3(&session->on_network_error,(long)"Error receiving RTCP packet",INT_TO_POINTER(errnum));
}else ortp_warning("Error receiving RTCP packet: %s.",getSocketError());
}else ortp_warning("Error receiving RTCP packet on port [%i]: %s.",session->rtcp.loc_port,getSocketError());
session->rtp.recv_errno=errnum;
}
/* don't free the cached_mp, it will be reused next time */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment