~ubuntu-branches/ubuntu/utopic/sip-tester/utopic

« back to all changes in this revision

Viewing changes to .pc/enable-gsl.patch/scenario.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell, Paul Belanger, Mark Purcell
  • Date: 2011-11-03 21:56:17 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20111103215617-nnxicj1oto9e8ix5
Tags: 1:3.2-1
[ Paul Belanger ]
* New Upstream Release (Closes: #623915).
* Switch to dpkg-source 3.0 (quilt) format
* Building with PCAP play.
* Switch back to Debhelper.
* debian/patches/spelling-error-in-binary: Fix lintian warning

[ Mark Purcell ]
* Drop pabs from Uploaders: at his request
* fix debhelper-overrides-need-versioned-build-depends
* fix description-synopsis-starts-with-article

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  This program is free software; you can redistribute it and/or modify
 
3
 *  it under the terms of the GNU General Public License as published by
 
4
 *  the Free Software Foundation; either version 2 of the License, or
 
5
 *  (at your option) any later version.
 
6
 *
 
7
 *  This program is distributed in the hope that it will be useful,
 
8
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
 *  GNU General Public License for more details.
 
11
 *
 
12
 *  You should have received a copy of the GNU General Public License
 
13
 *  along with this program; if not, write to the Free Software
 
14
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
 *
 
16
 *  Author : Richard GAYRAUD - 04 Nov 2003
 
17
 *           Olivier Jacques
 
18
 *           From Hewlett Packard Company.
 
19
 *           Shriram Natarajan
 
20
 *           Peter Higginson
 
21
 *           Venkatesh
 
22
 *           Lee Ballard
 
23
 *           Guillaume TEISSIER from FTR&D
 
24
 *           Wolfgang Beck
 
25
 *           Marc Van Diest from Belgacom
 
26
 *           Charles P. Wright from IBM Research
 
27
 *           Michael Stovenour
 
28
 */
 
29
 
 
30
#include <stdlib.h>
 
31
#include "sipp.hpp"
 
32
#ifdef HAVE_GSL
 
33
#include <gsl/gsl_rng.h>
 
34
#include <gsl/gsl_randist.h>
 
35
#include <gsl/gsl_cdf.h>
 
36
#endif
 
37
 
 
38
/************************ Class Constructor *************************/
 
39
 
 
40
message::message(int index, const char *desc)
 
41
{
 
42
  this->index = index;
 
43
  this->desc = desc;
 
44
  pause_distribution = NULL;
 
45
  pause_variable = -1;
 
46
  pause_desc = NULL;
 
47
  sessions = 0;
 
48
  bShouldRecordRoutes = 0;
 
49
#ifdef _USE_OPENSSL
 
50
  bShouldAuthenticate = 0;
 
51
#endif
 
52
 
 
53
  send_scheme = NULL;
 
54
  retrans_delay = 0;
 
55
  timeout = 0;
 
56
 
 
57
  recv_response = 0;
 
58
  recv_request = NULL;
 
59
  optional = 0;
 
60
  advance_state = true;
 
61
  regexp_match = 0;
 
62
  regexp_compile = NULL;
 
63
 
 
64
  /* Anyway */
 
65
  start_rtd = 0;
 
66
  stop_rtd  = 0;
 
67
  repeat_rtd = 0;
 
68
  lost = -1;
 
69
  crlf = 0;
 
70
  hide = 0;
 
71
  display_str = NULL;
 
72
  test = -1;
 
73
  condexec = -1;
 
74
  condexec_inverse = false;
 
75
  chance = 0;/* meaning always */
 
76
  next = -1;
 
77
  nextLabel = NULL;
 
78
  on_timeout = -1;
 
79
  onTimeoutLabel = NULL;
 
80
  timewait = false;
 
81
 
 
82
/* 3pcc extended mode */
 
83
  peer_dest = NULL;
 
84
  peer_src = NULL;
 
85
 
 
86
  /* Statistics */
 
87
  nb_sent = 0;
 
88
  nb_recv = 0;
 
89
  nb_sent_retrans = 0;
 
90
  nb_recv_retrans = 0;
 
91
  nb_timeout = 0;
 
92
  nb_unexp = 0;
 
93
  nb_lost = 0;
 
94
  counter = 0;
 
95
 
 
96
  M_actions = NULL;
 
97
 
 
98
  M_type = 0;
 
99
 
 
100
  M_sendCmdData = NULL;
 
101
  M_nbCmdSent   = 0;
 
102
  M_nbCmdRecv   = 0;
 
103
 
 
104
  content_length_flag = ContentLengthNoPresent;
 
105
 
 
106
  /* How to match responses to this message. */
 
107
  start_txn = 0;
 
108
  response_txn = 0;
 
109
  ack_txn = 0;
 
110
  recv_response_for_cseq_method_list = NULL;
 
111
}
 
112
 
 
113
message::~message()
 
114
{
 
115
  if(M_actions != NULL)
 
116
    delete(M_actions);
 
117
 
 
118
  if(send_scheme != NULL)
 
119
    delete send_scheme;
 
120
 
 
121
  if(recv_request != NULL)
 
122
    free (recv_request);
 
123
 
 
124
  if(regexp_compile != NULL)
 
125
    regfree(regexp_compile);
 
126
    free(regexp_compile);
 
127
 
 
128
 
 
129
  if (pause_distribution) {
 
130
    delete pause_distribution;
 
131
  }
 
132
 
 
133
  if(M_sendCmdData != NULL)
 
134
    delete M_sendCmdData;
 
135
 
 
136
  free(display_str);
 
137
  free(peer_dest);
 
138
  free(peer_src);
 
139
  free(pause_desc);
 
140
  free(recv_response_for_cseq_method_list);
 
141
}
 
142
 
 
143
/******** Global variables which compose the scenario file **********/
 
144
 
 
145
scenario      *main_scenario;
 
146
scenario      *ooc_scenario;
 
147
scenario      *display_scenario;
 
148
 
 
149
/* This mode setting refers to whether we open calls autonomously (MODE_CLIENT)
 
150
 * or in response to requests (MODE_SERVER). */
 
151
int           creationMode  = MODE_CLIENT;
 
152
/* Send mode. Do we send to a fixed address or to the last one we got. */
 
153
int           sendMode  = MODE_CLIENT;
 
154
/* This describes what our 3PCC behavior is. */
 
155
int           thirdPartyMode = MODE_3PCC_NONE;
 
156
 
 
157
/*************** Helper functions for various types *****************/
 
158
long get_long(const char *ptr, const char *what) {
 
159
  char *endptr;
 
160
  long ret;
 
161
 
 
162
  ret = strtol(ptr, &endptr, 0);
 
163
  if (*endptr) {
 
164
    ERROR("%s, \"%s\" is not a valid integer!\n", what, ptr);
 
165
  }
 
166
  return ret;
 
167
}
 
168
 
 
169
unsigned long long get_long_long(const char *ptr, const char *what) {
 
170
  char *endptr;
 
171
  unsigned long long ret;
 
172
 
 
173
  ret = strtoull(ptr, &endptr, 0);
 
174
  if (*endptr) {
 
175
    ERROR("%s, \"%s\" is not a valid integer!\n", what, ptr);
 
176
  }
 
177
  return ret;
 
178
}
 
179
 
 
180
/* This function returns a time in milliseconds from a string.
 
181
 * The multiplier is used to convert from the default input type into
 
182
 * milliseconds.  For example, for seconds you should use 1000 and for
 
183
 * milliseconds use 1. */
 
184
long get_time(const char *ptr, const char *what, int multiplier) {
 
185
  char *endptr;
 
186
  const char *p;
 
187
  long ret;
 
188
  double dret;
 
189
  int i;
 
190
 
 
191
  if (!isdigit(*ptr)) {
 
192
    ERROR("%s, \"%s\" is not a valid time!\n", what, ptr);
 
193
  }
 
194
 
 
195
  for (i = 0, p = ptr; *p; p++) {
 
196
        if (*p == ':') {
 
197
                i++;
 
198
        }
 
199
  }
 
200
 
 
201
  if (i == 1) { /* mm:ss */
 
202
    ERROR("%s, \"%s\" mm:ss not implemented yet!\n", what, ptr);
 
203
  }
 
204
  else if (i == 2) { /* hh:mm:ss */
 
205
    ERROR("%s, \"%s\" hh:mm:ss not implemented yet!\n", what, ptr);
 
206
  } else if (i != 0) {
 
207
    ERROR("%s, \"%s\" is not a valid time!\n", what, ptr);
 
208
  }
 
209
 
 
210
  dret = strtod(ptr, &endptr);
 
211
  if (*endptr) {
 
212
    if (!strcmp(endptr, "s")) { /* Seconds */
 
213
        ret = (long)(dret * 1000);
 
214
    } else if (!strcmp(endptr, "ms")) { /* Milliseconds. */
 
215
        ret = (long)dret;
 
216
    } else if (!strcmp(endptr, "m")) { /* Minutes. */
 
217
        ret = (long)(dret * 60000);
 
218
    } else if (!strcmp(endptr, "h")) { /* Hours. */
 
219
        ret = (long)(dret * 60 * 60 * 1000);
 
220
    } else {
 
221
      ERROR("%s, \"%s\" is not a valid time!\n", what, ptr);
 
222
    }
 
223
  } else {
 
224
    ret = (long)(dret * multiplier);
 
225
  }
 
226
  return ret;
 
227
}
 
228
 
 
229
double get_double(const char *ptr, const char *what) {
 
230
  char *endptr;
 
231
  double ret;
 
232
 
 
233
  ret = strtod(ptr, &endptr);
 
234
  if (*endptr) {
 
235
    ERROR("%s, \"%s\" is not a floating point number!\n", what, ptr);
 
236
  }
 
237
  return ret;
 
238
}
 
239
 
 
240
char * xp_get_string(const char *name, const char *what) {
 
241
  char *ptr;
 
242
 
 
243
  if (!(ptr = xp_get_value(name))) {
 
244
    ERROR("%s is missing the required '%s' parameter.", what, name);
 
245
  }
 
246
 
 
247
  return strdup(ptr);
 
248
}
 
249
 
 
250
double xp_get_double(const char *name, const char *what) {
 
251
  char *ptr;
 
252
  char *helptext;
 
253
  double val;
 
254
 
 
255
  if (!(ptr = xp_get_value(name))) {
 
256
    ERROR("%s is missing the required '%s' parameter.", what, name);
 
257
  }
 
258
  helptext = (char *)malloc(100 + strlen(name) + strlen(what));
 
259
  sprintf(helptext, "%s '%s' parameter", what, name);
 
260
  val = get_double(ptr, helptext);
 
261
  free(helptext);
 
262
 
 
263
  return val;
 
264
}
 
265
 
 
266
double xp_get_double(const char *name, const char *what, double defval) {
 
267
  if (!(xp_get_value(name))) {
 
268
    return defval;
 
269
  }
 
270
  return xp_get_double(name, what);
 
271
}
 
272
 
 
273
long xp_get_long(const char *name, const char *what) {
 
274
  char *ptr;
 
275
  char *helptext;
 
276
  long val;
 
277
 
 
278
  if (!(ptr = xp_get_value(name))) {
 
279
    ERROR("%s is missing the required '%s' parameter.", what, name);
 
280
  }
 
281
  helptext = (char *)malloc(100 + strlen(name) + strlen(what));
 
282
  sprintf(helptext, "%s '%s' parameter", what, name);
 
283
  val = get_long(ptr, helptext);
 
284
  free(helptext);
 
285
 
 
286
  return val;
 
287
}
 
288
 
 
289
long xp_get_long(const char *name, const char *what, long defval) {
 
290
  if (!(xp_get_value(name))) {
 
291
    return defval;
 
292
  }
 
293
  return xp_get_long(name, what);
 
294
}
 
295
 
 
296
 
 
297
double xp_get_bool(const char *name, const char *what) {
 
298
  char *ptr;
 
299
  char *helptext;
 
300
  bool val;
 
301
 
 
302
  if (!(ptr = xp_get_value(name))) {
 
303
    ERROR("%s is missing the required '%s' parameter.", what, name);
 
304
  }
 
305
  helptext = (char *)malloc(100 + strlen(name) + strlen(what));
 
306
  sprintf(helptext, "%s '%s' parameter", what, name);
 
307
  val = get_bool(ptr, helptext);
 
308
  free(helptext);
 
309
 
 
310
  return val;
 
311
}
 
312
 
 
313
double xp_get_bool(const char *name, const char *what, bool defval) {
 
314
  if (!(xp_get_value(name))) {
 
315
    return defval;
 
316
  }
 
317
  return xp_get_bool(name, what);
 
318
}
 
319
 
 
320
int scenario::get_txn(const char *txnName, const char *what, bool start, bool isInvite, bool isAck) {
 
321
  /* Check the name's validity. */
 
322
  if (txnName[0] == '\0') {
 
323
    ERROR("Variable names may not be empty for %s\n", what);
 
324
  }
 
325
  if (strcspn(txnName, "$,") != strlen(txnName)) {
 
326
    ERROR("Variable names may not contain $ or , for %s\n", what);
 
327
  }
 
328
 
 
329
  /* If this transaction has already been used, then we have nothing to do. */
 
330
  str_int_map::iterator txn_it = txnMap.find(txnName);
 
331
  if (txn_it != txnMap.end()) {
 
332
    if (start) {
 
333
      /* We need to fill in the invite field. */
 
334
      transactions[txn_it->second - 1].started++;
 
335
    } else if (isAck) {
 
336
      transactions[txn_it->second - 1].acks++;
 
337
    } else {
 
338
      transactions[txn_it->second - 1].responses++;
 
339
    }
 
340
    return txn_it->second;
 
341
  }
 
342
 
 
343
  /* Assign this variable the next slot. */
 
344
  struct txnControlInfo transaction;
 
345
 
 
346
  transaction.name = strdup(txnName);
 
347
  if (start) {
 
348
    transaction.started = 1;
 
349
    transaction.responses = 0;
 
350
    transaction.acks = 0;
 
351
    transaction.isInvite = isInvite;
 
352
  } else if (isAck) {
 
353
    /* Does not start or respond to this txn. */
 
354
    transaction.started = 0;
 
355
    transaction.responses = 0;
 
356
    transaction.acks = 1;
 
357
    transaction.isInvite = false;
 
358
  } else {
 
359
    transaction.started = 0;
 
360
    transaction.responses = 1;
 
361
    transaction.acks = 0;
 
362
    transaction.isInvite = false;
 
363
  }
 
364
 
 
365
  transactions.push_back(transaction);
 
366
  int txnNum = transactions.size();
 
367
  txnMap[txnName] = txnNum;
 
368
 
 
369
  return txnNum;
 
370
}
 
371
 
 
372
int scenario::find_var(const char *varName, const char *what) {
 
373
  return allocVars->find(varName, false);
 
374
}
 
375
 
 
376
int scenario::get_var(const char *varName, const char *what) {
 
377
  /* Check the name's validity. */
 
378
  if (varName[0] == '\0') {
 
379
    ERROR("Transaction names may not be empty for %s\n", what);
 
380
  }
 
381
  if (strcspn(varName, "$,") != strlen(varName)) {
 
382
    ERROR("Transaction names may not contain $ or , for %s\n", what);
 
383
  }
 
384
 
 
385
  return allocVars->find(varName, true);
 
386
}
 
387
 
 
388
int scenario::xp_get_var(const char *name, const char *what) {
 
389
  char *ptr;
 
390
 
 
391
  if (!(ptr = xp_get_value(name))) {
 
392
    ERROR("%s is missing the required '%s' variable parameter.", what, name);
 
393
  }
 
394
 
 
395
  return get_var(ptr, what);
 
396
}
 
397
 
 
398
int xp_get_optional(const char *name, const char *what) {
 
399
  char *ptr = xp_get_value(name);
 
400
 
 
401
  if (!(ptr = xp_get_value(name))) {
 
402
    return OPTIONAL_FALSE;
 
403
  }
 
404
 
 
405
  if(!strcmp(ptr, "true")) {
 
406
    return OPTIONAL_TRUE;
 
407
  } else if(!strcmp(ptr, "global")) {
 
408
    return OPTIONAL_GLOBAL;
 
409
  } else if(!strcmp(ptr, "false")) {
 
410
    return OPTIONAL_FALSE;
 
411
  } else {
 
412
    ERROR("Could not understand optional value for %s: %s", what, ptr);
 
413
  }
 
414
 
 
415
  return OPTIONAL_FALSE;
 
416
}
 
417
 
 
418
 
 
419
int scenario::xp_get_var(const char *name, const char *what, int defval) {
 
420
  char *ptr;
 
421
 
 
422
  if (!(ptr = xp_get_value(name))) {
 
423
        return defval;
 
424
  }
 
425
 
 
426
  return xp_get_var(name, what);
 
427
}
 
428
 
 
429
bool get_bool(const char *ptr, const char *what) {
 
430
  char *endptr;
 
431
  long ret;
 
432
 
 
433
  if (!strcmp(ptr, "true")) {
 
434
    return true;
 
435
  }
 
436
  if (!strcmp(ptr, "false")) {
 
437
    return false;
 
438
  }
 
439
 
 
440
  ret = strtol(ptr, &endptr, 0);
 
441
  if (*endptr) {
 
442
    ERROR("%s, \"%s\" is not a valid boolean!\n", what, ptr);
 
443
  }
 
444
  return ret ? true : false;
 
445
}
 
446
 
 
447
/* Pretty print a time. */
 
448
char *time_string(int ms) {
 
449
   static char tmp[20];
 
450
 
 
451
   if (ms < 10000) {
 
452
        snprintf(tmp, sizeof(tmp), "%dms", ms);
 
453
   } else if (ms < 100000) {
 
454
        snprintf(tmp, sizeof(tmp), "%.1fs", ((float)ms)/1000);
 
455
   } else {
 
456
        snprintf(tmp, sizeof(tmp), "%ds", ms/1000);
 
457
   }
 
458
 
 
459
   return tmp;
 
460
}
 
461
 
 
462
int time_string(double ms, char *res, int reslen) {
 
463
  if (ms < 10000) {
 
464
    /* Less then 10 seconds we represent accurately. */
 
465
    if ((int)(ms + 0.9999) == (int)(ms)) {
 
466
      /* We have an integer, or close enough to it. */
 
467
      return snprintf(res, reslen, "%dms", (int)ms);
 
468
    } else {
 
469
      if (ms < 1000) {
 
470
        return snprintf(res, reslen, "%.2lfms", ms);
 
471
      } else {
 
472
        return snprintf(res, reslen, "%.1lfms", ms);
 
473
      }
 
474
    }
 
475
  } else if (ms < 60000) {
 
476
    /* We round to 100ms for times less than a minute. */
 
477
    return snprintf(res, reslen, "%.1fs", ms/1000);
 
478
  } else if (ms < 60 * 60000) {
 
479
    /* We round to 1s for times more than a minute. */
 
480
    int s = (unsigned int)(ms / 1000);
 
481
    int m = s / 60;
 
482
    s %= 60;
 
483
    return snprintf(res, reslen, "%d:%02d", m, s);
 
484
  } else {
 
485
    int s = (unsigned int)(ms / 1000);
 
486
    int m = s / 60;
 
487
    int h = m / 60;
 
488
    s %= 60;
 
489
    m %= 60;
 
490
    return snprintf(res, reslen, "%d:%02d:%02d", h, m, s);
 
491
  }
 
492
}
 
493
 
 
494
char *double_time_string(double ms) {
 
495
   static char tmp[20];
 
496
 
 
497
   if (ms < 1000) {
 
498
        snprintf(tmp, sizeof(tmp), "%.2lfms", ms);
 
499
   } else if (ms < 10000) {
 
500
        snprintf(tmp, sizeof(tmp), "%.1lfms", ms);
 
501
   } else if (ms < 100000) {
 
502
        snprintf(tmp, sizeof(tmp), "%.1lfs", ms / 1000);
 
503
   } else {
 
504
        snprintf(tmp, sizeof(tmp), "%ds", (int)(ms/1000));
 
505
   }
 
506
 
 
507
   return tmp;
 
508
}
 
509
 
 
510
/* For backwards compatibility, we assign "true" to slot 1, false to 0, and
 
511
 * allow other valid integers. */
 
512
int scenario::get_rtd(const char *ptr, bool start) {
 
513
  if(!strcmp(ptr, (char *)"false"))
 
514
    return 0;
 
515
 
 
516
  if(!strcmp(ptr, (char *)"true"))
 
517
    return stats->findRtd("1", start);
 
518
 
 
519
  return stats->findRtd(ptr, start);
 
520
}
 
521
 
 
522
/* Get a counter */
 
523
int scenario::get_counter(const char *ptr, const char *what) {
 
524
  /* Check the name's validity. */
 
525
  if (ptr[0] == '\0') {
 
526
    ERROR("Counter names names may not be empty for %s\n", what);
 
527
  }
 
528
  if (strcspn(ptr, "$,") != strlen(ptr)) {
 
529
    ERROR("Counter names may not contain $ or , for %s\n", what);
 
530
  }
 
531
 
 
532
  return stats->findCounter(ptr, true);
 
533
}
 
534
 
 
535
 
 
536
/* Some validation functions. */
 
537
 
 
538
void scenario::validate_variable_usage() {
 
539
  allocVars->validate();
 
540
}
 
541
 
 
542
void scenario::validate_txn_usage() {
 
543
  for (unsigned int i = 0; i < transactions.size(); i++) {
 
544
    if(transactions[i].started == 0) {
 
545
      ERROR("Transaction %s is never started!\n", transactions[i].name);
 
546
    } else if(transactions[i].responses == 0) {
 
547
      ERROR("Transaction %s has no responses defined!\n", transactions[i].name);
 
548
    }
 
549
    if (transactions[i].isInvite && transactions[i].acks == 0) {
 
550
      ERROR("Transaction %s is an INVITE transaction without an ACK!\n", transactions[i].name);
 
551
    }
 
552
    if (!transactions[i].isInvite && (transactions[i].acks > 0)) {
 
553
      ERROR("Transaction %s is a non-INVITE transaction with an ACK!\n", transactions[i].name);
 
554
    }
 
555
  }
 
556
}
 
557
 
 
558
/* Apply the next and ontimeout labels according to our map. */
 
559
void scenario::apply_labels(msgvec v, str_int_map labels) {
 
560
  for (unsigned int i = 0; i < v.size(); i++) {
 
561
    if (v[i]->nextLabel) {
 
562
      str_int_map::iterator label_it = labels.find(v[i]->nextLabel);
 
563
      if (label_it == labels.end()) {
 
564
        ERROR("The label '%s' was not defined (index %d, next attribute)\n", v[i]->nextLabel, i);
 
565
      }
 
566
      v[i]->next = label_it->second;
 
567
    }
 
568
    if (v[i]->onTimeoutLabel) {
 
569
      str_int_map::iterator label_it = labels.find(v[i]->onTimeoutLabel);
 
570
      if (label_it == labels.end()) {
 
571
        ERROR("The label '%s' was not defined (index %d, ontimeout attribute)\n", v[i]->onTimeoutLabel, i);
 
572
      }
 
573
      v[i]->on_timeout = label_it->second;
 
574
    }
 
575
  }
 
576
}
 
577
 
 
578
int get_cr_number(char *src)
 
579
{
 
580
  int res=0;
 
581
  char *ptr = src;
 
582
  while(*ptr) {
 
583
    if(*ptr == '\n') res++;
 
584
    *ptr++;
 
585
  }
 
586
  return res;
 
587
}
 
588
 
 
589
char *clean_cdata(char *ptr, int *removed_crlf = NULL) {
 
590
  char * msg;
 
591
 
 
592
  while((*ptr == ' ') || (*ptr == '\t') || (*ptr == '\n')) ptr++;
 
593
 
 
594
  msg = (char *) malloc(strlen(ptr) + 3);
 
595
  if(!msg) { ERROR("Memory Overflow"); }
 
596
  strcpy(msg, ptr);
 
597
 
 
598
  ptr = msg + strlen(msg);
 
599
  ptr --;
 
600
 
 
601
  while((ptr >= msg) &&
 
602
      ((*ptr == ' ')  ||
 
603
       (*ptr == '\t') ||
 
604
       (*ptr == '\n'))) {
 
605
    if(*ptr == '\n' && removed_crlf) {
 
606
      (*removed_crlf)++;
 
607
    }
 
608
    *ptr-- = 0;
 
609
  }
 
610
 
 
611
  if(!strstr(msg, "\n\n")) {
 
612
    strcat(msg, "\n\n");
 
613
  }
 
614
 
 
615
  if(ptr == msg) {
 
616
    ERROR("Empty cdata in xml scenario file");
 
617
  }
 
618
  while ((ptr = strstr(msg, "\n "))) {
 
619
    memmove(ptr + 1, ptr + 2, strlen(ptr) - 1);
 
620
  }
 
621
  while ((ptr = strstr(msg, " \n"))) {
 
622
    memmove(ptr, ptr + 1, strlen(ptr));
 
623
  }
 
624
  while ((ptr = strstr(msg, "\n\t"))) {
 
625
    memmove(ptr + 1, ptr + 2, strlen(ptr) - 1);
 
626
  }
 
627
  while ((ptr = strstr(msg, "\t\n"))) {
 
628
    memmove(ptr, ptr + 1, strlen(ptr));
 
629
  }
 
630
 
 
631
  return msg;
 
632
}
 
633
 
 
634
 
 
635
 
 
636
/********************** Scenario File analyser **********************/
 
637
 
 
638
void scenario::checkOptionalRecv(char *elem, unsigned int scenario_file_cursor) {
 
639
  if (last_recv_optional) {
 
640
    ERROR("<recv> before <%s> sequence without a mandatory message. Please remove one 'optional=true' (element %d).", elem, scenario_file_cursor);
 
641
  }
 
642
  last_recv_optional = false;
 
643
}
 
644
 
 
645
scenario::scenario(char * filename, int deflt)
 
646
{
 
647
  char * elem;
 
648
  char *method_list = NULL;
 
649
  unsigned int scenario_file_cursor = 0;
 
650
  int    L_content_length = 0 ;
 
651
  char * peer; 
 
652
 
 
653
  last_recv_optional = false;
 
654
 
 
655
  if(filename) {
 
656
    if(!xp_set_xml_buffer_from_file(filename)) {
 
657
      ERROR("Unable to load or parse '%s' xml scenario file", filename);
 
658
    }
 
659
  } else {
 
660
    if(!xp_set_xml_buffer_from_string(default_scenario[deflt])) {
 
661
      ERROR("Unable to load default xml scenario file");
 
662
    }
 
663
  }
 
664
 
 
665
  stats = new CStat();
 
666
  allocVars = new AllocVariableTable(userVariables);
 
667
 
 
668
  hidedefault = false;
 
669
 
 
670
  elem = xp_open_element(0);
 
671
  if (!elem) {
 
672
    ERROR("No element in xml scenario file");
 
673
  }
 
674
  if(strcmp("scenario", elem)) {
 
675
    ERROR("No 'scenario' section in xml scenario file");
 
676
  }
 
677
 
 
678
  if(char *ptr = xp_get_value((char *)"name")) {
 
679
    name = strdup(ptr);
 
680
  } else {
 
681
    name = strdup("");
 
682
  }
 
683
 
 
684
  duration = 0;
 
685
  found_timewait = false;
 
686
 
 
687
  scenario_file_cursor = 0;
 
688
 
 
689
  while ((elem = xp_open_element(scenario_file_cursor))) {
 
690
    char * ptr;
 
691
    scenario_file_cursor ++;
 
692
 
 
693
    if(!strcmp(elem, "CallLengthRepartition")) {
 
694
      ptr = xp_get_string("value", "CallLengthRepartition");
 
695
      stats->setRepartitionCallLength(ptr);
 
696
      free(ptr);
 
697
    } else if(!strcmp(elem, "ResponseTimeRepartition")) {
 
698
      ptr = xp_get_string("value", "ResponseTimeRepartition");
 
699
      stats->setRepartitionResponseTime(ptr);
 
700
      free(ptr);
 
701
    } else if(!strcmp(elem, "Global")) {
 
702
      ptr = xp_get_string("variables", "Global");
 
703
 
 
704
      char **       currentTabVarName = NULL;
 
705
      int           currentNbVarNames;
 
706
 
 
707
      createStringTable(ptr, &currentTabVarName, &currentNbVarNames);
 
708
      for (int i = 0; i < currentNbVarNames; i++) {
 
709
        globalVariables->find(currentTabVarName[i], true);
 
710
      }
 
711
      freeStringTable(currentTabVarName, currentNbVarNames);
 
712
      free(ptr);
 
713
    } else if(!strcmp(elem, "User")) {
 
714
      ptr = xp_get_string("variables", "User");
 
715
 
 
716
      char **       currentTabVarName = NULL;
 
717
      int           currentNbVarNames;
 
718
 
 
719
      createStringTable(ptr, &currentTabVarName, &currentNbVarNames);
 
720
      for (int i = 0; i < currentNbVarNames; i++) {
 
721
        userVariables->find(currentTabVarName[i], true);
 
722
      }
 
723
      freeStringTable(currentTabVarName, currentNbVarNames);
 
724
      free(ptr);
 
725
    } else if(!strcmp(elem, "Reference")) {
 
726
      ptr = xp_get_string("variables", "Reference");
 
727
 
 
728
      char **       currentTabVarName = NULL;
 
729
      int           currentNbVarNames;
 
730
 
 
731
      createStringTable(ptr, &currentTabVarName, &currentNbVarNames);
 
732
      for (int i = 0; i < currentNbVarNames; i++) {
 
733
        int id = allocVars->find(currentTabVarName[i], false);
 
734
        if (id == -1) {
 
735
          ERROR("Could not reference non-existant variable '%s'", currentTabVarName[i]);
 
736
        }
 
737
      }
 
738
      freeStringTable(currentTabVarName, currentNbVarNames);
 
739
      free(ptr);
 
740
    } else if(!strcmp(elem, "DefaultMessage")) {
 
741
      char *id = xp_get_string("id", "DefaultMessage");
 
742
      if(!(ptr = xp_get_cdata())) {
 
743
        ERROR("No CDATA in 'send' section of xml scenario file");
 
744
      }
 
745
      char *msg = clean_cdata(ptr);
 
746
      set_default_message(id, msg);
 
747
      free(id);
 
748
      /* XXX: This should really be per scenario. */
 
749
    } else if(!strcmp(elem, "label")) {
 
750
      ptr = xp_get_string("id", "label");
 
751
      if (labelMap.find(ptr) != labelMap.end()) {
 
752
        ERROR("The label name '%s' is used twice.", ptr);
 
753
      }
 
754
      labelMap[ptr] = messages.size();
 
755
      free(ptr);
 
756
    } else if (!strcmp(elem, "init")) {
 
757
      /* We have an init section, which must be full of nops or labels. */
 
758
      int nop_cursor = 0;
 
759
      char *initelem;
 
760
      while ((initelem = xp_open_element(nop_cursor++))) {
 
761
        if (!strcmp(initelem, "nop")) {
 
762
          /* We should parse this. */
 
763
          message *nopmsg = new message(initmessages.size(), "scenario initialization");
 
764
          initmessages.push_back(nopmsg);
 
765
          nopmsg->M_type = MSG_TYPE_NOP;
 
766
          getCommonAttributes(nopmsg);
 
767
        } else if (!strcmp(initelem, "label")) {
 
768
          /* Add an init label. */
 
769
          ptr = xp_get_value((char *)"id");
 
770
          if (initLabelMap.find(ptr) != initLabelMap.end()) {
 
771
            ERROR("The label name '%s' is used twice.", ptr);
 
772
          }
 
773
          initLabelMap[ptr] = initmessages.size();
 
774
        } else {
 
775
          ERROR("Invalid element in an init stanza: '%s'", initelem);
 
776
        }
 
777
        xp_close_element();
 
778
      }
 
779
    } else { /** Message Case */
 
780
      if (found_timewait) {
 
781
        ERROR("<timewait> can only be the last message in a scenario!\n");
 
782
      }
 
783
      message *curmsg = new message(messages.size(), name ? name : "unknown scenario");
 
784
      messages.push_back(curmsg);
 
785
 
 
786
      if(!strcmp(elem, "send")) {
 
787
        checkOptionalRecv(elem, scenario_file_cursor);
 
788
        curmsg->M_type = MSG_TYPE_SEND;
 
789
        /* Sent messages descriptions */
 
790
        if(!(ptr = xp_get_cdata())) {
 
791
          ERROR("No CDATA in 'send' section of xml scenario file");
 
792
        }
 
793
 
 
794
        int removed_clrf = 0;
 
795
        char * msg = clean_cdata(ptr, &removed_clrf);
 
796
 
 
797
        L_content_length = xp_get_content_length(msg);
 
798
        switch (L_content_length) {
 
799
          case  -1 :
 
800
            // the msg does not contain content-length field
 
801
            break ;
 
802
          case  0 :
 
803
            curmsg -> content_length_flag =
 
804
              message::ContentLengthValueZero;   // Initialize to No present
 
805
            break ;
 
806
          default :
 
807
            curmsg -> content_length_flag =
 
808
              message::ContentLengthValueNoZero;   // Initialize to No present
 
809
            break ;
 
810
        }
 
811
 
 
812
        if((msg[strlen(msg) - 1] != '\n') && (removed_clrf)) {
 
813
          strcat(msg, "\n");
 
814
        }
 
815
        char *tsrc = msg;
 
816
        while(*tsrc++);
 
817
        curmsg -> send_scheme = new SendingMessage(this, msg);
 
818
        free(msg);
 
819
 
 
820
        // If this is a request we are sending, then store our transaction/method matching information.
 
821
        if (!curmsg->send_scheme->isResponse()) {
 
822
          char *method = curmsg->send_scheme->getMethod();
 
823
          bool isInvite = !strcmp(method, "INVITE");
 
824
          bool isAck = !strcmp(method, "ACK");
 
825
 
 
826
          if ((ptr = xp_get_value("start_txn"))) {
 
827
            if (isAck) {
 
828
                ERROR("An ACK message can not start a transaction!");
 
829
            }
 
830
            curmsg->start_txn = get_txn(ptr, "start transaction", true, isInvite, false);
 
831
          } else if ((ptr = xp_get_value("ack_txn"))) {
 
832
            if (!isAck) {
 
833
                ERROR("The ack_txn attribute is valid only for ACK messages!");
 
834
            }
 
835
            curmsg->ack_txn = get_txn(ptr, "ack transaction", false, false, true);
 
836
          } else {
 
837
            int len = method_list ? strlen(method_list) : 0;
 
838
            method_list = (char *)realloc(method_list, len + strlen(method) + 1);
 
839
            if (!method_list) {
 
840
                ERROR_NO("Out of memory allocating method_list!");
 
841
            }
 
842
            strcpy(method_list + len, method);
 
843
          }
 
844
        } else {
 
845
          if ((ptr = xp_get_value("start_txn"))) {
 
846
            ERROR("Responses can not start a transaction");
 
847
          }
 
848
          if ((ptr = xp_get_value("ack_txn"))) {
 
849
            ERROR("Responses can not ACK a transaction");
 
850
          }
 
851
        }
 
852
 
 
853
        if ((ptr = xp_get_value("response_txn"))) {
 
854
          ERROR("response_txn can only be used for recieved messages.");
 
855
        }
 
856
 
 
857
        curmsg -> retrans_delay = xp_get_long("retrans", "retransmission timer", 0);
 
858
        curmsg -> timeout = xp_get_long("timeout", "message send timeout", 0);
 
859
      } else if(!strcmp(elem, (char *)"recv")) {
 
860
        curmsg->M_type = MSG_TYPE_RECV;
 
861
        /* Received messages descriptions */
 
862
        if((ptr = xp_get_value((char *)"response"))) {
 
863
          curmsg ->recv_response = get_long(ptr, "response code");
 
864
          if (method_list) {
 
865
            curmsg->recv_response_for_cseq_method_list = strdup(method_list);
 
866
          }
 
867
          if ((ptr = xp_get_value("response_txn"))) {
 
868
            curmsg->response_txn = get_txn(ptr, "transaction response", false, false, false);
 
869
          }
 
870
        }
 
871
 
 
872
        if((ptr = xp_get_value((char *)"request"))) {
 
873
          curmsg -> recv_request = strdup(ptr);
 
874
          if ((ptr = xp_get_value("response_txn"))) {
 
875
            ERROR("response_txn can only be used for recieved responses.");
 
876
          }
 
877
        }
 
878
 
 
879
        curmsg->optional = xp_get_optional("optional", "recv");
 
880
        last_recv_optional = curmsg->optional;
 
881
        curmsg->advance_state = xp_get_bool("advance_state", "recv", true);
 
882
        if (!curmsg->advance_state && curmsg->optional == OPTIONAL_FALSE) {
 
883
          ERROR("advance_state is allowed only for optional messages (index = %d)\n", messages.size() - 1);
 
884
        }
 
885
 
 
886
        if (0 != (ptr = xp_get_value((char *)"regexp_match"))) {
 
887
          if(!strcmp(ptr, "true")) {
 
888
            curmsg -> regexp_match = 1;
 
889
          }
 
890
        }
 
891
 
 
892
        curmsg->timeout = xp_get_long("timeout", "message timeout", 0);
 
893
 
 
894
        /* record the route set  */
 
895
        /* TODO disallow optional and rrs to coexist? */
 
896
        if((ptr = xp_get_value((char *)"rrs"))) {
 
897
          curmsg -> bShouldRecordRoutes = get_bool(ptr, "record route set");
 
898
        }
 
899
 
 
900
        /* record the authentication credentials  */
 
901
        if((ptr = xp_get_value((char *)"auth"))) {
 
902
          bool temp = get_bool(ptr, "message authentication");
 
903
#ifdef _USE_OPENSSL
 
904
          curmsg -> bShouldAuthenticate = temp;
 
905
#else
 
906
          if (temp) {
 
907
            ERROR("Authentication requires OpenSSL support!");
 
908
          }
 
909
#endif
 
910
        }
 
911
      } else if(!strcmp(elem, "pause") || !strcmp(elem, "timewait")) {
 
912
        checkOptionalRecv(elem, scenario_file_cursor);
 
913
        curmsg->M_type = MSG_TYPE_PAUSE;
 
914
        if (!strcmp(elem, "timewait")) {
 
915
          curmsg->timewait = true;
 
916
          found_timewait = true;
 
917
        }
 
918
 
 
919
        int var;
 
920
        if ((var = xp_get_var("variable", "pause", -1)) != -1) {
 
921
          curmsg->pause_variable = var;
 
922
        } else {
 
923
          CSample *distribution = parse_distribution(true);
 
924
 
 
925
          bool sanity_check = xp_get_bool("sanity_check", "pause", true);
 
926
 
 
927
          double pause_duration = distribution->cdfInv(0.99);
 
928
          if (sanity_check && (pause_duration > INT_MAX)) {
 
929
            char percentile[100];
 
930
            char desc[100];
 
931
 
 
932
            distribution->timeDescr(desc, sizeof(desc));
 
933
            time_string(pause_duration, percentile, sizeof(percentile));
 
934
 
 
935
            ERROR("The distribution %s has a 99th percentile of %s, which is larger than INT_MAX.  You should chose different parameters.", desc, percentile);
 
936
          }
 
937
 
 
938
          curmsg->pause_distribution = distribution;
 
939
          /* Update scenario duration with max duration */
 
940
          duration += (int)pause_duration;
 
941
        }
 
942
      }
 
943
      else if(!strcmp(elem, "nop")) {
 
944
        checkOptionalRecv(elem, scenario_file_cursor);
 
945
        /* Does nothing at SIP level.  This message type can be used to handle
 
946
         * actions, increment counters, or for RTDs. */
 
947
        curmsg->M_type = MSG_TYPE_NOP;
 
948
      }
 
949
      else if(!strcmp(elem, "recvCmd")) {
 
950
        curmsg->M_type = MSG_TYPE_RECVCMD;
 
951
        curmsg->optional = xp_get_optional("optional", "recv");
 
952
        last_recv_optional = curmsg->optional;
 
953
 
 
954
        /* 3pcc extended mode */
 
955
        if((ptr = xp_get_value((char *)"src"))) {
 
956
           curmsg ->peer_src = strdup(ptr);
 
957
        } else if (extendedTwinSippMode) {
 
958
          ERROR("You must specify a 'src' for recvCmd when using extended 3pcc mode!");
 
959
        }
 
960
      } else if(!strcmp(elem, "sendCmd")) {
 
961
        checkOptionalRecv(elem, scenario_file_cursor);
 
962
        curmsg->M_type = MSG_TYPE_SENDCMD;
 
963
        /* Sent messages descriptions */
 
964
 
 
965
        /* 3pcc extended mode  */
 
966
        if((ptr = xp_get_value((char *)"dest"))) { 
 
967
           peer = strdup(ptr) ;
 
968
           curmsg ->peer_dest = peer ;
 
969
           peer_map::iterator peer_it;
 
970
           peer_it = peers.find(peer_map::key_type(peer));
 
971
           if(peer_it == peers.end())  /* the peer (slave or master)
 
972
                                          has not been added in the map
 
973
                                          (first occurence in the scenario) */
 
974
           {
 
975
             T_peer_infos infos;
 
976
             infos.peer_socket = 0;
 
977
             strcpy(infos.peer_host, get_peer_addr(peer));
 
978
             peers[std::string(peer)] = infos; 
 
979
           }
 
980
        } else if (extendedTwinSippMode) {
 
981
          ERROR("You must specify a 'dest' for sendCmd with extended 3pcc mode!");
 
982
        }
 
983
 
 
984
        if(!(ptr = xp_get_cdata())) {
 
985
          ERROR("No CDATA in 'sendCmd' section of xml scenario file");
 
986
        }
 
987
        char *msg = clean_cdata(ptr);
 
988
 
 
989
        curmsg -> M_sendCmdData = new SendingMessage(this, msg, true /* skip sanity */);
 
990
        free(msg);
 
991
      }
 
992
      else {
 
993
        ERROR("Unknown element '%s' in xml scenario file", elem);
 
994
      }
 
995
 
 
996
      getCommonAttributes(curmsg);
 
997
    } /** end * Message case */
 
998
    xp_close_element();
 
999
  } // end while
 
1000
 
 
1001
  free(method_list);
 
1002
 
 
1003
  str_int_map::iterator label_it = labelMap.find("_unexp.main");
 
1004
  if (label_it != labelMap.end()) {
 
1005
    unexpected_jump = label_it->second;
 
1006
  } else {
 
1007
    unexpected_jump = -1;
 
1008
  }
 
1009
  retaddr = find_var("_unexp.retaddr", "unexpected return address");
 
1010
  pausedaddr = find_var("_unexp.pausedaddr", "unexpected paused until");
 
1011
 
 
1012
  /* Patch up the labels. */
 
1013
  apply_labels(messages, labelMap);
 
1014
  apply_labels(initmessages, initLabelMap);
 
1015
 
 
1016
  /* Some post-scenario loading validation. */
 
1017
  stats->validateRtds();
 
1018
 
 
1019
  /* Make sure that all variables are used more than once. */
 
1020
  validate_variable_usage();
 
1021
 
 
1022
  /* Make sure that all started transactions have responses, and vice versa. */
 
1023
  validate_txn_usage();
 
1024
 
 
1025
  if (messages.size() == 0) {
 
1026
    ERROR("Did not find any messages inside of scenario!");
 
1027
  }
 
1028
}
 
1029
 
 
1030
void scenario::runInit() {
 
1031
  call *initcall;
 
1032
  if (initmessages.size() > 0) {
 
1033
    initcall = new call(main_scenario, NULL, NULL, "///main-init", 0, false, false, true);
 
1034
    initcall->run();
 
1035
  }
 
1036
}
 
1037
 
 
1038
void clear_int_str(int_str_map m) {
 
1039
  for(int_str_map::iterator it = m.begin(); it != m.end(); it = m.begin()) {
 
1040
    free(it->second);
 
1041
    m.erase(it);
 
1042
  }
 
1043
}
 
1044
 
 
1045
void clear_str_int(str_int_map m) {
 
1046
  for(str_int_map::iterator it = m.begin(); it != m.end(); it = m.begin()) {
 
1047
    m.erase(it);
 
1048
  }
 
1049
}
 
1050
 
 
1051
void clear_int_int(int_int_map m) {
 
1052
  for(int_int_map::iterator it = m.begin(); it != m.end(); it = m.begin()) {
 
1053
    m.erase(it);
 
1054
  }
 
1055
}
 
1056
 
 
1057
scenario::~scenario() {
 
1058
  for (msgvec::iterator i = messages.begin(); i != messages.end(); i++) {
 
1059
    delete *i;
 
1060
  }
 
1061
  messages.clear();
 
1062
 
 
1063
  free(name);
 
1064
 
 
1065
  allocVars->putTable();
 
1066
  delete stats;
 
1067
 
 
1068
  for (unsigned int i = 0; i < transactions.size(); i++) {
 
1069
    free(transactions[i].name);
 
1070
  }
 
1071
  transactions.clear();
 
1072
 
 
1073
  clear_str_int(labelMap);
 
1074
  clear_str_int(initLabelMap);
 
1075
  clear_str_int(txnMap);
 
1076
}
 
1077
 
 
1078
CSample *parse_distribution(bool oldstyle = false) {
 
1079
  CSample *distribution;
 
1080
  char *distname;
 
1081
  char *ptr;
 
1082
 
 
1083
  if(!(distname = xp_get_value("distribution"))) {
 
1084
    if (!oldstyle) {
 
1085
      ERROR("statistically distributed actions or pauses requires 'distribution' parameter");
 
1086
    }
 
1087
    if ((ptr = xp_get_value("normal"))) {
 
1088
        distname = "normal";
 
1089
    } else if ((ptr = xp_get_value("exponential"))) {
 
1090
        distname = "exponential";
 
1091
    } else if ((ptr = xp_get_value("lognormal"))) {
 
1092
        distname = "lognormal";
 
1093
    } else if ((ptr = xp_get_value("weibull"))) {
 
1094
        distname = "weibull";
 
1095
    } else if ((ptr = xp_get_value("pareto"))) {
 
1096
      distname = "pareto";
 
1097
    } else if ((ptr = xp_get_value("gamma"))) {
 
1098
      distname = "gamma";
 
1099
    } else if ((ptr = xp_get_value("min"))) {
 
1100
        distname = "uniform";
 
1101
    } else if ((ptr = xp_get_value("max"))) {
 
1102
        distname = "uniform";
 
1103
    } else if ((ptr = xp_get_value("milliseconds"))) {
 
1104
        double val = get_double(ptr, "Pause milliseconds");
 
1105
        return new CFixed(val);
 
1106
    } else {
 
1107
        return new CDefaultPause();
 
1108
    }
 
1109
  }
 
1110
 
 
1111
  if (!strcmp(distname, "fixed")) {
 
1112
    double value = xp_get_double("value", "Fixed distribution");
 
1113
    distribution = new CFixed(value);
 
1114
  } else if (!strcmp(distname, "uniform")) {
 
1115
    double min = xp_get_double("min", "Uniform distribution");
 
1116
    double max = xp_get_double("max", "Uniform distribution");
 
1117
    distribution = new CUniform(min, max);
 
1118
#ifdef HAVE_GSL
 
1119
  } else if (!strcmp(distname, "normal")) {
 
1120
    double mean = xp_get_double("mean", "Normal distribution");
 
1121
    double stdev = xp_get_double("stdev", "Normal distribution");
 
1122
    distribution = new CNormal(mean, stdev);
 
1123
  } else if (!strcmp(distname, "lognormal")) {
 
1124
    double mean = xp_get_double("mean", "Lognormal distribution");
 
1125
    double stdev = xp_get_double("stdev", "Lognormal distribution");
 
1126
    distribution = new CLogNormal(mean, stdev);
 
1127
  } else if (!strcmp(distname, "exponential")) {
 
1128
    double mean = xp_get_double("mean", "Exponential distribution");
 
1129
    distribution = new CExponential(mean);
 
1130
  } else if (!strcmp(distname, "weibull")) {
 
1131
    double lambda = xp_get_double("lambda", "Weibull distribution");
 
1132
    double k = xp_get_double("k", "Weibull distribution");
 
1133
    distribution = new CWeibull(lambda, k);
 
1134
  } else if (!strcmp(distname, "pareto")) {
 
1135
    double k = xp_get_double("k", "Pareto distribution");
 
1136
    double xsubm = xp_get_double("x_m", "Pareto distribution");
 
1137
    distribution = new CPareto(k, xsubm);
 
1138
  } else if (!strcmp(distname, "gpareto")) {
 
1139
    double shape = xp_get_double("shape", "Generalized Pareto distribution");
 
1140
    double scale = xp_get_double("scale", "Generalized Pareto distribution");
 
1141
    double location = xp_get_double("location", "Generalized Pareto distribution");
 
1142
    distribution = new CGPareto(shape, scale, location);
 
1143
  } else if (!strcmp(distname, "gamma")) {
 
1144
    double k = xp_get_double("k", "Gamma distribution");
 
1145
    double theta = xp_get_double("theta", "Gamma distribution");
 
1146
    distribution = new CGamma(k, theta);
 
1147
  } else if (!strcmp(distname, "negbin")) {
 
1148
    double n = xp_get_double("n", "Negative Binomial distribution");
 
1149
    double p = xp_get_double("p", "Negative Binomial distribution");
 
1150
    distribution = new CNegBin(n, p);
 
1151
#else
 
1152
  } else if (!strcmp(distname, "normal")
 
1153
      || !strcmp(distname, "lognormal")
 
1154
      || !strcmp(distname, "exponential")
 
1155
      || !strcmp(distname, "pareto")
 
1156
      || !strcmp(distname, "gamma")
 
1157
      || !strcmp(distname, "negbin")
 
1158
      || !strcmp(distname, "weibull")) {
 
1159
    ERROR("The distribution '%s' is only available with GSL.", distname);
 
1160
#endif
 
1161
  } else {
 
1162
    ERROR("Unknown distribution: %s\n", ptr);
 
1163
  }
 
1164
 
 
1165
  return distribution;
 
1166
}
 
1167
 
 
1168
 
 
1169
 
 
1170
/* 3pcc extended mode:
 
1171
   get the correspondances between
 
1172
   slave and master names and their 
 
1173
   addresses */
 
1174
 
 
1175
void parse_slave_cfg()
 
1176
{
 
1177
  FILE * f;
 
1178
  char line[MAX_PEER_SIZE];
 
1179
  char * temp_peer;
 
1180
  char * temp_host;
 
1181
  char * peer_host;
 
1182
 
 
1183
  f = fopen(slave_cfg_file, "r");
 
1184
  if(f){
 
1185
     while (fgets(line, MAX_PEER_SIZE, f) != NULL)
 
1186
     {
 
1187
       if((temp_peer = strtok(line, ";"))) {
 
1188
         if((peer_host = (char *) malloc(MAX_PEER_SIZE))){
 
1189
           if((temp_host  = strtok(NULL, ";"))){
 
1190
              strcpy(peer_host, temp_host);
 
1191
              peer_addrs[std::string(temp_peer)] = peer_host;
 
1192
             }
 
1193
         }else {
 
1194
             ERROR("Cannot allocate memory!\n");
 
1195
           }
 
1196
       }
 
1197
     }
 
1198
   }else{
 
1199
     ERROR("Can not open slave_cfg file %s\n", slave_cfg_file);
 
1200
     }
 
1201
 
 
1202
}
 
1203
 
 
1204
// Determine in which mode the sipp tool has been 
 
1205
// launched (client, server, 3pcc client, 3pcc server, 3pcc extended master or slave)
 
1206
void scenario::computeSippMode()
 
1207
{
 
1208
  bool isRecvCmdFound = false;
 
1209
  bool isSendCmdFound = false;
 
1210
 
 
1211
  creationMode = -1;
 
1212
  sendMode = -1;
 
1213
  thirdPartyMode = MODE_3PCC_NONE;
 
1214
 
 
1215
  assert(messages.size() > 0);
 
1216
 
 
1217
  for(unsigned int i=0; i<messages.size(); i++)
 
1218
    {
 
1219
      switch(messages[i]->M_type)
 
1220
        {
 
1221
        case MSG_TYPE_PAUSE:
 
1222
        case MSG_TYPE_NOP:
 
1223
          /* Allow pauses or nops to go first. */
 
1224
          continue;
 
1225
        case MSG_TYPE_SEND:
 
1226
          if (sendMode == -1) {
 
1227
            sendMode = MODE_CLIENT;
 
1228
          }
 
1229
          if (creationMode == -1) {
 
1230
            creationMode = MODE_CLIENT;
 
1231
          }
 
1232
          break;
 
1233
 
 
1234
        case MSG_TYPE_RECV:
 
1235
          if (sendMode == -1) {
 
1236
            sendMode = MODE_SERVER;
 
1237
          }
 
1238
          if (creationMode == -1) {
 
1239
            creationMode = MODE_SERVER;
 
1240
          }
 
1241
          break;
 
1242
        case MSG_TYPE_SENDCMD:
 
1243
          isSendCmdFound = true;
 
1244
          if (creationMode == -1) {
 
1245
            creationMode = MODE_CLIENT;
 
1246
          }
 
1247
          if(!isRecvCmdFound) {
 
1248
            if (creationMode == MODE_SERVER) {
 
1249
              /*
 
1250
               * If it is a server already, then start it in
 
1251
               * 3PCC A passive mode
 
1252
               */
 
1253
               if(twinSippMode){
 
1254
                 thirdPartyMode = MODE_3PCC_A_PASSIVE;
 
1255
               }else if (extendedTwinSippMode){
 
1256
                 thirdPartyMode = MODE_MASTER_PASSIVE;
 
1257
               }
 
1258
            } else {
 
1259
                if(twinSippMode){
 
1260
                  thirdPartyMode = MODE_3PCC_CONTROLLER_A;
 
1261
                }else if (extendedTwinSippMode){
 
1262
                  thirdPartyMode = MODE_MASTER;
 
1263
                }
 
1264
            }
 
1265
            if((thirdPartyMode == MODE_MASTER_PASSIVE || thirdPartyMode == MODE_MASTER) && !master_name){
 
1266
              ERROR("Inconsistency between command line and scenario: master scenario but -master option not set\n");
 
1267
            }
 
1268
            if(!twinSippMode && !extendedTwinSippMode)
 
1269
              ERROR("sendCmd message found in scenario but no twin sipp"
 
1270
                    " address has been passed! Use -3pcc option or 3pcc extended mode.\n");
 
1271
          }
 
1272
          break;
 
1273
 
 
1274
        case MSG_TYPE_RECVCMD:
 
1275
          if (creationMode == -1) {
 
1276
            creationMode = MODE_SERVER;
 
1277
          }
 
1278
          isRecvCmdFound = true;
 
1279
          if(!isSendCmdFound)
 
1280
            {
 
1281
              if(twinSippMode){
 
1282
                thirdPartyMode = MODE_3PCC_CONTROLLER_B;
 
1283
              } else if(extendedTwinSippMode){
 
1284
                thirdPartyMode = MODE_SLAVE;
 
1285
                 if(!slave_number) {
 
1286
                   ERROR("Inconsistency between command line and scenario: slave scenario but -slave option not set\n");
 
1287
                 }else{
 
1288
                   thirdPartyMode = MODE_SLAVE;
 
1289
                 }
 
1290
              }
 
1291
              if(!twinSippMode && !extendedTwinSippMode)
 
1292
                ERROR("recvCmd message found in scenario but no "
 
1293
                      "twin sipp address has been passed! Use "
 
1294
                      "-3pcc option\n");
 
1295
            }
 
1296
          break;
 
1297
        default:
 
1298
          break;
 
1299
        }
 
1300
    }
 
1301
    if(creationMode == -1)
 
1302
      ERROR("Unable to determine creation mode of the tool (server, client)\n");
 
1303
    if(sendMode == -1)
 
1304
      ERROR("Unable to determine send mode of the tool (server, client)\n");
 
1305
}
 
1306
 
 
1307
void scenario::handle_rhs(CAction *tmpAction, char *what) {
 
1308
  if (xp_get_value("value")) {
 
1309
    tmpAction->setDoubleValue(xp_get_double("value", what));
 
1310
    if (xp_get_value("variable")) {
 
1311
      ERROR("Value and variable are mutually exclusive for %s action!", what);
 
1312
    }
 
1313
  } else if (xp_get_value("variable")) {
 
1314
    tmpAction->setVarInId(xp_get_var("variable", what));
 
1315
    if (xp_get_value("value")) {
 
1316
      ERROR("Value and variable are mutually exclusive for %s action!", what);
 
1317
    }
 
1318
  } else {
 
1319
    ERROR("No value or variable defined for %s action!", what);
 
1320
  }
 
1321
}
 
1322
 
 
1323
void scenario::handle_arithmetic(CAction *tmpAction, char *what) {
 
1324
  tmpAction->setVarId(xp_get_var("assign_to", what));
 
1325
  handle_rhs(tmpAction, what);
 
1326
}
 
1327
 
 
1328
void scenario::parseAction(CActions *actions) {
 
1329
  char *        actionElem;
 
1330
  unsigned int recvScenarioLen = 0;
 
1331
  char *        currentRegExp = NULL;
 
1332
  char *        buffer = NULL;
 
1333
  char **       currentTabVarName = NULL;
 
1334
  int           currentNbVarNames;
 
1335
  char * ptr;
 
1336
  int           sub_currentNbVarId;
 
1337
 
 
1338
  while((actionElem = xp_open_element(recvScenarioLen))) {
 
1339
    CAction *tmpAction = new CAction(this);
 
1340
 
 
1341
    if(!strcmp(actionElem, "ereg")) {
 
1342
      ptr = xp_get_string("regexp", "ereg");
 
1343
 
 
1344
      // keeping regexp expression in memory
 
1345
      if(currentRegExp != NULL)
 
1346
        delete[] currentRegExp;
 
1347
      currentRegExp = new char[strlen(ptr)+1];
 
1348
      buffer = new char[strlen(ptr)+1];
 
1349
      xp_replace(ptr, buffer, "&lt;", "<");
 
1350
      xp_replace(buffer, currentRegExp, "&gt;", ">");
 
1351
      if(buffer != NULL)
 
1352
        delete[] buffer;
 
1353
      tmpAction->setActionType(CAction::E_AT_ASSIGN_FROM_REGEXP);
 
1354
 
 
1355
      // warning - although these are detected for both msg and hdr
 
1356
      // they are only implemented for search_in="hdr"
 
1357
      tmpAction->setCaseIndep(xp_get_bool("case_indep", "ereg", false));
 
1358
      tmpAction->setHeadersOnly(xp_get_bool("start_line", "ereg", false));
 
1359
 
 
1360
      free(ptr);
 
1361
      if ( 0 != ( ptr = xp_get_value((char *)"search_in") ) ) {
 
1362
        tmpAction->setOccurence(1);
 
1363
 
 
1364
        if ( 0 == strcmp(ptr, (char *)"msg") ) {
 
1365
          tmpAction->setLookingPlace(CAction::E_LP_MSG);
 
1366
          tmpAction->setLookingChar (NULL);
 
1367
        } else if ( 0 == strcmp(ptr, (char *)"body") ) {
 
1368
          tmpAction->setLookingPlace(CAction::E_LP_BODY);
 
1369
          tmpAction->setLookingChar (NULL);
 
1370
        } else if (!strcmp(ptr, (char *)"var")) {
 
1371
          tmpAction->setVarInId(xp_get_var("variable", "ereg"));
 
1372
          tmpAction->setLookingPlace(CAction::E_LP_VAR);
 
1373
        } else if (!strcmp(ptr, (char *)"hdr")) {
 
1374
          ptr = xp_get_value((char *)"header");
 
1375
          if (!ptr || !strlen(ptr)) {
 
1376
            ERROR("search_in=\"hdr\" requires header field");
 
1377
          }
 
1378
          tmpAction->setLookingPlace(CAction::E_LP_HDR);
 
1379
          tmpAction->setLookingChar(ptr);
 
1380
          if (0 != (ptr = xp_get_value((char *)"occurence"))) {
 
1381
            tmpAction->setOccurence (atol(ptr));
 
1382
          }
 
1383
          if (0 != (ptr = xp_get_value((char *)"occurrence"))) {
 
1384
            tmpAction->setOccurence (atol(ptr));
 
1385
          }
 
1386
        } else {
 
1387
          ERROR("Unknown search_in value %s", ptr);
 
1388
        }
 
1389
      } else {
 
1390
        tmpAction->setLookingPlace(CAction::E_LP_MSG);
 
1391
        tmpAction->setLookingChar(NULL);
 
1392
      } // end if-else search_in
 
1393
 
 
1394
      if (xp_get_value("check_it")) {
 
1395
      tmpAction->setCheckIt(xp_get_bool("check_it", "ereg", false));
 
1396
          if (xp_get_value("check_it_inverse")) {
 
1397
              ERROR("Can not have both check_it and check_it_inverse for ereg!");
 
1398
          }
 
1399
      } else {
 
1400
          tmpAction->setCheckItInverse(xp_get_bool("check_it_inverse", "ereg", false));
 
1401
      }
 
1402
 
 
1403
      if (!(ptr = xp_get_value((char *) "assign_to"))) {
 
1404
        ERROR("assign_to value is missing");
 
1405
      }
 
1406
 
 
1407
      createStringTable(ptr, &currentTabVarName, &currentNbVarNames);
 
1408
 
 
1409
      int varId = get_var(currentTabVarName[0], "assign_to");
 
1410
      tmpAction->setVarId(varId);
 
1411
 
 
1412
      tmpAction->setRegExp(currentRegExp);
 
1413
      if (currentNbVarNames > 1 ) {
 
1414
        sub_currentNbVarId = currentNbVarNames - 1 ;
 
1415
        tmpAction->setNbSubVarId(sub_currentNbVarId);
 
1416
 
 
1417
        for(int i=1; i<= sub_currentNbVarId; i++) {
 
1418
          int varId = get_var(currentTabVarName[i], "sub expression assign_to");
 
1419
          tmpAction->setSubVarId(varId);
 
1420
        }
 
1421
      }
 
1422
 
 
1423
      freeStringTable(currentTabVarName, currentNbVarNames);
 
1424
 
 
1425
      if(currentRegExp != NULL) {
 
1426
        delete[] currentRegExp;
 
1427
      }
 
1428
      currentRegExp = NULL;
 
1429
    } /* end !strcmp(actionElem, "ereg") */ else if(!strcmp(actionElem, "log")) {
 
1430
      tmpAction->setMessage(xp_get_string("message", "log"));
 
1431
      tmpAction->setActionType(CAction::E_AT_LOG_TO_FILE);
 
1432
    } else if(!strcmp(actionElem, "warning")) {
 
1433
      tmpAction->setMessage(xp_get_string("message", "warning"));
 
1434
      tmpAction->setActionType(CAction::E_AT_LOG_WARNING);
 
1435
    } else if(!strcmp(actionElem, "error")) {
 
1436
      tmpAction->setMessage(xp_get_string("message", "error"));
 
1437
      tmpAction->setActionType(CAction::E_AT_LOG_ERROR);
 
1438
    } else if(!strcmp(actionElem, "assign")) {
 
1439
      tmpAction->setActionType(CAction::E_AT_ASSIGN_FROM_VALUE);
 
1440
      handle_arithmetic(tmpAction, "assign");
 
1441
    } else if(!strcmp(actionElem, "assignstr")) {
 
1442
      tmpAction->setActionType(CAction::E_AT_ASSIGN_FROM_STRING);
 
1443
      tmpAction->setVarId(xp_get_var("assign_to", "assignstr"));
 
1444
      tmpAction->setMessage(xp_get_string("value", "assignstr"));
 
1445
    } else if(!strcmp(actionElem, "gettimeofday")) {
 
1446
      tmpAction->setActionType(CAction::E_AT_ASSIGN_FROM_GETTIMEOFDAY);
 
1447
 
 
1448
      if (!(ptr = xp_get_value((char *) "assign_to"))) {
 
1449
        ERROR("assign_to value is missing");
 
1450
      }
 
1451
      createStringTable(ptr, &currentTabVarName, &currentNbVarNames);
 
1452
      if (currentNbVarNames != 2 ) {
 
1453
        ERROR("The gettimeofday action requires two output variables!");
 
1454
      }
 
1455
      tmpAction->setNbSubVarId(1);
 
1456
 
 
1457
      int varId = get_var(currentTabVarName[0], "gettimeofday seconds assign_to");
 
1458
      tmpAction->setVarId(varId);
 
1459
      varId = get_var(currentTabVarName[1], "gettimeofday useconds assign_to");
 
1460
      tmpAction->setSubVarId(varId);
 
1461
 
 
1462
      freeStringTable(currentTabVarName, currentNbVarNames);
 
1463
    } else if(!strcmp(actionElem, "index")) {
 
1464
      tmpAction->setVarId(xp_get_var("assign_to", "index"));
 
1465
      tmpAction->setActionType(CAction::E_AT_ASSIGN_FROM_INDEX);
 
1466
    } else if(!strcmp(actionElem, "jump")) {
 
1467
      tmpAction->setActionType(CAction::E_AT_JUMP);
 
1468
      handle_rhs(tmpAction, "jump");
 
1469
    } else if(!strcmp(actionElem, "pauserestore")) {
 
1470
      tmpAction->setActionType(CAction::E_AT_PAUSE_RESTORE);
 
1471
      handle_rhs(tmpAction, "pauserestore");
 
1472
    } else if(!strcmp(actionElem, "add")) {
 
1473
      tmpAction->setActionType(CAction::E_AT_VAR_ADD);
 
1474
      handle_arithmetic(tmpAction, "add");
 
1475
    } else if(!strcmp(actionElem, "subtract")) {
 
1476
      tmpAction->setActionType(CAction::E_AT_VAR_SUBTRACT);
 
1477
      handle_arithmetic(tmpAction, "subtract");
 
1478
    } else if(!strcmp(actionElem, "multiply")) {
 
1479
      tmpAction->setActionType(CAction::E_AT_VAR_MULTIPLY);
 
1480
      handle_arithmetic(tmpAction, "multiply");
 
1481
    } else if(!strcmp(actionElem, "divide")) {
 
1482
      tmpAction->setActionType(CAction::E_AT_VAR_DIVIDE);
 
1483
      handle_arithmetic(tmpAction, "divide");
 
1484
      if (tmpAction->getVarInId() == 0) {
 
1485
        if (tmpAction->getDoubleValue() == 0.0) {
 
1486
          ERROR("divide actions can not have a value of zero!");
 
1487
        }
 
1488
      }
 
1489
    } else if(!strcmp(actionElem, "sample")) {
 
1490
      tmpAction->setVarId(xp_get_var("assign_to", "sample"));
 
1491
      tmpAction->setActionType(CAction::E_AT_ASSIGN_FROM_SAMPLE);
 
1492
      tmpAction->setDistribution(parse_distribution());
 
1493
    } else if(!strcmp(actionElem, "todouble")) {
 
1494
      tmpAction->setActionType(CAction::E_AT_VAR_TO_DOUBLE);
 
1495
      tmpAction->setVarId(xp_get_var("assign_to", "todouble"));
 
1496
      tmpAction->setVarInId(xp_get_var("variable", "todouble"));
 
1497
    } else if(!strcmp(actionElem, "test")) {
 
1498
      tmpAction->setVarId(xp_get_var("assign_to", "test"));
 
1499
      tmpAction->setVarInId(xp_get_var("variable", "test"));
 
1500
      if (xp_get_value("value")) {
 
1501
        tmpAction->setDoubleValue(xp_get_double("value", "test"));
 
1502
        if (xp_get_value("variable2")) {
 
1503
          ERROR("Can not have both a value and a variable2 for test!");
 
1504
        }
 
1505
      } else {
 
1506
        tmpAction->setVarIn2Id(xp_get_var("variable2", "test"));
 
1507
      }
 
1508
      tmpAction->setActionType(CAction::E_AT_VAR_TEST);
 
1509
      ptr = xp_get_string("compare", "test");
 
1510
      if (!strcmp(ptr, "equal")) {
 
1511
        tmpAction->setComparator(CAction::E_C_EQ);
 
1512
      } else if (!strcmp(ptr, "not_equal")) {
 
1513
        tmpAction->setComparator(CAction::E_C_NE);
 
1514
      } else if (!strcmp(ptr, "greater_than")) {
 
1515
        tmpAction->setComparator(CAction::E_C_GT);
 
1516
      } else if (!strcmp(ptr, "less_than")) {
 
1517
        tmpAction->setComparator(CAction::E_C_LT);
 
1518
      } else if (!strcmp(ptr, "greater_than_equal")) {
 
1519
        tmpAction->setComparator(CAction::E_C_GEQ);
 
1520
      } else if (!strcmp(ptr, "less_than_equal")) {
 
1521
        tmpAction->setComparator(CAction::E_C_LEQ);
 
1522
      } else {
 
1523
        ERROR("Invalid 'compare' parameter: %s", ptr);
 
1524
      }
 
1525
      free(ptr);
 
1526
    } else if(!strcmp(actionElem, "verifyauth")) {
 
1527
#ifdef _USE_OPENSSL
 
1528
      tmpAction->setVarId(xp_get_var("assign_to", "verifyauth"));
 
1529
      tmpAction->setMessage(xp_get_string("username", "verifyauth"), 0);
 
1530
      tmpAction->setMessage(xp_get_string("password", "verifyauth"), 1);
 
1531
      tmpAction->setActionType(CAction::E_AT_VERIFY_AUTH);
 
1532
#else
 
1533
      ERROR("The verifyauth action requires OpenSSL support.");
 
1534
#endif
 
1535
    } else if(!strcmp(actionElem, "lookup")) {
 
1536
      tmpAction->setVarId(xp_get_var("assign_to", "lookup"));
 
1537
      tmpAction->setMessage(xp_get_string("file", "lookup"), 0);
 
1538
      tmpAction->setMessage(xp_get_string("key", "lookup"), 1);
 
1539
      tmpAction->setActionType(CAction::E_AT_LOOKUP);
 
1540
    } else if(!strcmp(actionElem, "insert")) {
 
1541
      tmpAction->setMessage(xp_get_string("file", "insert"), 0);
 
1542
      tmpAction->setMessage(xp_get_string("value", "insert"), 1);
 
1543
      tmpAction->setActionType(CAction::E_AT_INSERT);
 
1544
    } else if(!strcmp(actionElem, "replace")) {
 
1545
      tmpAction->setMessage(xp_get_string("file", "replace"), 0);
 
1546
      tmpAction->setMessage(xp_get_string("line", "replace"), 1);
 
1547
      tmpAction->setMessage(xp_get_string("value", "replace"), 2);
 
1548
      tmpAction->setActionType(CAction::E_AT_REPLACE);
 
1549
    } else if(!strcmp(actionElem, "setdest")) {
 
1550
      tmpAction->setMessage(xp_get_string("host", actionElem), 0);
 
1551
      tmpAction->setMessage(xp_get_string("port", actionElem), 1);
 
1552
      tmpAction->setMessage(xp_get_string("protocol", actionElem), 2);
 
1553
      tmpAction->setActionType(CAction::E_AT_SET_DEST);
 
1554
    } else if(!strcmp(actionElem, "closecon")) {
 
1555
      tmpAction->setActionType(CAction::E_AT_CLOSE_CON);
 
1556
    } else if(!strcmp(actionElem, "strcmp")) {
 
1557
      tmpAction->setVarId(xp_get_var("assign_to", "strcmp"));
 
1558
      tmpAction->setVarInId(xp_get_var("variable", "strcmp"));
 
1559
      if (xp_get_value("value")) {
 
1560
        tmpAction->setStringValue(xp_get_string("value", "strcmp"));
 
1561
        if (xp_get_value("variable2")) {
 
1562
          ERROR("Can not have both a value and a variable2 for strcmp!");
 
1563
        }
 
1564
      } else {
 
1565
        tmpAction->setVarIn2Id(xp_get_var("variable2", "strcmp"));
 
1566
      }
 
1567
      tmpAction->setActionType(CAction::E_AT_VAR_STRCMP);
 
1568
    } else if(!strcmp(actionElem, "trim")) {
 
1569
      tmpAction->setVarId(xp_get_var("assign_to", "trim"));
 
1570
      tmpAction->setActionType(CAction::E_AT_VAR_TRIM);
 
1571
    } else if(!strcmp(actionElem, "exec")) {
 
1572
      if((ptr = xp_get_value((char *)"command"))) {
 
1573
        tmpAction->setActionType(CAction::E_AT_EXECUTE_CMD);
 
1574
        tmpAction->setMessage(ptr);
 
1575
      } /* end (ptr = xp_get_value("command")  */ else if((ptr = xp_get_value((char *)"int_cmd"))) {
 
1576
        CAction::T_IntCmdType type(CAction::E_INTCMD_STOPCALL); /* assume the default */
 
1577
 
 
1578
        if (!strcmp(ptr, "stop_now")) {
 
1579
          type = CAction::E_INTCMD_STOP_NOW;
 
1580
        } else if (!strcmp(ptr, "stop_gracefully")) {
 
1581
          type = CAction::E_INTCMD_STOP_ALL;
 
1582
        } else if (!strcmp(ptr, "stop_call")) {
 
1583
          type = CAction::E_INTCMD_STOPCALL;
 
1584
        }
 
1585
 
 
1586
        /* the action is well formed, adding it in the */
 
1587
        /* tmpActionTable */
 
1588
        tmpAction->setActionType(CAction::E_AT_EXEC_INTCMD);
 
1589
        tmpAction->setIntCmd(type);
 
1590
#ifdef PCAPPLAY
 
1591
      } else if ((ptr = xp_get_value((char *) "play_pcap_audio"))) {
 
1592
        tmpAction->setPcapArgs(ptr);
 
1593
        tmpAction->setActionType(CAction::E_AT_PLAY_PCAP_AUDIO);
 
1594
        hasMedia = 1;
 
1595
      } else if ((ptr = xp_get_value((char *) "play_pcap_video"))) {
 
1596
        tmpAction->setPcapArgs(ptr);
 
1597
        tmpAction->setActionType(CAction::E_AT_PLAY_PCAP_VIDEO);
 
1598
        hasMedia = 1;
 
1599
#else
 
1600
      } else if ((ptr = xp_get_value((char *) "play_pcap_audio"))) {
 
1601
        ERROR("play_pcap_audio requires pcap support! Please recompile SIPp");
 
1602
      } else if ((ptr = xp_get_value((char *) "play_pcap_video"))) {
 
1603
        ERROR("play_pcap_video requires pcap support! Please recompile SIPp");
 
1604
#endif
 
1605
      } else {
 
1606
        ERROR("illegal <exec> in the scenario\n");
 
1607
      }
 
1608
    } else {
 
1609
      ERROR("Unknown action: %s", actionElem);
 
1610
    }
 
1611
 
 
1612
    /* If the action was not well-formed, there should have already been an
 
1613
     * ERROR declaration, thus it is safe to add it here at the end of the loop. */
 
1614
    actions->setAction(tmpAction);
 
1615
 
 
1616
    xp_close_element();
 
1617
    recvScenarioLen++;
 
1618
  } // end while
 
1619
}
 
1620
 
 
1621
// Action list for the message indexed by message_index in
 
1622
// the scenario
 
1623
void scenario::getActionForThisMessage(message *message)
 
1624
{
 
1625
  char *        actionElem;
 
1626
 
 
1627
  if(!(actionElem = xp_open_element(0))) {
 
1628
    return;
 
1629
  }
 
1630
  if(strcmp(actionElem, "action")) {
 
1631
    return;
 
1632
  }
 
1633
 
 
1634
  /* We actually have an action element. */
 
1635
  if(message->M_actions != NULL) {
 
1636
    ERROR("Duplicate action for %s index %d", message->desc, message->index);
 
1637
  }
 
1638
  message->M_actions = new CActions();
 
1639
 
 
1640
  parseAction(message->M_actions);
 
1641
  xp_close_element();
 
1642
}
 
1643
 
 
1644
void scenario::getBookKeeping(message *message) {
 
1645
  char *ptr;
 
1646
 
 
1647
  if((ptr = xp_get_value((char *)"rtd"))) {
 
1648
    message -> stop_rtd = get_rtd(ptr, false);
 
1649
  }
 
1650
  if ((ptr = xp_get_value((char *)"repeat_rtd"))) {
 
1651
    if (message -> stop_rtd) {
 
1652
      message-> repeat_rtd = get_bool(ptr, "repeat_rtd");
 
1653
    } else {
 
1654
      ERROR("There is a repeat_rtd element without an rtd element");
 
1655
    }
 
1656
  }
 
1657
 
 
1658
  if((ptr = xp_get_value((char *)"start_rtd"))) {
 
1659
    message -> start_rtd = get_rtd(ptr, true);
 
1660
  }
 
1661
 
 
1662
  if((ptr = xp_get_value((char *)"counter"))) {
 
1663
    message -> counter = get_counter(ptr, "counter");
 
1664
  }
 
1665
}
 
1666
 
 
1667
void scenario::getCommonAttributes(message *message) {
 
1668
  char *ptr;
 
1669
 
 
1670
  getBookKeeping(message);
 
1671
  getActionForThisMessage(message);
 
1672
 
 
1673
  if((ptr = xp_get_value((char *)"lost"))) {
 
1674
    message -> lost = get_double(ptr, "lost percentage");
 
1675
    lose_packets = 1;
 
1676
  }
 
1677
 
 
1678
  if((ptr = xp_get_value((char *)"crlf"))) {
 
1679
    message -> crlf = 1;
 
1680
  }
 
1681
 
 
1682
  if (xp_get_value("hiderest")) {
 
1683
    hidedefault = xp_get_bool("hiderest", "hiderest");
 
1684
  }
 
1685
  message -> hide = xp_get_bool("hide", "hide", hidedefault);
 
1686
  if((ptr = xp_get_value((char *)"display"))) {
 
1687
    message -> display_str = strdup(ptr);
 
1688
  }
 
1689
 
 
1690
  message -> condexec = xp_get_var("condexec", "condexec variable", -1);
 
1691
  message -> condexec_inverse = xp_get_bool("condexec_inverse", "condexec_inverse", false);
 
1692
 
 
1693
  if ((ptr = xp_get_value((char *)"next"))) {
 
1694
    if (found_timewait) {
 
1695
      ERROR("next labels are not allowed in <timewait> elements.");
 
1696
    }
 
1697
    message -> nextLabel = strdup(ptr);
 
1698
    message -> test = xp_get_var("test", "test variable", -1);
 
1699
    if ( 0 != ( ptr = xp_get_value((char *)"chance") ) ) {
 
1700
      float chance = get_double(ptr,"chance");
 
1701
      /* probability of branch to next */
 
1702
      if (( chance < 0.0 ) || (chance > 1.0 )) {
 
1703
        ERROR("Chance %s not in range [0..1]", ptr);
 
1704
      }
 
1705
      message -> chance = (int)((1.0-chance)*RAND_MAX);
 
1706
    }
 
1707
    else {
 
1708
      message -> chance = 0; /* always */
 
1709
    }
 
1710
  }
 
1711
 
 
1712
  if ((ptr = xp_get_value((char *)"ontimeout"))) {
 
1713
    if (found_timewait) {
 
1714
      ERROR("ontimeout labels are not allowed in <timewait> elements.");
 
1715
    }
 
1716
    message -> onTimeoutLabel = strdup(ptr);
 
1717
  }
 
1718
}
 
1719
 
 
1720
// char* manipulation : create a int[] from a char*
 
1721
// test first is the char* is formed by int separeted by coma
 
1722
// and then create the table
 
1723
 
 
1724
int isWellFormed(char * P_listeStr, int * nombre)
 
1725
{
 
1726
  char * ptr = P_listeStr;
 
1727
  int sizeOf;
 
1728
  bool isANumber;
 
1729
 
 
1730
  (*nombre) = 0;
 
1731
  sizeOf = strlen(P_listeStr);
 
1732
  // getting the number 
 
1733
  if(sizeOf > 0)
 
1734
    {
 
1735
      // is the string well formed ? [0-9] [,]
 
1736
      isANumber = false;
 
1737
      for(int i=0; i<=sizeOf; i++)
 
1738
        {
 
1739
          switch(ptr[i])
 
1740
            {
 
1741
            case ',':
 
1742
              if(isANumber == false)
 
1743
                {   
 
1744
                  return(0);
 
1745
                }
 
1746
              else
 
1747
                {
 
1748
                  (*nombre)++;             
 
1749
                } 
 
1750
              isANumber = false;
 
1751
              break;
 
1752
            case '0':
 
1753
            case '1':
 
1754
            case '2':
 
1755
            case '3':
 
1756
            case '4':
 
1757
            case '5':
 
1758
            case '6':
 
1759
            case '7':
 
1760
            case '8':
 
1761
            case '9':
 
1762
              isANumber = true;
 
1763
              break;
 
1764
            case '\t':
 
1765
            case ' ' :
 
1766
              break;
 
1767
            case '\0':
 
1768
              if(isANumber == false)
 
1769
                {   
 
1770
                  return(0);
 
1771
                }
 
1772
              else
 
1773
                {
 
1774
                  (*nombre)++;
 
1775
                } 
 
1776
              break;
 
1777
            default:
 
1778
              return(0);
 
1779
            }
 
1780
        } // end for
 
1781
    }
 
1782
  return(1);
 
1783
}
 
1784
 
 
1785
int createIntegerTable(char * P_listeStr, 
 
1786
                       unsigned int ** listeInteger, 
 
1787
                       int * sizeOfList)
 
1788
{
 
1789
  int nb=0;
 
1790
  char * ptr = P_listeStr;
 
1791
  char * ptr_prev = P_listeStr;
 
1792
  unsigned int current_int;
 
1793
 
 
1794
  if(P_listeStr){ 
 
1795
   if(isWellFormed(P_listeStr, sizeOfList) == 1)
 
1796
     {
 
1797
       (*listeInteger) = new unsigned int[(*sizeOfList)];
 
1798
       while((*ptr) != ('\0'))
 
1799
         {
 
1800
           if((*ptr) == ',')
 
1801
             {
 
1802
               sscanf(ptr_prev, "%u", &current_int);
 
1803
               if (nb<(*sizeOfList))
 
1804
                 (*listeInteger)[nb] = current_int;
 
1805
               nb++;
 
1806
               ptr_prev = ptr+1;
 
1807
             } 
 
1808
           ptr++;
 
1809
         }
 
1810
 
 
1811
       // Read the last
 
1812
       sscanf(ptr_prev, "%u", &current_int); 
 
1813
       if (nb<(*sizeOfList))
 
1814
         (*listeInteger)[nb] = current_int;
 
1815
       nb++;
 
1816
       return(1);
 
1817
     }
 
1818
   return(0);
 
1819
  }else return(0);
 
1820
}
 
1821
 
 
1822
int createStringTable(char * inputString, char *** stringList, int *sizeOfList)
 
1823
{
 
1824
  if(!inputString) {
 
1825
    return 0;
 
1826
  }
 
1827
 
 
1828
  *stringList = NULL;
 
1829
  *sizeOfList = 0;
 
1830
 
 
1831
  do
 
1832
  {
 
1833
    char *p = strchr(inputString, ',');
 
1834
    if (p) {
 
1835
      *p++ = '\0';
 
1836
    }
 
1837
 
 
1838
    *stringList = (char **)realloc(*stringList, sizeof(char *) * (*sizeOfList + 1));
 
1839
    (*stringList)[*sizeOfList] = strdup(inputString);
 
1840
    (*sizeOfList)++;
 
1841
 
 
1842
    inputString = p;
 
1843
  }
 
1844
  while (inputString);
 
1845
 
 
1846
  return 1;
 
1847
}
 
1848
 
 
1849
void freeStringTable(char ** stringList, int sizeOfList) {
 
1850
  for (int i = 0; i < sizeOfList; i++) {
 
1851
    free(stringList[i]);
 
1852
  }
 
1853
  free(stringList);
 
1854
}
 
1855
 
 
1856
/* These are the names of the scenarios, they must match the default_scenario table. */
 
1857
char *scenario_table[] = {
 
1858
        "uac",
 
1859
        "uas",
 
1860
        "regexp",
 
1861
        "3pcc-C-A",
 
1862
        "3pcc-C-B",
 
1863
        "3pcc-A",
 
1864
        "3pcc-B",
 
1865
        "branchc",
 
1866
        "branchs",
 
1867
        "uac_pcap",
 
1868
        "ooc_default",
 
1869
};
 
1870
 
 
1871
int find_scenario(const char *scenario) {
 
1872
  int i, max;
 
1873
  max = sizeof(scenario_table)/sizeof(scenario_table[0]);
 
1874
 
 
1875
  for (i = 0; i < max; i++) {
 
1876
    if (!strcmp(scenario_table[i], scenario)) {
 
1877
        return i;
 
1878
    }
 
1879
  }
 
1880
 
 
1881
  ERROR("Invalid default scenario name '%s'.\n", scenario);
 
1882
  return -1;
 
1883
}
 
1884
 
 
1885
// TIP: to integrate an existing XML scenario, use the following sed line:
 
1886
// cat ../3pcc-controller-B.xml | sed -e 's/\"/\\\"/g' -e 's/\(.*\)/\"\1\\n\"/'
 
1887
char * default_scenario [] = {
 
1888
/************* Default_scenario[0] ***************/
 
1889
(char *)
 
1890
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"
 
1891
"<!DOCTYPE scenario SYSTEM \"sipp.dtd\">\n"
 
1892
"\n"
 
1893
"<!-- This program is free software; you can redistribute it and/or      -->\n"
 
1894
"<!-- modify it under the terms of the GNU General Public License as     -->\n"
 
1895
"<!-- published by the Free Software Foundation; either version 2 of the -->\n"
 
1896
"<!-- License, or (at your option) any later version.                    -->\n"
 
1897
"<!--                                                                    -->\n"
 
1898
"<!-- This program is distributed in the hope that it will be useful,    -->\n"
 
1899
"<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of     -->\n"
 
1900
"<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      -->\n"
 
1901
"<!-- GNU General Public License for more details.                       -->\n"
 
1902
"<!--                                                                    -->\n"
 
1903
"<!-- You should have received a copy of the GNU General Public License  -->\n"
 
1904
"<!-- along with this program; if not, write to the                      -->\n"
 
1905
"<!-- Free Software Foundation, Inc.,                                    -->\n"
 
1906
"<!-- 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA             -->\n"
 
1907
"<!--                                                                    -->\n"
 
1908
"<!--                 Sipp default 'uac' scenario.                       -->\n"
 
1909
"<!--                                                                    -->\n"
 
1910
"\n"
 
1911
"<scenario name=\"Basic Sipstone UAC\">\n"
 
1912
"  <!-- In client mode (sipp placing calls), the Call-ID MUST be         -->\n"
 
1913
"  <!-- generated by sipp. To do so, use [call_id] keyword.                -->\n"
 
1914
"  <send retrans=\"500\">\n"
 
1915
"    <![CDATA[\n"
 
1916
"\n"
 
1917
"      INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0\n"
 
1918
"      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]\n"
 
1919
"      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]\n"
 
1920
"      To: sut <sip:[service]@[remote_ip]:[remote_port]>\n"
 
1921
"      Call-ID: [call_id]\n"
 
1922
"      CSeq: 1 INVITE\n"
 
1923
"      Contact: sip:sipp@[local_ip]:[local_port]\n"
 
1924
"      Max-Forwards: 70\n"
 
1925
"      Subject: Performance Test\n"
 
1926
"      Content-Type: application/sdp\n"
 
1927
"      Content-Length: [len]\n"
 
1928
"\n"
 
1929
"      v=0\n"
 
1930
"      o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]\n"
 
1931
"      s=-\n"
 
1932
"      c=IN IP[media_ip_type] [media_ip]\n"
 
1933
"      t=0 0\n"
 
1934
"      m=audio [media_port] RTP/AVP 0\n"
 
1935
"      a=rtpmap:0 PCMU/8000\n"
 
1936
"\n"
 
1937
"    ]]>\n"
 
1938
"  </send>\n"
 
1939
"\n"
 
1940
"  <recv response=\"100\"\n"
 
1941
"        optional=\"true\">\n"
 
1942
"  </recv>\n"
 
1943
"\n"
 
1944
"  <recv response=\"180\" optional=\"true\">\n"
 
1945
"  </recv>\n"
 
1946
"\n"
 
1947
"  <recv response=\"183\" optional=\"true\">\n"
 
1948
"  </recv>\n"
 
1949
"\n"
 
1950
"  <!-- By adding rrs=\"true\" (Record Route Sets), the route sets         -->\n"
 
1951
"  <!-- are saved and used for following messages sent. Useful to test   -->\n"
 
1952
"  <!-- against stateful SIP proxies/B2BUAs.                             -->\n"
 
1953
"  <recv response=\"200\" rtd=\"true\">\n"
 
1954
"  </recv>\n"
 
1955
"\n"
 
1956
"  <!-- Packet lost can be simulated in any send/recv message by         -->\n"
 
1957
"  <!-- by adding the 'lost = \"10\"'. Value can be [1-100] percent.       -->\n"
 
1958
"  <send>\n"
 
1959
"    <![CDATA[\n"
 
1960
"\n"
 
1961
"      ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0\n"
 
1962
"      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]\n"
 
1963
"      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]\n"
 
1964
"      To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]\n"
 
1965
"      Call-ID: [call_id]\n"
 
1966
"      CSeq: 1 ACK\n"
 
1967
"      Contact: sip:sipp@[local_ip]:[local_port]\n"
 
1968
"      Max-Forwards: 70\n"
 
1969
"      Subject: Performance Test\n"
 
1970
"      Content-Length: 0\n"
 
1971
"\n"
 
1972
"    ]]>\n"
 
1973
"  </send>\n"
 
1974
"\n"
 
1975
"  <!-- This delay can be customized by the -d command-line option       -->\n"
 
1976
"  <!-- or by adding a 'milliseconds = \"value\"' option here.             -->\n"
 
1977
"  <pause/>\n"
 
1978
"\n"
 
1979
"  <!-- The 'crlf' option inserts a blank line in the statistics report. -->\n"
 
1980
"  <send retrans=\"500\">\n"
 
1981
"    <![CDATA[\n"
 
1982
"\n"
 
1983
"      BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0\n"
 
1984
"      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]\n"
 
1985
"      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]\n"
 
1986
"      To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]\n"
 
1987
"      Call-ID: [call_id]\n"
 
1988
"      CSeq: 2 BYE\n"
 
1989
"      Contact: sip:sipp@[local_ip]:[local_port]\n"
 
1990
"      Max-Forwards: 70\n"
 
1991
"      Subject: Performance Test\n"
 
1992
"      Content-Length: 0\n"
 
1993
"\n"
 
1994
"    ]]>\n"
 
1995
"  </send>\n"
 
1996
"\n"
 
1997
"  <recv response=\"200\" crlf=\"true\">\n"
 
1998
"  </recv>\n"
 
1999
"\n"
 
2000
"  <!-- definition of the response time repartition table (unit is ms)   -->\n"
 
2001
"  <ResponseTimeRepartition value=\"10, 20, 30, 40, 50, 100, 150, 200\"/>\n"
 
2002
"\n"
 
2003
"  <!-- definition of the call length repartition table (unit is ms)     -->\n"
 
2004
"  <CallLengthRepartition value=\"10, 50, 100, 500, 1000, 5000, 10000\"/>\n"
 
2005
"\n"
 
2006
"</scenario>\n"
 
2007
"\n"
 
2008
 
2009
 
 
2010
/************* Default_scenario[1] ***************/
 
2011
(char *)
 
2012
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"
 
2013
"<!DOCTYPE scenario SYSTEM \"sipp.dtd\">\n"
 
2014
"\n"
 
2015
"<!-- This program is free software; you can redistribute it and/or      -->\n"
 
2016
"<!-- modify it under the terms of the GNU General Public License as     -->\n"
 
2017
"<!-- published by the Free Software Foundation; either version 2 of the -->\n"
 
2018
"<!-- License, or (at your option) any later version.                    -->\n"
 
2019
"<!--                                                                    -->\n"
 
2020
"<!-- This program is distributed in the hope that it will be useful,    -->\n"
 
2021
"<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of     -->\n"
 
2022
"<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      -->\n"
 
2023
"<!-- GNU General Public License for more details.                       -->\n"
 
2024
"<!--                                                                    -->\n"
 
2025
"<!-- You should have received a copy of the GNU General Public License  -->\n"
 
2026
"<!-- along with this program; if not, write to the                      -->\n"
 
2027
"<!-- Free Software Foundation, Inc.,                                    -->\n"
 
2028
"<!-- 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA             -->\n"
 
2029
"<!--                                                                    -->\n"
 
2030
"<!--                 Sipp default 'uas' scenario.                       -->\n"
 
2031
"<!--                                                                    -->\n"
 
2032
"\n"
 
2033
"<scenario name=\"Basic UAS responder\">\n"
 
2034
"  <!-- By adding rrs=\"true\" (Record Route Sets), the route sets         -->\n"
 
2035
"  <!-- are saved and used for following messages sent. Useful to test   -->\n"
 
2036
"  <!-- against stateful SIP proxies/B2BUAs.                             -->\n"
 
2037
"  <recv request=\"INVITE\" crlf=\"true\">\n"
 
2038
"  </recv>\n"
 
2039
"\n"
 
2040
"  <!-- The '[last_*]' keyword is replaced automatically by the          -->\n"
 
2041
"  <!-- specified header if it was present in the last message received  -->\n"
 
2042
"  <!-- (except if it was a retransmission). If the header was not       -->\n"
 
2043
"  <!-- present or if no message has been received, the '[last_*]'       -->\n"
 
2044
"  <!-- keyword is discarded, and all bytes until the end of the line    -->\n"
 
2045
"  <!-- are also discarded.                                              -->\n"
 
2046
"  <!--                                                                  -->\n"
 
2047
"  <!-- If the specified header was present several times in the         -->\n"
 
2048
"  <!-- message, all occurences are concatenated (CRLF seperated)        -->\n"
 
2049
"  <!-- to be used in place of the '[last_*]' keyword.                   -->\n"
 
2050
"\n"
 
2051
"  <send>\n"
 
2052
"    <![CDATA[\n"
 
2053
"\n"
 
2054
"      SIP/2.0 180 Ringing\n"
 
2055
"      [last_Via:]\n"
 
2056
"      [last_From:]\n"
 
2057
"      [last_To:];tag=[pid]SIPpTag01[call_number]\n"
 
2058
"      [last_Call-ID:]\n"
 
2059
"      [last_CSeq:]\n"
 
2060
"      Contact: <sip:[local_ip]:[local_port];transport=[transport]>\n"
 
2061
"      Content-Length: 0\n"
 
2062
"\n"
 
2063
"    ]]>\n"
 
2064
"  </send>\n"
 
2065
"\n"
 
2066
"  <send retrans=\"500\">\n"
 
2067
"    <![CDATA[\n"
 
2068
"\n"
 
2069
"      SIP/2.0 200 OK\n"
 
2070
"      [last_Via:]\n"
 
2071
"      [last_From:]\n"
 
2072
"      [last_To:];tag=[pid]SIPpTag01[call_number]\n"
 
2073
"      [last_Call-ID:]\n"
 
2074
"      [last_CSeq:]\n"
 
2075
"      Contact: <sip:[local_ip]:[local_port];transport=[transport]>\n"
 
2076
"      Content-Type: application/sdp\n"
 
2077
"      Content-Length: [len]\n"
 
2078
"\n"
 
2079
"      v=0\n"
 
2080
"      o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]\n"
 
2081
"      s=-\n"
 
2082
"      c=IN IP[media_ip_type] [media_ip]\n"
 
2083
"      t=0 0\n"
 
2084
"      m=audio [media_port] RTP/AVP 0\n"
 
2085
"      a=rtpmap:0 PCMU/8000\n"
 
2086
"\n"
 
2087
"    ]]>\n"
 
2088
"  </send>\n"
 
2089
"\n"
 
2090
"  <recv request=\"ACK\"\n"
 
2091
"        optional=\"true\"\n"
 
2092
"        rtd=\"true\"\n"
 
2093
"        crlf=\"true\">\n"
 
2094
"  </recv>\n"
 
2095
"\n"
 
2096
"  <recv request=\"BYE\">\n"
 
2097
"  </recv>\n"
 
2098
"\n"
 
2099
"  <send>\n"
 
2100
"    <![CDATA[\n"
 
2101
"\n"
 
2102
"      SIP/2.0 200 OK\n"
 
2103
"      [last_Via:]\n"
 
2104
"      [last_From:]\n"
 
2105
"      [last_To:]\n"
 
2106
"      [last_Call-ID:]\n"
 
2107
"      [last_CSeq:]\n"
 
2108
"      Contact: <sip:[local_ip]:[local_port];transport=[transport]>\n"
 
2109
"      Content-Length: 0\n"
 
2110
"\n"
 
2111
"    ]]>\n"
 
2112
"  </send>\n"
 
2113
"\n"
 
2114
"  <!-- Keep the call open for a while in case the 200 is lost to be     -->\n"
 
2115
"  <!-- able to retransmit it if we receive the BYE again.               -->\n"
 
2116
"  <timewait milliseconds=\"4000\"/>\n"
 
2117
"\n"
 
2118
"\n"
 
2119
"  <!-- definition of the response time repartition table (unit is ms)   -->\n"
 
2120
"  <ResponseTimeRepartition value=\"10, 20, 30, 40, 50, 100, 150, 200\"/>\n"
 
2121
"\n"
 
2122
"  <!-- definition of the call length repartition table (unit is ms)     -->\n"
 
2123
"  <CallLengthRepartition value=\"10, 50, 100, 500, 1000, 5000, 10000\"/>\n"
 
2124
"\n"
 
2125
"</scenario>\n"
 
2126
"\n",
 
2127
 
 
2128
/************* Default_scenario[2] ***************/
 
2129
(char *)
 
2130
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"
 
2131
"<!DOCTYPE scenario SYSTEM \"sipp.dtd\">\n"
 
2132
"\n"
 
2133
"<!-- This program is free software; you can redistribute it and/or      -->\n"
 
2134
"<!-- modify it under the terms of the GNU General Public License as     -->\n"
 
2135
"<!-- published by the Free Software Foundation; either version 2 of the -->\n"
 
2136
"<!-- License, or (at your option) any later version.                    -->\n"
 
2137
"<!--                                                                    -->\n"
 
2138
"<!-- This program is distributed in the hope that it will be useful,    -->\n"
 
2139
"<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of     -->\n"
 
2140
"<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      -->\n"
 
2141
"<!-- GNU General Public License for more details.                       -->\n"
 
2142
"<!--                                                                    -->\n"
 
2143
"<!-- You should have received a copy of the GNU General Public License  -->\n"
 
2144
"<!-- along with this program; if not, write to the                      -->\n"
 
2145
"<!-- Free Software Foundation, Inc.,                                    -->\n"
 
2146
"<!-- 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA             -->\n"
 
2147
"<!--                                                                    -->\n"
 
2148
"<!--                 Sipp default 'regexp client' scenario.             -->\n"
 
2149
"<!--                                                                    -->\n"
 
2150
"\n"
 
2151
"<scenario name=\"Client with regexp scenario\">\n"
 
2152
"  <send retrans=\"500\">\n"
 
2153
"    <![CDATA[\n"
 
2154
"\n"
 
2155
"      INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0\n"
 
2156
"      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]\n"
 
2157
"      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag02[call_number]\n"
 
2158
"      To: sut <sip:[service]@[remote_ip]:[remote_port]>\n"
 
2159
"      Call-ID: [call_id]\n"
 
2160
"      CSeq: 1 INVITE\n"
 
2161
"      Contact: sip:sipp@[local_ip]:[local_port]\n"
 
2162
"      Max-Forwards: 70\n"
 
2163
"      Subject: Performance Test\n"
 
2164
"      Content-Type: application/sdp\n"
 
2165
"      Content-Length: [len]\n"
 
2166
"\n"
 
2167
"      v=0\n"
 
2168
"      o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]\n"
 
2169
"      s=-\n"
 
2170
"      c=IN IP[media_ip_type] [media_ip]\n"
 
2171
"      t=0 0\n"
 
2172
"      m=audio [media_port] RTP/AVP 0\n"
 
2173
"      a=rtpmap:0 PCMU/8000\n"
 
2174
"\n"
 
2175
"    ]]>\n"
 
2176
"  </send>\n"
 
2177
"\n"
 
2178
"  <recv response=\"100\"\n"
 
2179
"        optional=\"true\">\n"
 
2180
"  </recv>\n"
 
2181
"\n"
 
2182
"  <recv response=\"180\" optional=\"true\">\n"
 
2183
"  </recv>\n"
 
2184
"  <recv response=\"183\" optional=\"true\">\n"
 
2185
"  </recv>\n"
 
2186
"\n"
 
2187
"  <recv response=\"200\" start_rtd=\"true\">\n"
 
2188
"    <!-- Definition of regexp in the action tag. The regexp must follow -->\n"
 
2189
"    <!-- the Posix Extended standard (POSIX 1003.2), see:               -->\n"
 
2190
"    <!--                                                                -->\n"
 
2191
"    <!--   http://www.opengroup.org/onlinepubs/007908799/xbd/re.html    -->\n"
 
2192
"    <!--                                                                -->\n"
 
2193
"    <!-- regexp    : Contain the regexp to use for matching the         -->\n"
 
2194
"    <!--             received message                                   -->\n"
 
2195
"    <!--             MANDATORY                                          -->\n"
 
2196
"    <!-- search_in : msg (try to match against the entire message)      -->\n"
 
2197
"    <!--           : hdr (try to match against a specific SIP header    -->\n"
 
2198
"    <!--             (passed in the header tag)                         -->\n"
 
2199
"    <!--             OPTIONAL - default value : msg                     -->\n"
 
2200
"    <!-- header    : Header to try to match against.                    -->\n"
 
2201
"    <!--             Only used when the search_in tag is set to hdr     -->\n"
 
2202
"    <!--             MANDATORY IF search_in is equal to hdr             -->\n"
 
2203
"    <!-- check_it  : if set to true, the call is marked as failed if    -->\n"
 
2204
"    <!--             the regexp doesn't match.                          -->\n"
 
2205
"    <!--             OPTIONAL - default value : false                   -->\n"
 
2206
"    <!-- assign_to : contain the variable id (integer) or a list of     -->\n"
 
2207
"    <!--             variable id which will be used to store the        -->\n"
 
2208
"    <!--             result of the matching process between the regexp  -->\n"
 
2209
"    <!--             and the message. This variable can be re-used at   -->\n"
 
2210
"    <!--             a later time in the scenario using '[$n]' syntax   -->\n"
 
2211
"    <!--             where n is the variable id.                        -->\n"
 
2212
"    <!--             MANDATORY                                          -->\n"
 
2213
"    <action>\n"
 
2214
"      <ereg regexp=\"[0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}[:][0-9]{1,5}\" \n"
 
2215
"            search_in=\"msg\" \n"
 
2216
"            check_it=\"true\" \n"
 
2217
"            assign_to=\"1\"/>\n"
 
2218
"      <ereg regexp=\".*\" \n"
 
2219
"            search_in=\"hdr\" \n"
 
2220
"            header=\"Contact:\" \n"
 
2221
"            check_it=\"true\" \n"
 
2222
"            assign_to=\"6\"/>\n"
 
2223
"      <ereg regexp=\"o=([[:alnum:]]*) ([[:alnum:]]*) ([[:alnum:]]*)\"\n"
 
2224
"            search_in=\"msg\" \n"
 
2225
"            check_it=\"true\" \n"
 
2226
"            assign_to=\"3,4,5,8\"/>\n"
 
2227
"    </action>\n"
 
2228
"  </recv>\n"
 
2229
"\n"
 
2230
"  <send>\n"
 
2231
"    <![CDATA[\n"
 
2232
"      ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0\n"
 
2233
"      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]\n"
 
2234
"      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag02[call_number]\n"
 
2235
"      To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]\n"
 
2236
"      Call-ID: [call_id]\n"
 
2237
"      CSeq: 1 ACK\n"
 
2238
"      retrievedIp: [$1]\n"
 
2239
"      retrievedContact:[$6]\n"
 
2240
"      retrievedSdpOrigin:[$3]\n"
 
2241
"      retrievedSdpOrigin-username:[$4]\n"
 
2242
"      retrievedSdpOrigin-session-id:[$5]\n"
 
2243
"      retrievedSdpOrigin-version:[$8]\n"
 
2244
"      Contact: sip:sipp@[local_ip]:[local_port]\n"
 
2245
"      Max-Forwards: 70\n"
 
2246
"      Subject: Performance Test\n"
 
2247
"      Content-Length: 0\n"
 
2248
"    ]]>\n"
 
2249
"  </send>\n"
 
2250
"\n"
 
2251
"  <!-- This delay can be customized by the -d command-line option       -->\n"
 
2252
"  <!-- or by adding a 'milliseconds = \"value\"' option here.           -->\n"
 
2253
"  <pause milliseconds = \"1000\"/>\n"
 
2254
"\n"
 
2255
"  <!-- The 'crlf' option inserts a blank line in the statistics report. -->\n"
 
2256
"  <send retrans=\"500\">\n"
 
2257
"    <![CDATA[\n"
 
2258
"\n"
 
2259
"      BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0\n"
 
2260
"      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]\n"
 
2261
"      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag02[call_number]\n"
 
2262
"      To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]\n"
 
2263
"      Call-ID: [call_id]\n"
 
2264
"      CSeq: 2 BYE\n"
 
2265
"      Contact: sip:sipp@[local_ip]:[local_port]\n"
 
2266
"      Max-Forwards: 70\n"
 
2267
"      Subject: Performance Test\n"
 
2268
"      Content-Length: 0\n"
 
2269
"\n"
 
2270
"    ]]>\n"
 
2271
"  </send>\n"
 
2272
"\n"
 
2273
"  <recv response=\"200\" crlf=\"true\" rtd=\"true\">\n"
 
2274
"  </recv>\n"
 
2275
"\n"
 
2276
"  <!-- definition of the response time repartition table (unit is ms)   -->\n"
 
2277
"  <ResponseTimeRepartition value=\"1000, 1040, 1080, 1120, 1160, 1200\"/>\n"
 
2278
"\n"
 
2279
"  <!-- definition of the call length repartition table (unit is ms)     -->\n"
 
2280
"  <CallLengthRepartition value=\"1000, 1100, 1200, 1300, 1400\"/>\n"
 
2281
"\n"
 
2282
"</scenario>\n"
 
2283
"\n",
 
2284
 
 
2285
/************* Default_scenario[3] ***************/
 
2286
(char*)
 
2287
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"
 
2288
"<!DOCTYPE scenario SYSTEM \"sipp.dtd\">\n"
 
2289
"\n"
 
2290
"<!-- This program is free software; you can redistribute it and/or      -->\n"
 
2291
"<!-- modify it under the terms of the GNU General Public License as     -->\n"
 
2292
"<!-- published by the Free Software Foundation; either version 2 of the -->\n"
 
2293
"<!-- License, or (at your option) any later version.                    -->\n"
 
2294
"<!--                                                                    -->\n"
 
2295
"<!-- This program is distributed in the hope that it will be useful,    -->\n"
 
2296
"<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of     -->\n"
 
2297
"<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      -->\n"
 
2298
"<!-- GNU General Public License for more details.                       -->\n"
 
2299
"<!--                                                                    -->\n"
 
2300
"<!-- You should have received a copy of the GNU General Public License  -->\n"
 
2301
"<!-- along with this program; if not, write to the                      -->\n"
 
2302
"<!-- Free Software Foundation, Inc.,                                    -->\n"
 
2303
"<!-- 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA             -->\n"
 
2304
"<!--                                                                    -->\n"
 
2305
"<!--                 3PCC - Controller - A side                         -->\n"
 
2306
"<!--                                                                    -->\n"
 
2307
"<!--             A              Controller               B              -->\n"
 
2308
"<!--             |(1) INVITE no SDP  |                   |              -->\n"
 
2309
"<!--             |<==================|                   |              -->\n"
 
2310
"<!--             |(2) 200 offer1     |                   |              -->\n"
 
2311
"<!--             |==================>|                   |              -->\n"
 
2312
"<!--             |                   |(3) INVITE offer1  |              -->\n"
 
2313
"<!--             |                   |==================>|              -->\n"
 
2314
"<!--             |                   |(4) 200 OK answer1 |              -->\n"
 
2315
"<!--             |                   |<==================|              -->\n"
 
2316
"<!--             |                   |(5) ACK            |              -->\n"
 
2317
"<!--             |                   |==================>|              -->\n"
 
2318
"<!--             |(6) ACK answer1    |                   |              -->\n"
 
2319
"<!--             |<==================|                   |              -->\n"
 
2320
"<!--             |(7) RTP            |                   |              -->\n"
 
2321
"<!--             |.......................................|              -->\n"
 
2322
"<!--                                                                    -->\n"
 
2323
"\n"
 
2324
"<scenario name=\"3PCC Controller - A side\">\n"
 
2325
"  <send retrans=\"500\">\n"
 
2326
"    <![CDATA[\n"
 
2327
"\n"
 
2328
"      INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0\n"
 
2329
"      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]\n"
 
2330
"      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag03[call_number]\n"
 
2331
"      To: sut <sip:[service]@[remote_ip]:[remote_port]>\n"
 
2332
"      Call-ID: [call_id]\n"
 
2333
"      CSeq: 1 INVITE\n"
 
2334
"      Contact: sip:sipp@[local_ip]:[local_port]\n"
 
2335
"      Max-Forwards: 70\n"
 
2336
"      Subject: Performance Test\n"
 
2337
"      Content-Length: 0\n"
 
2338
"\n"
 
2339
"    ]]>\n"
 
2340
"  </send>\n"
 
2341
"\n"
 
2342
"  <recv response=\"100\" optional=\"true\"> </recv>\n"
 
2343
"  <recv response=\"180\" optional=\"true\"> </recv>\n"
 
2344
"  <recv response=\"183\" optional=\"true\"> </recv>\n"
 
2345
"  <recv response=\"200\" crlf=\"true\" start_rtd=\"true\">\n"
 
2346
"    <action>\n"
 
2347
"       <ereg regexp=\"Content-Type:.*\" \n"
 
2348
"             search_in=\"msg\"  \n"
 
2349
"             assign_to=\"1\" /> \n"
 
2350
"    </action>\n"
 
2351
"  </recv>\n"
 
2352
"\n"
 
2353
"  <sendCmd>\n"
 
2354
"    <![CDATA[\n"
 
2355
"      Call-ID: [call_id]\n"
 
2356
"      [$1]\n"
 
2357
"\n"
 
2358
"     ]]>\n"
 
2359
"  </sendCmd>\n"
 
2360
"  \n"
 
2361
"  <recvCmd>\n"
 
2362
"    <action>\n"
 
2363
"       <ereg regexp=\"Content-Type:.*\"  \n"
 
2364
"             search_in=\"msg\"  \n"
 
2365
"             assign_to=\"2\" /> \n"
 
2366
"    </action>\n"
 
2367
"  \n"
 
2368
"  </recvCmd>\n"
 
2369
"  \n"
 
2370
"  <send rtd=\"true\">\n"
 
2371
"    <![CDATA[\n"
 
2372
"\n"
 
2373
"      ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0\n"
 
2374
"      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]\n"
 
2375
"      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag03[call_number]\n"
 
2376
"      To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]\n"
 
2377
"      Call-ID: [call_id]\n"
 
2378
"      CSeq: 1 ACK\n"
 
2379
"      Contact: sip:sipp@[local_ip]:[local_port]\n"
 
2380
"      Max-Forwards: 70\n"
 
2381
"      Subject: Performance Test\n"
 
2382
"      [$2]\n"
 
2383
"\n"
 
2384
"    ]]>\n"
 
2385
"  </send>\n"
 
2386
"\n"
 
2387
"  <pause milliseconds=\"1000\"/>\n"
 
2388
"\n"
 
2389
"  <!-- The 'crlf' option inserts a blank line in the statistics report. -->\n"
 
2390
"  <send retrans=\"500\">\n"
 
2391
"    <![CDATA[\n"
 
2392
"\n"
 
2393
"      BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0\n"
 
2394
"      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]\n"
 
2395
"      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag03[call_number]\n"
 
2396
"      To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]\n"
 
2397
"      Call-ID: [call_id]\n"
 
2398
"      CSeq: 2 BYE\n"
 
2399
"      Contact: sip:sipp@[local_ip]:[local_port]\n"
 
2400
"      Max-Forwards: 70\n"
 
2401
"      Subject: Performance Test\n"
 
2402
"      Content-Length: 0\n"
 
2403
"\n"
 
2404
"    ]]>\n"
 
2405
"  </send>\n"
 
2406
"\n"
 
2407
"  <recv response=\"200\" crlf=\"true\"> </recv>\n"
 
2408
"\n"
 
2409
"</scenario>\n"
 
2410
"\n",
 
2411
 
 
2412
/************* Default_scenario[4] ***************/
 
2413
(char*) 
 
2414
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"
 
2415
"<!DOCTYPE scenario SYSTEM \"sipp.dtd\">\n"
 
2416
"\n"
 
2417
"<!-- This program is free software; you can redistribute it and/or      -->\n"
 
2418
"<!-- modify it under the terms of the GNU General Public License as     -->\n"
 
2419
"<!-- published by the Free Software Foundation; either version 2 of the -->\n"
 
2420
"<!-- License, or (at your option) any later version.                    -->\n"
 
2421
"<!--                                                                    -->\n"
 
2422
"<!-- This program is distributed in the hope that it will be useful,    -->\n"
 
2423
"<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of     -->\n"
 
2424
"<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      -->\n"
 
2425
"<!-- GNU General Public License for more details.                       -->\n"
 
2426
"<!--                                                                    -->\n"
 
2427
"<!-- You should have received a copy of the GNU General Public License  -->\n"
 
2428
"<!-- along with this program; if not, write to the                      -->\n"
 
2429
"<!-- Free Software Foundation, Inc.,                                    -->\n"
 
2430
"<!-- 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA             -->\n"
 
2431
"<!--                                                                    -->\n"
 
2432
"<!--                 3PCC - Controller - B side                         -->\n"
 
2433
"<!--                                                                    -->\n"
 
2434
"<!--             A              Controller               B              -->\n"
 
2435
"<!--             |(1) INVITE no SDP  |                   |              -->\n"
 
2436
"<!--             |<==================|                   |              -->\n"
 
2437
"<!--             |(2) 200 offer1     |                   |              -->\n"
 
2438
"<!--             |==================>|                   |              -->\n"
 
2439
"<!--             |                   |(3) INVITE offer1  |              -->\n"
 
2440
"<!--             |                   |==================>|              -->\n"
 
2441
"<!--             |                   |(4) 200 OK answer1 |              -->\n"
 
2442
"<!--             |                   |<==================|              -->\n"
 
2443
"<!--             |                   |(5) ACK            |              -->\n"
 
2444
"<!--             |                   |==================>|              -->\n"
 
2445
"<!--             |(6) ACK answer1    |                   |              -->\n"
 
2446
"<!--             |<==================|                   |              -->\n"
 
2447
"<!--             |(7) RTP            |                   |              -->\n"
 
2448
"<!--             |.......................................|              -->\n"
 
2449
"<!--                                                                    -->\n"
 
2450
"\n"
 
2451
"\n"
 
2452
"<scenario name=\"3PCC Controller - B side\">\n"
 
2453
"\n"
 
2454
"<recvCmd>\n"
 
2455
"  <action>\n"
 
2456
"       <ereg regexp=\"Content-Type:.*\"  \n"
 
2457
"             search_in=\"msg\"  \n"
 
2458
"             assign_to=\"1\" /> \n"
 
2459
"  </action>\n"
 
2460
"</recvCmd>\n"
 
2461
"\n"
 
2462
"  <send retrans=\"500\">\n"
 
2463
"    <![CDATA[\n"
 
2464
"\n"
 
2465
"      INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0\n"
 
2466
"      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]\n"
 
2467
"      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag04[call_number]\n"
 
2468
"      To: sut <sip:[service]@[remote_ip]:[remote_port]>\n"
 
2469
"      Call-ID: [call_id]\n"
 
2470
"      CSeq: 1 INVITE\n"
 
2471
"      Contact: sip:sipp@[local_ip]:[local_port]\n"
 
2472
"      Max-Forwards: 70\n"
 
2473
"      Subject: Performance Test\n"
 
2474
"      [$1]\n"
 
2475
"\n"
 
2476
"     ]]>\n"
 
2477
"  </send>\n"
 
2478
"\n"
 
2479
"  <recv response=\"100\" optional=\"true\"> </recv>\n"
 
2480
"  <recv response=\"180\" optional=\"true\"> </recv>\n"
 
2481
"  <recv response=\"183\" optional=\"true\"> </recv>\n"
 
2482
"  <recv response=\"200\" crlf=\"true\">\n"
 
2483
"    <action>\n"
 
2484
"       <ereg regexp=\"Content-Type:.*\"  \n"
 
2485
"             search_in=\"msg\"  \n"
 
2486
"             assign_to=\"2\" /> \n"
 
2487
"    </action>\n"
 
2488
"  </recv>\n"
 
2489
"  \n"
 
2490
"    \n"
 
2491
"  <send start_rtd=\"true\">\n"
 
2492
"    <![CDATA[\n"
 
2493
"\n"
 
2494
"      ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0\n"
 
2495
"      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]\n"
 
2496
"      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag04[call_number]\n"
 
2497
"      To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]\n"
 
2498
"      Call-ID: [call_id]\n"
 
2499
"      CSeq: 1 ACK\n"
 
2500
"      Contact: sip:sipp@[local_ip]:[local_port]\n"
 
2501
"      Max-Forwards: 70\n"
 
2502
"      Subject: Performance Test\n"
 
2503
"      Content-Length: 0\n"
 
2504
"\n"
 
2505
"    ]]>\n"
 
2506
"  </send>\n"
 
2507
"\n"
 
2508
"  <sendCmd>\n"
 
2509
"    <![CDATA[\n"
 
2510
"      Call-ID: [call_id]\n"
 
2511
"      [$2]\n"
 
2512
"\n"
 
2513
"    ]]>\n"
 
2514
"  </sendCmd>\n"
 
2515
" \n"
 
2516
"  <pause milliseconds=\"1000\"/>\n"
 
2517
"\n"
 
2518
"\n"
 
2519
"  <!-- The 'crlf' option inserts a blank line in the statistics report. -->\n"
 
2520
"  <send retrans=\"500\" rtd=\"true\">\n"
 
2521
"    <![CDATA[\n"
 
2522
"\n"
 
2523
"      BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0\n"
 
2524
"      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]\n"
 
2525
"      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag04[call_number]\n"
 
2526
"      To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]\n"
 
2527
"      Call-ID: [call_id]\n"
 
2528
"      CSeq: 2 BYE\n"
 
2529
"      Contact: sip:sipp@[local_ip]:[local_port]\n"
 
2530
"      Max-Forwards: 70\n"
 
2531
"      Subject: Performance Test\n"
 
2532
"      Content-Length: 0\n"
 
2533
"\n"
 
2534
"    ]]>\n"
 
2535
"  </send>\n"
 
2536
"\n"
 
2537
"  <recv response=\"200\" crlf=\"true\">\n"
 
2538
"  </recv>\n"
 
2539
"\n"
 
2540
"\n"
 
2541
"</scenario>\n"
 
2542
"\n",
 
2543
 
 
2544
/************* Default_scenario[5] ***************/
 
2545
(char*) 
 
2546
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"
 
2547
"<!DOCTYPE scenario SYSTEM \"sipp.dtd\">\n"
 
2548
"\n"
 
2549
"<!-- This program is free software; you can redistribute it and/or      -->\n"
 
2550
"<!-- modify it under the terms of the GNU General Public License as     -->\n"
 
2551
"<!-- published by the Free Software Foundation; either version 2 of the -->\n"
 
2552
"<!-- License, or (at your option) any later version.                    -->\n"
 
2553
"<!--                                                                    -->\n"
 
2554
"<!-- This program is distributed in the hope that it will be useful,    -->\n"
 
2555
"<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of     -->\n"
 
2556
"<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      -->\n"
 
2557
"<!-- GNU General Public License for more details.                       -->\n"
 
2558
"<!--                                                                    -->\n"
 
2559
"<!-- You should have received a copy of the GNU General Public License  -->\n"
 
2560
"<!-- along with this program; if not, write to the                      -->\n"
 
2561
"<!-- Free Software Foundation, Inc.,                                    -->\n"
 
2562
"<!-- 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA             -->\n"
 
2563
"<!--                                                                    -->\n"
 
2564
"<!--                 3PCC - A side emulator                             -->\n"
 
2565
"<!--                                                                    -->\n"
 
2566
"<!--             A              Controller               B              -->\n"
 
2567
"<!--             |(1) INVITE no SDP  |                   |              -->\n"
 
2568
"<!--             |<==================|                   |              -->\n"
 
2569
"<!--             |(2) 200 offer1     |                   |              -->\n"
 
2570
"<!--             |==================>|                   |              -->\n"
 
2571
"<!--             |                   |(3) INVITE offer1  |              -->\n"
 
2572
"<!--             |                   |==================>|              -->\n"
 
2573
"<!--             |                   |(4) 200 OK answer1 |              -->\n"
 
2574
"<!--             |                   |<==================|              -->\n"
 
2575
"<!--             |                   |(5) ACK            |              -->\n"
 
2576
"<!--             |                   |==================>|              -->\n"
 
2577
"<!--             |(6) ACK answer1    |                   |              -->\n"
 
2578
"<!--             |<==================|                   |              -->\n"
 
2579
"<!--             |(7) RTP            |                   |              -->\n"
 
2580
"<!--             |.......................................|              -->\n"
 
2581
"<!--                                                                    -->\n"
 
2582
"\n"
 
2583
"\n"
 
2584
"<scenario name=\"3PCC A side\">\n"
 
2585
"  <recv request=\"INVITE\" crlf=\"true\">\n"
 
2586
"  </recv>\n"
 
2587
"\n"
 
2588
"  <send>\n"
 
2589
"    <![CDATA[\n"
 
2590
"\n"
 
2591
"      SIP/2.0 200 OK\n"
 
2592
"      [last_Via:]\n"
 
2593
"      [last_From:]\n"
 
2594
"      [last_To:];tag=[pid]SIPpTag05[call_number]\n"
 
2595
"      [last_Call-ID:]\n"
 
2596
"      [last_CSeq:]\n"
 
2597
"      Contact: <sip:[local_ip]:[local_port];transport=[transport]>\n"
 
2598
"      Content-Type: application/sdp\n"
 
2599
"      Content-Length: [len]\n"
 
2600
"\n"
 
2601
"      v=0\n"
 
2602
"      o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]\n"
 
2603
"      s=-\n"
 
2604
"      c=IN IP[media_ip_type] [media_ip]\n"
 
2605
"      t=0 0\n"
 
2606
"      m=audio [media_port] RTP/AVP 0\n"
 
2607
"      a=rtpmap:0 PCMU/8000\n"
 
2608
"\n"
 
2609
"    ]]>\n"
 
2610
"  </send>\n"
 
2611
"\n"
 
2612
"  <recv request=\"ACK\" rtd=\"true\" crlf=\"true\"> </recv>\n"
 
2613
"\n"
 
2614
"  <!-- RTP flow starts from here! -->\n"
 
2615
"\n"
 
2616
"  <recv request=\"BYE\" crlf=\"true\"> </recv>\n"
 
2617
"\n"
 
2618
"  <send>\n"
 
2619
"    <![CDATA[\n"
 
2620
"\n"
 
2621
"      SIP/2.0 200 OK\n"
 
2622
"      [last_Via:]\n"
 
2623
"      [last_From:]\n"
 
2624
"      [last_To:]\n"
 
2625
"      [last_Call-ID:]\n"
 
2626
"      [last_CSeq:]\n"
 
2627
"      Contact: <sip:[local_ip]:[local_port];transport=[transport]>\n"
 
2628
"      Content-Length: 0\n"
 
2629
"\n"
 
2630
"    ]]>\n"
 
2631
"  </send>\n"
 
2632
"\n"
 
2633
"  <!-- Keep the call open for a while in case the 200 is lost to be     -->\n"
 
2634
"  <!-- able to retransmit it if we receive the BYE again.               -->\n"
 
2635
"  <timewait milliseconds=\"2000\"/>\n"
 
2636
"\n"
 
2637
"</scenario>\n"
 
2638
"\n",
 
2639
 
 
2640
/************* Default_scenario[6] ***************/
 
2641
(char*) 
 
2642
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"
 
2643
"<!DOCTYPE scenario SYSTEM \"sipp.dtd\">\n"
 
2644
"\n"
 
2645
"<!-- This program is free software; you can redistribute it and/or      -->\n"
 
2646
"<!-- modify it under the terms of the GNU General Public License as     -->\n"
 
2647
"<!-- published by the Free Software Foundation; either version 2 of the -->\n"
 
2648
"<!-- License, or (at your option) any later version.                    -->\n"
 
2649
"<!--                                                                    -->\n"
 
2650
"<!-- This program is distributed in the hope that it will be useful,    -->\n"
 
2651
"<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of     -->\n"
 
2652
"<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      -->\n"
 
2653
"<!-- GNU General Public License for more details.                       -->\n"
 
2654
"<!--                                                                    -->\n"
 
2655
"<!-- You should have received a copy of the GNU General Public License  -->\n"
 
2656
"<!-- along with this program; if not, write to the                      -->\n"
 
2657
"<!-- Free Software Foundation, Inc.,                                    -->\n"
 
2658
"<!-- 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA             -->\n"
 
2659
"<!--                                                                    -->\n"
 
2660
"<!--                 3PCC - B side emulator                             -->\n"
 
2661
"<!--                                                                    -->\n"
 
2662
"<!--             A              Controller               B              -->\n"
 
2663
"<!--             |(1) INVITE no SDP  |                   |              -->\n"
 
2664
"<!--             |<==================|                   |              -->\n"
 
2665
"<!--             |(2) 200 offer1     |                   |              -->\n"
 
2666
"<!--             |==================>|                   |              -->\n"
 
2667
"<!--             |                   |(3) INVITE offer1  |              -->\n"
 
2668
"<!--             |                   |==================>|              -->\n"
 
2669
"<!--             |                   |(4) 200 OK answer1 |              -->\n"
 
2670
"<!--             |                   |<==================|              -->\n"
 
2671
"<!--             |                   |(5) ACK            |              -->\n"
 
2672
"<!--             |                   |==================>|              -->\n"
 
2673
"<!--             |(6) ACK answer1    |                   |              -->\n"
 
2674
"<!--             |<==================|                   |              -->\n"
 
2675
"<!--             |(7) RTP            |                   |              -->\n"
 
2676
"<!--             |.......................................|              -->\n"
 
2677
"<!--                                                                    -->\n"
 
2678
"\n"
 
2679
"\n"
 
2680
"\n"
 
2681
"<scenario name=\"3PCC B side\">\n"
 
2682
"  <recv request=\"INVITE\" crlf=\"true\"> </recv>\n"
 
2683
"\n"
 
2684
"  <send>\n"
 
2685
"    <![CDATA[\n"
 
2686
"\n"
 
2687
"      SIP/2.0 200 OK\n"
 
2688
"      [last_Via:]\n"
 
2689
"      [last_From:]\n"
 
2690
"      [last_To:];tag=[pid]SIPpTag06[call_number]\n"
 
2691
"      [last_Call-ID:]\n"
 
2692
"      [last_CSeq:]\n"
 
2693
"      Contact: <sip:[local_ip]:[local_port];transport=[transport]>\n"
 
2694
"      Content-Type: application/sdp\n"
 
2695
"      Content-Length: [len]\n"
 
2696
"\n"
 
2697
"      v=0\n"
 
2698
"      o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]\n"
 
2699
"      s=-\n"
 
2700
"      c=IN IP[media_ip_type] [media_ip]\n"
 
2701
"      t=0 0\n"
 
2702
"      m=audio [media_port] RTP/AVP 0\n"
 
2703
"      a=rtpmap:0 PCMU/8000\n"
 
2704
"\n"
 
2705
"    ]]>\n"
 
2706
"  </send>\n"
 
2707
"\n"
 
2708
"  <recv request=\"ACK\" rtd=\"true\" crlf=\"true\"> </recv>\n"
 
2709
"\n"
 
2710
"  <!-- RTP flow starts from here! -->\n"
 
2711
"\n"
 
2712
"  <recv request=\"BYE\"> </recv>\n"
 
2713
"\n"
 
2714
"  <send>\n"
 
2715
"    <![CDATA[\n"
 
2716
"\n"
 
2717
"      SIP/2.0 200 OK\n"
 
2718
"      [last_Via:]\n"
 
2719
"      [last_From:]\n"
 
2720
"      [last_To:]\n"
 
2721
"      [last_Call-ID:]\n"
 
2722
"      [last_CSeq:]\n"
 
2723
"      Contact: <sip:[local_ip]:[local_port];transport=[transport]>\n"
 
2724
"      Content-Length: 0\n"
 
2725
"\n"
 
2726
"    ]]>\n"
 
2727
"  </send>\n"
 
2728
"\n"
 
2729
"  <!-- Keep the call open for a while in case the 200 is lost to be     -->\n"
 
2730
"  <!-- able to retransmit it if we receive the BYE again.               -->\n"
 
2731
"  <timewait milliseconds=\"2000\"/>\n"
 
2732
"\n"
 
2733
"</scenario>\n",
 
2734
 
 
2735
/************* Default_scenario[7] ***************/
 
2736
(char*)
 
2737
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"
 
2738
"<!DOCTYPE scenario SYSTEM \"sipp.dtd\">\n"
 
2739
"\n"
 
2740
"<!-- This program is free software; you can redistribute it and/or      -->\n"
 
2741
"<!-- modify it under the terms of the GNU General Public License as     -->\n"
 
2742
"<!-- published by the Free Software Foundation; either version 2 of the -->\n"
 
2743
"<!-- License, or (at your option) any later version.                    -->\n"
 
2744
"<!--                                                                    -->\n"
 
2745
"<!-- This program is distributed in the hope that it will be useful,    -->\n"
 
2746
"<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of     -->\n"
 
2747
"<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      -->\n"
 
2748
"<!-- GNU General Public License for more details.                       -->\n"
 
2749
"<!--                                                                    -->\n"
 
2750
"<!-- You should have received a copy of the GNU General Public License  -->\n"
 
2751
"<!-- along with this program; if not, write to the                      -->\n"
 
2752
"<!-- Free Software Foundation, Inc.,                                    -->\n"
 
2753
"<!-- 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA             -->\n"
 
2754
"<!--                                                                    -->\n"
 
2755
"<!--                 Sipp default 'branchc' scenario.                   -->\n"
 
2756
"<!--                                                                    -->\n"
 
2757
"\n"
 
2758
"<scenario name=\"branch_client\">\n"
 
2759
"  <send retrans=\"500\">\n"
 
2760
"    <![CDATA[\n"
 
2761
"\n"
 
2762
"      REGISTER sip:CA.cym.com SIP/2.0\n"
 
2763
"      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]\n"
 
2764
"      From: ua1 <sip:ua1@nnl.cym:[local_port]>;tag=[pid]SIPpTag07[call_number]\n"
 
2765
"      To: ua1 <sip:ua1@nnl.cym:[local_port]>\n"
 
2766
"      Call-ID: [call_id]\n"
 
2767
"      CSeq: 1 REGISTER\n"
 
2768
"      Contact: sip:ua1@[local_ip]:[local_port]\n"
 
2769
"      Content-Length: 0\n"
 
2770
"      Expires: 300\n"
 
2771
"\n"
 
2772
"    ]]>\n"
 
2773
"  </send>\n"
 
2774
"\n"
 
2775
"  <!-- simple case - just jump over a line   -->\n"
 
2776
"  <recv response=\"200\" rtd=\"true\" next=\"5\">\n"
 
2777
"  </recv>\n"
 
2778
"\n"
 
2779
"  <recv response=\"200\">\n"
 
2780
"  </recv>\n"
 
2781
"\n"
 
2782
"  <label id=\"5\"/>\n"
 
2783
"\n"
 
2784
"  <send retrans=\"500\">\n"
 
2785
"    <![CDATA[\n"
 
2786
"\n"
 
2787
"      INVITE sip:ua2@CA.cym.com SIP/2.0\n"
 
2788
"      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]\n"
 
2789
"      From: ua[call_number] <sip:ua1@nnl.cym:[local_port]>;tag=[pid]SIPpTag07b[call_number]\n"
 
2790
"      To: ua2 <sip:ua2@nnl.cym:[remote_port]>\n"
 
2791
"      Call-ID: [call_id]\n"
 
2792
"      CSeq: 1 INVITE\n"
 
2793
"      Contact: sip:ua1@[local_ip]:[local_port]\n"
 
2794
"      Max-Forwards: 70\n"
 
2795
"      Subject: Performance Test\n"
 
2796
"      Content-Type: application/sdp\n"
 
2797
"      Content-Length: [len]\n"
 
2798
"\n"
 
2799
"      v=0\n"
 
2800
"      o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]\n"
 
2801
"      s=-\n"
 
2802
"      c=IN IP[media_ip_type] [media_ip]\n"
 
2803
"      t=0 0\n"
 
2804
"      m=audio [media_port] RTP/AVP 0\n"
 
2805
"      a=rtpmap:0 PCMU/8000\n"
 
2806
"\n"
 
2807
"    ]]>\n"
 
2808
"  </send>\n"
 
2809
"\n"
 
2810
"  <recv response=\"100\" optional=\"true\">\n"
 
2811
"  </recv>\n"
 
2812
"\n"
 
2813
"  <recv response=\"180\" optional=\"true\">\n"
 
2814
"  </recv>\n"
 
2815
"\n"
 
2816
"  <recv response=\"183\" optional=\"true\">\n"
 
2817
"  </recv>\n"
 
2818
"\n"
 
2819
"  <!-- Do something different on an optional receive   -->\n"
 
2820
"  <recv response=\"403\" optional=\"true\" next=\"1\">\n"
 
2821
"  </recv>\n"
 
2822
"\n"
 
2823
"  <recv response=\"200\">\n"
 
2824
"    <action>\n"
 
2825
"      <ereg regexp=\"ua25\"\n"
 
2826
"            search_in=\"hdr\"\n"
 
2827
"            header=\"From: \"\n"
 
2828
"            assign_to=\"8\"/>\n"
 
2829
"    </action>\n"
 
2830
"  </recv>\n"
 
2831
"\n"
 
2832
"  <!-- set variable 8 above on 25th call, send the ACK but skip the pause for it   -->\n"
 
2833
"  <send next=\"1\" test=\"8\">\n"
 
2834
"    <![CDATA[\n"
 
2835
"\n"
 
2836
"      ACK sip:ua2@CA.cym.com SIP/2.0\n"
 
2837
"      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]\n"
 
2838
"      From: ua1 <sip:ua1@nnl.cym:[local_port]>;tag=[pid]SIPpTag07b[call_number]\n"
 
2839
"      To: ua2 <sip:ua2@nnl.cym:[remote_port]>[peer_tag_param]\n"
 
2840
"      Call-ID: [call_id]\n"
 
2841
"      CSeq: 1 ACK\n"
 
2842
"      Contact: sip:ua1@[local_ip]:[local_port]\n"
 
2843
"      Max-Forwards: 70\n"
 
2844
"      Subject: Performance Test\n"
 
2845
"      Content-Length: 0\n"
 
2846
"\n"
 
2847
"    ]]>\n"
 
2848
"  </send>\n"
 
2849
"\n"
 
2850
"  <pause milliseconds=\"5000\"/>\n"
 
2851
"\n"
 
2852
"  <label id=\"1\"/>\n"
 
2853
"\n"
 
2854
"  <send retrans=\"500\">\n"
 
2855
"    <![CDATA[\n"
 
2856
"\n"
 
2857
"      BYE sip:ua2@CA.cym.com SIP/2.0\n"
 
2858
"      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]\n"
 
2859
"      From: ua1 <sip:ua1@nnl.cym:[local_port]>;tag=[pid]SIPpTag07b[call_number]\n"
 
2860
"      To: ua2 <sip:ua2@nnl.cym:[remote_port]>[peer_tag_param]\n"
 
2861
"      Call-ID: [call_id]\n"
 
2862
"      CSeq: 2 BYE\n"
 
2863
"      Contact: sip:ua1@[local_ip]:[local_port]\n"
 
2864
"      Max-Forwards: 70\n"
 
2865
"      Subject: Performance Test\n"
 
2866
"      Content-Length: 0\n"
 
2867
"\n"
 
2868
"    ]]>\n"
 
2869
"  </send>\n"
 
2870
"\n"
 
2871
"  <recv response=\"200\" crlf=\"true\">\n"
 
2872
"  </recv>\n"
 
2873
"\n"
 
2874
"  <pause milliseconds=\"4000\"/>\n"
 
2875
"\n"
 
2876
"  <!-- definition of the response time repartition table (unit is ms)   -->\n"
 
2877
"  <ResponseTimeRepartition value=\"10, 20, 30, 40, 50, 100, 150, 200\"/>\n"
 
2878
"\n"
 
2879
"  <!-- definition of the call length repartition table (unit is ms)     -->\n"
 
2880
"  <CallLengthRepartition value=\"10, 50, 100, 500, 1000, 5000, 10000\"/>\n"
 
2881
"\n"
 
2882
"</scenario>\n"
 
2883
"\n",
 
2884
 
 
2885
/************* Default_scenario[8] ***************/
 
2886
(char*)
 
2887
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"
 
2888
"<!DOCTYPE scenario SYSTEM \"sipp.dtd\">\n"
 
2889
"\n"
 
2890
"<!-- This program is free software; you can redistribute it and/or      -->\n"
 
2891
"<!-- modify it under the terms of the GNU General Public License as     -->\n"
 
2892
"<!-- published by the Free Software Foundation; either version 2 of the -->\n"
 
2893
"<!-- License, or (at your option) any later version.                    -->\n"
 
2894
"<!--                                                                    -->\n"
 
2895
"<!-- This program is distributed in the hope that it will be useful,    -->\n"
 
2896
"<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of     -->\n"
 
2897
"<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      -->\n"
 
2898
"<!-- GNU General Public License for more details.                       -->\n"
 
2899
"<!--                                                                    -->\n"
 
2900
"<!-- You should have received a copy of the GNU General Public License  -->\n"
 
2901
"<!-- along with this program; if not, write to the                      -->\n"
 
2902
"<!-- Free Software Foundation, Inc.,                                    -->\n"
 
2903
"<!-- 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA             -->\n"
 
2904
"<!--                                                                    -->\n"
 
2905
"<!--                 Sipp default 'branchs' scenario.                   -->\n"
 
2906
"<!--                                                                    -->\n"
 
2907
"\n"
 
2908
"<scenario name=\"branch_server\">\n"
 
2909
"  <recv request=\"REGISTER\">\n"
 
2910
"  </recv>\n"
 
2911
"\n"
 
2912
"  <send>\n"
 
2913
"    <![CDATA[\n"
 
2914
"\n"
 
2915
"      SIP/2.0 200 OK\n"
 
2916
"      [last_Via:]\n"
 
2917
"      [last_From:]\n"
 
2918
"      [last_To:];tag=[pid]SIPpTag08[call_number]\n"
 
2919
"      [last_Call-ID:]\n"
 
2920
"      [last_CSeq:]\n"
 
2921
"      Contact: <sip:[local_ip]:[local_port];transport=[transport]>\n"
 
2922
"      Content-Length: 0\n"
 
2923
"      Expires: 300\n"
 
2924
"\n"
 
2925
"    ]]>\n"
 
2926
"  </send>\n"
 
2927
"\n"
 
2928
"  <!-- Set variable 3 if the ua is of the form ua2... -->\n"
 
2929
"  <recv request=\"INVITE\" crlf=\"true\">\n"
 
2930
"    <action>\n"
 
2931
"      <ereg regexp=\"ua2\"\n"
 
2932
"            search_in=\"hdr\"\n"
 
2933
"            header=\"From: \"\n"
 
2934
"            assign_to=\"3\"/>\n"
 
2935
"    </action>\n"
 
2936
"  </recv>\n"
 
2937
"\n"
 
2938
"  <!-- send 180 then trying if variable 3 is set -->\n"
 
2939
"  <send next=\"1\" test=\"3\">\n"
 
2940
"    <![CDATA[\n"
 
2941
"\n"
 
2942
"      SIP/2.0 180 Ringing\n"
 
2943
"      [last_Via:]\n"
 
2944
"      [last_From:]\n"
 
2945
"      [last_To:];tag=[pid]SIPpTag08b[call_number]\n"
 
2946
"      [last_Call-ID:]\n"
 
2947
"      [last_CSeq:]\n"
 
2948
"      Contact: <sip:[local_ip]:[local_port];transport=[transport]>\n"
 
2949
"      Content-Length: 0\n"
 
2950
"\n"
 
2951
"    ]]>\n"
 
2952
"  </send>\n"
 
2953
"\n"
 
2954
"  <!-- if not, send a 403 error then skip to wait for a BYE -->\n"
 
2955
"  <send next=\"2\">\n"
 
2956
"    <![CDATA[\n"
 
2957
"\n"
 
2958
"      SIP/2.0 403 Error\n"
 
2959
"      [last_Via:]\n"
 
2960
"      [last_From:]\n"
 
2961
"      [last_To:];tag=[pid]SIPpTag08b[call_number]\n"
 
2962
"      [last_Call-ID:]\n"
 
2963
"      [last_CSeq:]\n"
 
2964
"      Contact: <sip:[local_ip]:[local_port];transport=[transport]>\n"
 
2965
"      Content-Length: 0\n"
 
2966
"\n"
 
2967
"    ]]>\n"
 
2968
"  </send>\n"
 
2969
"\n"
 
2970
"  <label id=\"1\"/>\n"
 
2971
"\n"
 
2972
"  <send>\n"
 
2973
"    <![CDATA[\n"
 
2974
"\n"
 
2975
"      SIP/2.0 100 Trying\n"
 
2976
"      [last_Via:]\n"
 
2977
"      [last_From:]\n"
 
2978
"      [last_To:];tag=[pid]SIPpTag08b[call_number]\n"
 
2979
"      [last_Call-ID:]\n"
 
2980
"      [last_CSeq:]\n"
 
2981
"      Contact: <sip:[local_ip]:[local_port];transport=[transport]>\n"
 
2982
"      Content-Length: 0\n"
 
2983
"\n"
 
2984
"    ]]>\n"
 
2985
"  </send>\n"
 
2986
"\n"
 
2987
"  <send retrans=\"500\">\n"
 
2988
"    <![CDATA[\n"
 
2989
"\n"
 
2990
"      SIP/2.0 200 OK\n"
 
2991
"      [last_Via:]\n"
 
2992
"      [last_From:]\n"
 
2993
"      [last_To:];tag=[pid]SIPpTag08b[call_number]\n"
 
2994
"      [last_Call-ID:]\n"
 
2995
"      [last_CSeq:]\n"
 
2996
"      Contact: <sip:[local_ip]:[local_port];transport=[transport]>\n"
 
2997
"      Content-Type: application/sdp\n"
 
2998
"      Content-Length: [len]\n"
 
2999
"\n"
 
3000
"      v=0\n"
 
3001
"      o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]\n"
 
3002
"      s=-\n"
 
3003
"      c=IN IP[media_ip_type] [media_ip]\n"
 
3004
"      t=0 0\n"
 
3005
"      m=audio [media_port] RTP/AVP 0\n"
 
3006
"      a=rtpmap:0 PCMU/8000\n"
 
3007
"\n"
 
3008
"    ]]>\n"
 
3009
"  </send>\n"
 
3010
"\n"
 
3011
"  <recv request=\"ACK\"\n"
 
3012
"        optional=\"true\"\n"
 
3013
"        rtd=\"true\"\n"
 
3014
"        crlf=\"true\">\n"
 
3015
"  </recv>\n"
 
3016
"\n"
 
3017
"  <label id=\"2\"/>\n"
 
3018
"\n"
 
3019
"  <recv request=\"BYE\">\n"
 
3020
"  </recv>\n"
 
3021
"\n"
 
3022
"  <send>\n"
 
3023
"    <![CDATA[\n"
 
3024
"\n"
 
3025
"      SIP/2.0 200 OK\n"
 
3026
"      [last_Via:]\n"
 
3027
"      [last_From:]\n"
 
3028
"      [last_To:]\n"
 
3029
"      [last_Call-ID:]\n"
 
3030
"      [last_CSeq:]\n"
 
3031
"      Contact: <sip:[local_ip]:[local_port];transport=[transport]>\n"
 
3032
"      Content-Length: 0\n"
 
3033
"\n"
 
3034
"    ]]>\n"
 
3035
"  </send>\n"
 
3036
"\n"
 
3037
"  <!-- Keep the call open for a while in case the 200 is lost to be     -->\n"
 
3038
"  <!-- able to retransmit it if we receive the BYE again.               -->\n"
 
3039
"  <timewait milliseconds=\"4000\"/>\n"
 
3040
"\n"
 
3041
"  <!-- Definition of the response time repartition table (unit is ms)   -->\n"
 
3042
"  <ResponseTimeRepartition value=\"10, 20, 30, 40, 50, 100, 150, 200\"/>\n"
 
3043
"\n"
 
3044
"  <!-- Definition of the call length repartition table (unit is ms)     -->\n"
 
3045
"  <CallLengthRepartition value=\"10, 50, 100, 500, 1000, 5000, 10000\"/>\n"
 
3046
"\n"
 
3047
"</scenario>\n"
 
3048
"\n",
 
3049
 
 
3050
/* Although this scenario will not work without pcap play enabled, there is no
 
3051
 * harm in including it in the binary anyway, because the user could have
 
3052
 * dumped it and passed it with -sf. */
 
3053
 
 
3054
/************* Default_scenario[9] ***************/
 
3055
(char*)
 
3056
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"
 
3057
"<!DOCTYPE scenario SYSTEM \"sipp.dtd\">\n"
 
3058
"\n"
 
3059
"<!-- This program is free software; you can redistribute it and/or      -->\n"
 
3060
"<!-- modify it under the terms of the GNU General Public License as     -->\n"
 
3061
"<!-- published by the Free Software Foundation; either version 2 of the -->\n"
 
3062
"<!-- License, or (at your option) any later version.                    -->\n"
 
3063
"<!--                                                                    -->\n"
 
3064
"<!-- This program is distributed in the hope that it will be useful,    -->\n"
 
3065
"<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of     -->\n"
 
3066
"<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      -->\n"
 
3067
"<!-- GNU General Public License for more details.                       -->\n"
 
3068
"<!--                                                                    -->\n"
 
3069
"<!-- You should have received a copy of the GNU General Public License  -->\n"
 
3070
"<!-- along with this program; if not, write to the                      -->\n"
 
3071
"<!-- Free Software Foundation, Inc.,                                    -->\n"
 
3072
"<!-- 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA             -->\n"
 
3073
"<!--                                                                    -->\n"
 
3074
"<!--                 Sipp 'uac' scenario with pcap (rtp) play           -->\n"
 
3075
"<!--                                                                    -->\n"
 
3076
"\n"
 
3077
"<scenario name=\"UAC with media\">\n"
 
3078
"  <!-- In client mode (sipp placing calls), the Call-ID MUST be         -->\n"
 
3079
"  <!-- generated by sipp. To do so, use [call_id] keyword.                -->\n"
 
3080
"  <send retrans=\"500\">\n"
 
3081
"    <![CDATA[\n"
 
3082
"\n"
 
3083
"      INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0\n"
 
3084
"      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]\n"
 
3085
"      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag09[call_number]\n"
 
3086
"      To: sut <sip:[service]@[remote_ip]:[remote_port]>\n"
 
3087
"      Call-ID: [call_id]\n"
 
3088
"      CSeq: 1 INVITE\n"
 
3089
"      Contact: sip:sipp@[local_ip]:[local_port]\n"
 
3090
"      Max-Forwards: 70\n"
 
3091
"      Subject: Performance Test\n"
 
3092
"      Content-Type: application/sdp\n"
 
3093
"      Content-Length: [len]\n"
 
3094
"\n"
 
3095
"      v=0\n"
 
3096
"      o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]\n"
 
3097
"      s=-\n"
 
3098
"      c=IN IP[local_ip_type] [local_ip]\n"
 
3099
"      t=0 0\n"
 
3100
"      m=audio [auto_media_port] RTP/AVP 8 101\n"
 
3101
"      a=rtpmap:8 PCMA/8000\n"
 
3102
"      a=rtpmap:101 telephone-event/8000\n"
 
3103
"      a=fmtp:101 0-11,16\n"
 
3104
"\n"
 
3105
"    ]]>\n"
 
3106
"  </send>\n"
 
3107
"\n"
 
3108
"  <recv response=\"100\" optional=\"true\">\n"
 
3109
"  </recv>\n"
 
3110
"\n"
 
3111
"  <recv response=\"180\" optional=\"true\">\n"
 
3112
"  </recv>\n"
 
3113
"\n"
 
3114
"  <!-- By adding rrs=\"true\" (Record Route Sets), the route sets         -->\n"
 
3115
"  <!-- are saved and used for following messages sent. Useful to test   -->\n"
 
3116
"  <!-- against stateful SIP proxies/B2BUAs.                             -->\n"
 
3117
"  <recv response=\"200\" rtd=\"true\" crlf=\"true\">\n"
 
3118
"  </recv>\n"
 
3119
"\n"
 
3120
"  <!-- Packet lost can be simulated in any send/recv message by         -->\n"
 
3121
"  <!-- by adding the 'lost = \"10\"'. Value can be [1-100] percent.       -->\n"
 
3122
"  <send>\n"
 
3123
"    <![CDATA[\n"
 
3124
"\n"
 
3125
"      ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0\n"
 
3126
"      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]\n"
 
3127
"      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag09[call_number]\n"
 
3128
"      To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]\n"
 
3129
"      Call-ID: [call_id]\n"
 
3130
"      CSeq: 1 ACK\n"
 
3131
"      Contact: sip:sipp@[local_ip]:[local_port]\n"
 
3132
"      Max-Forwards: 70\n"
 
3133
"      Subject: Performance Test\n"
 
3134
"      Content-Length: 0\n"
 
3135
"\n"
 
3136
"    ]]>\n"
 
3137
"  </send>\n"
 
3138
"\n"
 
3139
"  <!-- Play a pre-recorded PCAP file (RTP stream)                       -->\n"
 
3140
"  <nop>\n"
 
3141
"    <action>\n"
 
3142
"      <exec play_pcap_audio=\"pcap/g711a.pcap\"/>\n"
 
3143
"    </action>\n"
 
3144
"  </nop>\n"
 
3145
"\n"
 
3146
"  <!-- Pause 8 seconds, which is approximately the duration of the      -->\n"
 
3147
"  <!-- PCAP file                                                        -->\n"
 
3148
"  <pause milliseconds=\"8000\"/>\n"
 
3149
"\n"
 
3150
"  <!-- Play an out of band DTMF '1'                                     -->\n"
 
3151
"  <nop>\n"
 
3152
"    <action>\n"
 
3153
"      <exec play_pcap_audio=\"pcap/dtmf_2833_1.pcap\"/>\n"
 
3154
"    </action>\n"
 
3155
"  </nop>\n"
 
3156
"\n"
 
3157
"  <pause milliseconds=\"1000\"/>\n"
 
3158
"\n"
 
3159
"  <!-- The 'crlf' option inserts a blank line in the statistics report. -->\n"
 
3160
"  <send retrans=\"500\">\n"
 
3161
"    <![CDATA[\n"
 
3162
"\n"
 
3163
"      BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0\n"
 
3164
"      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]\n"
 
3165
"      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag09[call_number]\n"
 
3166
"      To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]\n"
 
3167
"      Call-ID: [call_id]\n"
 
3168
"      CSeq: 2 BYE\n"
 
3169
"      Contact: sip:sipp@[local_ip]:[local_port]\n"
 
3170
"      Max-Forwards: 70\n"
 
3171
"      Subject: Performance Test\n"
 
3172
"      Content-Length: 0\n"
 
3173
"\n"
 
3174
"    ]]>\n"
 
3175
"  </send>\n"
 
3176
"\n"
 
3177
"  <recv response=\"200\" crlf=\"true\">\n"
 
3178
"  </recv>\n"
 
3179
"\n"
 
3180
"  <!-- definition of the response time repartition table (unit is ms)   -->\n"
 
3181
"  <ResponseTimeRepartition value=\"10, 20, 30, 40, 50, 100, 150, 200\"/>\n"
 
3182
"\n"
 
3183
"  <!-- definition of the call length repartition table (unit is ms)     -->\n"
 
3184
"  <CallLengthRepartition value=\"10, 50, 100, 500, 1000, 5000, 10000\"/>\n"
 
3185
"\n"
 
3186
"</scenario>\n"
 
3187
"\n",
 
3188
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"
 
3189
"<!DOCTYPE scenario SYSTEM \"sipp.dtd\">\n"
 
3190
"\n"
 
3191
"<!-- This program is free software; you can redistribute it and/or      -->\n"
 
3192
"<!-- modify it under the terms of the GNU General Public License as     -->\n"
 
3193
"<!-- published by the Free Software Foundation; either version 2 of the -->\n"
 
3194
"<!-- License, or (at your option) any later version.                    -->\n"
 
3195
"<!--                                                                    -->\n"
 
3196
"<!-- This program is distributed in the hope that it will be useful,    -->\n"
 
3197
"<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of     -->\n"
 
3198
"<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      -->\n"
 
3199
"<!-- GNU General Public License for more details.                       -->\n"
 
3200
"<!--                                                                    -->\n"
 
3201
"<!-- You should have received a copy of the GNU General Public License  -->\n"
 
3202
"<!-- along with this program; if not, write to the                      -->\n"
 
3203
"<!-- Free Software Foundation, Inc.,                                    -->\n"
 
3204
"<!-- 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA             -->\n"
 
3205
"<!--                                                                    -->\n"
 
3206
"<!--                 Sipp default 'uas' scenario.                       -->\n"
 
3207
"<!--                                                                    -->\n"
 
3208
"\n"
 
3209
"<scenario name=\"Out-of-call UAS\">\n"
 
3210
"  <recv request=\".*\" regexp_match=\"true\" />\n"
 
3211
"\n"
 
3212
"  <send>\n"
 
3213
"    <![CDATA[\n"
 
3214
"      SIP/2.0 200 OK\n"
 
3215
"      [last_Via:]\n"
 
3216
"      [last_From:]\n"
 
3217
"      [last_To:]\n"
 
3218
"      [last_Call-ID:]\n"
 
3219
"      [last_CSeq:]\n"
 
3220
"      Contact: <sip:[local_ip]:[local_port];transport=[transport]>\n"
 
3221
"      Content-Length: 0\n"
 
3222
"\n"
 
3223
"    ]]>\n"
 
3224
"  </send>\n"
 
3225
"\n"
 
3226
"  <!-- Keep the call open for a while in case the 200 is lost to be     -->\n"
 
3227
"  <!-- able to retransmit it if we receive the BYE again.               -->\n"
 
3228
"  <timewait milliseconds=\"4000\"/>\n"
 
3229
"\n"
 
3230
"\n"
 
3231
"  <!-- definition of the response time repartition table (unit is ms)   -->\n"
 
3232
"  <ResponseTimeRepartition value=\"10, 20, 30, 40, 50, 100, 150, 200\"/>\n"
 
3233
"\n"
 
3234
"  <!-- definition of the call length repartition table (unit is ms)     -->\n"
 
3235
"  <CallLengthRepartition value=\"10, 50, 100, 500, 1000, 5000, 10000\"/>\n"
 
3236
"\n"
 
3237
"</scenario>\n",
 
3238
};