1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
<?xml version="1.0" encoding="latin1" ?>
<!DOCTYPE chapter SYSTEM "chapter.dtd">
<chapter>
<header>
<copyright>
<year>2000</year><year>2009</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
The contents of this file are subject to the Erlang Public License,
Version 1.1, (the "License"); you may not use this file except in
compliance with the License. You should have received a copy of the
Erlang Public License along with this software. If not, it can be
retrieved online at http://www.erlang.org/.
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and limitations
under the License.
</legalnotice>
<title>Implementation examples</title>
<prepared>Håkan Mattsson</prepared>
<responsible>Håkan Mattsson</responsible>
<docno></docno>
<approved>Håkan Mattsson</approved>
<checked></checked>
<date>2007-06-15</date>
<rev>%VSN%</rev>
<file>megaco_examples.xml</file>
</header>
<section>
<title>A simple Media Gateway Controller</title>
<p>In megaco/examples/simple/megaco_simple_mgc.erl there is an
example of a simple MGC that listens on both text and binary
standard ports and is prepared to handle a Service Change
Request message to arrive either via TCP/IP or UDP/IP. Messages
received on the text port are decoded using a text decoder and
messages received on the binary port are decoded using a binary
decoder.</p>
<p>The Service Change Reply is encoded in the same way as the
request and sent back to the MG with the same transport
mechanism UDP/IP or TCP/IP.</p>
<p>After this initial service change message the connection
between the MG and MGC is fully established and supervised.</p>
<p>The MGC, with its four listeners, may be started with:</p>
<pre>
cd megaco/examples/simple
erl -pa ../../../megaco/ebin -s megaco_filter -s megaco
megaco_simple_mgc:start().
</pre>
<p>or simply 'gmake mgc'.</p>
<p>The -s megaco_filter option to erl implies, the event tracing
mechanism to be enabled and an interactive sequence chart tool
to be started. This may be quite useful in order to visualize
how your MGC interacts with the Megaco/H.248 protocol stack.</p>
<p>The event traces may alternatively be directed to a file for
later analyze. By default the event tracing is disabled, but it
may dynamically be enabled without any need for re-compilation
of the code.
</p>
</section>
<section>
<title>A simple Media Gateway</title>
<p>In megaco/examples/simple/megaco_simple_mg.erl there is an
example of a simple MG that connects to an MGC, sends a Service
Change Request and waits synchronously for a reply.</p>
<p>After this initial service change message the connection
between the MG and MGC is fully established and supervised.</p>
<p>Assuming that the MGC is started on the local host, four
different MG's, using text over TCP/IP, binary over TCP/IP, text
over UDP/IP and binary over UDP/IP may be started on the same
Erlang node with:</p>
<pre>
cd megaco/examples/simple
erl -pa ../../../megaco/ebin -s megaco_filter -s megaco
megaco_simple_mg:start().
</pre>
<p>or simply 'gmake mg'.</p>
<p>If you "only" want to start a single MG which tries to connect
an MG on a host named "baidarka", you may use one of these
functions (instead of the megaco_simple_mg:start/0 above):</p>
<pre>
megaco_simple_mg:start_tcp_text("baidarka", []).
megaco_simple_mg:start_tcp_binary("baidarka", []).
megaco_simple_mg:start_udp_text("baidarka", []).
megaco_simple_mg:start_udp_binary("baidarka", []).
</pre>
<p>The -s megaco_filter option to erl implies, the event tracing
mechanism to be enabled and an interactive sequence chart tool
to be started. This may be quite useful in order to visualize
how your MG interacts with the Megaco/H.248 protocol stack.</p>
<p>The event traces may alternatively be directed to a file for
later analyze. By default the event tracing is disabled, but it
may dynamically be enabled without any need for re-compilation
of the code.
</p>
</section>
</chapter>
|