-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathSipSpeedLinux.cpp
More file actions
142 lines (110 loc) · 3.78 KB
/
SipSpeedLinux.cpp
File metadata and controls
142 lines (110 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
* Copyright (C) 2012 Yee Young Han <websearch@naver.com> (http://blog.naver.com/websearch)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "SipSpeedLinux.h"
#include "SipSpeedSetup.h"
#include "SipClient.h"
#include "TimeUtility.h"
CSipUserAgent gclsSipUserAgent;
int main( int argc, char * argv[] )
{
if( argc != 2 )
{
printf( "[Usage] %s {setup filename}\n", argv[0] );
return 0;
}
const char * pszSetupFileName = argv[1];
if( gclsSetup.Read( pszSetupFileName ) == false ) return 0;
// SipStack 을 시작한다.
CSipStackSetup clsSetup;
CSipServerInfo clsInfo;
CSipClient clsCallBack;
GetLocalIp( clsSetup.m_strLocalIp );
clsInfo.m_strIp = gclsSetup.m_strSipServerIp;
clsInfo.m_iPort = gclsSetup.m_iSipServerPort;
clsInfo.m_strDomain = gclsSetup.m_strSipDomain;
clsInfo.m_strUserId = gclsSetup.m_strCallerId;
clsInfo.m_strPassWord = gclsSetup.m_strCallerPassWord;
gclsSipUserAgent.InsertRegisterInfo( clsInfo );
clsInfo.m_strUserId = gclsSetup.m_strCalleeId;
clsInfo.m_strPassWord = gclsSetup.m_strCalleePassWord;
gclsSipUserAgent.InsertRegisterInfo( clsInfo );
bool bSuccess = false;
clsSetup.m_iUdpThreadCount = 4;
clsSetup.m_iStackExecutePeriod = 100;
clsSetup.m_iTimerD = 4000;
clsSetup.m_iTimerJ = 4000;
clsSetup.m_iUdpBufSize = 1500000;
for( int i = 0; i < 100; ++i )
{
clsSetup.m_iLocalUdpPort = i + 10000;
if( gclsSipUserAgent.Start( clsSetup, &clsCallBack ) )
{
bSuccess = true;
break;
}
}
if( bSuccess == false )
{
printf( "gclsSipUserAgent.Start() error\n" );
return 0;
}
while( clsCallBack.m_bCallerLogin == false || clsCallBack.m_bCalleeLogin == false )
{
MiliSleep(20);
}
printf( "start test\n" );
struct timeval sttStart, sttEnd;
gettimeofday( &sttStart, NULL );
CSipCallRtp clsRtp;
CSipCallRoute clsRoute;
std::string strCallId;
clsRtp.m_strIp = gclsSipUserAgent.m_clsSipStack.m_clsSetup.m_strLocalIp;
clsRtp.m_iPort = 4000;
clsRtp.m_iCodec = 0;
clsRoute.m_strDestIp = gclsSetup.m_strSipServerIp;
clsRoute.m_iDestPort = gclsSetup.m_iSipServerPort;
// 통화 연결 테스트
for( int i = 0; i < gclsSetup.m_iCallTotalCount; ++i )
{
// 동시 통화 개수가 설정된 개수와 같거나 큰 경우에는 대기한다.
while( gclsSipUserAgent.GetCallCount() >= gclsSetup.m_iCallConcurrentCount )
{
MiliSleep(20);
}
if( gclsSipUserAgent.StartCall( gclsSetup.m_strCallerId.c_str(), gclsSetup.m_strCalleeId.c_str(), &clsRtp, &clsRoute, strCallId ) == false )
{
break;
}
}
// 모든 통화가 종료될 때까지 대기한다.
while( gclsSipUserAgent.GetCallCount() > 0 )
{
MiliSleep(20);
}
gettimeofday( &sttEnd, NULL );
int iDiff = DiffTimeval( &sttStart, &sttEnd );
double fCps = 0.0;
if( iDiff > 0 )
{
fCps = (double)( clsCallBack.m_iCallSuccess + clsCallBack.m_iCallError ) / ( (double)iDiff / 1000 );
}
printf( "call success(%d) / error(%d) / cps(%.3f) / time(%d ms)\n", clsCallBack.m_iCallSuccess, clsCallBack.m_iCallError, fCps, iDiff );
gclsSipUserAgent.m_clsSipStack.PrintReSendCount();
gclsSipUserAgent.Stop();
return 0;
}