<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/en/2171/18/9/_/styles/combined.css?spaceKey=TOP&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://wiki.asterisk.org/wiki/display/TOP/Hello+World+-+Asterisk+SCF+Style">Hello World - Asterisk SCF Style</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://wiki.asterisk.org/wiki/display/~beagles">Brent Eagles</a>
    </h4>
        <br/>
                         <h4>Changes (2)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >We will save this file in the {{sip}} repo&#39;s {{config}} directory as {{Sip.config}}. For your convenience, here is the file: <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">[Asterisk SCF Hello World Example^Sip.config] <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">[Hello World - Asterisk SCF Style^Sip.config] <br></td></tr>
            <tr><td class="diff-unchanged" > <br>h3. Running the configurator script <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>You've managed to get Asterisk SCF completely downloaded and compiled, so now what? In this tutorial, I will give a step-by-step set of instructions for getting two SIP phones to communicate with each other. We will be foregoing features such as registration and authentication for the sake of simplicity.</p>

<h1><a name="HelloWorld-AsteriskSCFStyle-AnOverview"></a>An Overview</h1>

<p>We will use the bare essentials for this. This will require the use of the following components:</p>

<ul>
        <li>ServiceDisovery: The other components use this to advertise themselves and to find components they rely upon to operate.</li>
        <li>SIP: This handles SIP signaling. This is also where we configure SIP endpoints.</li>
        <li>Media-RTP-PJMEDIA: This handles the RTP setup and media streams.</li>
        <li>BasicRouting: This will do endpoint lookup and bridge setup.</li>
        <li>Bridging: This will connect the sessions and their associated media.</li>
        <li>MediaFormatGeneric: This contains descriptor information for the media type we will use in our call.</li>
</ul>


<p>We will run the above components in separate icebox instances. It would be possible to run them in a single icebox instance, but doing it this way allows for the individual components' configurations to be changed more easily.</p>

<p>After the components are running, we will need to push additional configuration to the SIP component in order for SIP services to be started and in order for endpoints to be created. This will be done using the provided <tt>SipConfigurator.py</tt> script in the SIP repo's <tt>/config</tt> directory.</p>

<p>The following examples will be written with the assumptions that the gitall script is in the <tt>/home/asteriskscf</tt>. For example, the SIP repo will be in <tt>/home/asteriskscf/gitall/sip</tt>. If you are using a different path for your repos, then make the appropriate changes to the instructions below.</p>

<h1><a name="HelloWorld-AsteriskSCFStyle-Gettingthecomponentsconfigured"></a>Getting the components configured</h1>

<p>Each component will require an icebox configuration file to give it essential information like where to find the ServiceLocator, what host and port its services should run on, and various other component-specific options.</p>

<p>For your convenience, <a href="/wiki/display/TOP/Example+IceBox+Config+Files" title="Example IceBox Config Files">this page</a> has all the icebox configuration files you will need in order to start your components. <a href="/wiki/display/TOP/Notes+on+Ice+Config+Files" title="Notes on Ice Config Files">This page</a> has a bit of an explanation behind a few of the configuration options.</p>

<h1><a name="HelloWorld-AsteriskSCFStyle-StartingAsteriskSCF"></a>Starting Asterisk SCF</h1>

<p>Now that you have configuration files written, you'll need to start each of the components.<br/>
To start a component, you'll need to issue the following command:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>$ icebox --Ice.Config=path/to/component/config/file
</pre>
</div></div>

<p>For instance, if you have called your routing configuration file <tt>routing.icebox</tt>, and it is saved in the routing repo's config directory, then you would start the routing service using the command</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>$ icebox --Ice.Config=/home/asteriskscf/gitall/routing/config/routing.icebox
</pre>
</div></div>

<p>You will need to issue <tt>icebox</tt> commands for each of the components. It would probably do you well to create a small script to start up all the services.</p>

<h1><a name="HelloWorld-AsteriskSCFStyle-ConfiguringSIPendpoints."></a>Configuring SIP endpoints.</h1>

<p>At this point you should have all of your components up and running. Unfortunately, they cannot really do much of anything without further application-specific configuration. In this case, we need to configure the SIP component so that it will be able to handle calls.</p>

<p>To do this, we will made use of the <tt>SipConfigurator.py</tt> script in the <tt>config</tt> directory of the <tt>sip</tt> repo.</p>

<h3><a name="HelloWorld-AsteriskSCFStyle-Creatingaconfigurationfile"></a>Creating a configuration file</h3>

<p>The configurator reads in a .ini-style file with configuration options specified. Below is an example configuration file to use.</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>
# First, we need to configure a transport for the SIP component to use.
# Feel free to give it whatever name you want.
[udp-transport]
# This tells the configurator what type of configuration
# section this is. In this case, we're configuring a
# UDP transport
type=transport-udp

# This tells the IP address and port to bind to for this transport.
# This can be an IPv4 or IPv6 address.
host=0.0.0.0
port=5060

# Now we need to configure endpoints. Endpoints each comprise their
# own section.
[1000]
# This tells the configurator that this section describes
# an endpoint
type=endpoint

# The IP address or hostname and port of the endpoint.
targethost=&lt;IP address or hostname of endpoint 1000&gt;
targetport=5060

# The IP address and port that we tell the endpoint to
# send their SIP signaling to when we call it.
sourcehost=&lt;IP address of the Asterisk SCF server&gt;
sourceport=5060

# This specifies the allowable direction(s) for communications
# between Asterisk SCF and the endpoint. Setting this to "both"
# allows for both incoming and outgoing calls to be made with
# this endpoint.
direction=both

# This specifies what formats to offer in SDP offers and what
# formats to accept in an SDP answer. For our example, we will
# use 8000 Hz G.711 uLAW audio.
formats=ulaw/8000

# This endpoint will mostly be configured the same.
[2000]
type=endpoint
targethost=&lt;IP address or hostname of endpoint 2000&gt;
targetport=5060
sourceport=&lt;IP address of the Asterisk SCF server&gt;
sourceport=5060
direction=both
formats=ulaw/8000

</pre>
</div></div>

<p>We will save this file in the <tt>sip</tt> repo's <tt>config</tt> directory as <tt>Sip.config</tt>. For your convenience, here is the file:</p>

<p><a href="/wiki/download/attachments/19007195/Sip.config?version=2&amp;modificationDate=1323721147826">Sip.config</a></p>

<h3><a name="HelloWorld-AsteriskSCFStyle-Runningtheconfiguratorscript"></a>Running the configurator script</h3>

<p>You'll now need to run the <tt>SipConfigurator.py</tt> script in order to apply the SIP configuration to the running SIP component. The configurator relies on some environment variables to be set, so let's go and do that!</p>

<p>First, you'll need to add a couple of items to your <tt>PYTHONPATH</tt>. You will need to add the path to Ice's python definitions (on Linux, this is /opt/Ice-3.4.2/python/ by default) and the path to the Asterisk SCF <tt>configurator</tt> repo. You will also need to set the <tt>ASTSCF_HOME</tt> environment variable. This is the path to the <tt>slice</tt> subdirectory of the Asterisk SCF <tt>slice</tt> repo. On Unix-like systems, this is done using the following command:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>$ export PYTHONPATH=/opt/Ice-3.4.2/python:/home/asteriskscf/gitall/configurator
$ export ASTSCF_HOME=/home/asteriskscf/gitall/slice/slice
</pre>
</div></div>

<p>Now that you have the appropriate environment variables set up, you can actually run the python script.</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>$ cd /home/asteriskscf/gitall/sip/config
$ ./SipConfigurator.py --wipe --config=Sip.config --locator="LocatorService:tcp -p 4411"
</pre>
</div></div>

<p>This should successfully apply your configuration to the running SIP component.</p>

<h3><a name="HelloWorld-AsteriskSCFStyle-Configuringthephones"></a>Configuring the phones</h3>

<p>With this setup, we've named the phones <tt>1000</tt> and <tt>2000</tt>. Asterisk SCF's current endpoint matching scheme is to use the user part in the URI in the From header of an INVITE to determine which endpoint the message is originating from. This means that you will need to configure your phone to identify itself properly. The method will differ per phone. Options such as "Caller ID number" or "Phone Number" are generally good places to set the endpoint name.</p>

<h1><a name="HelloWorld-AsteriskSCFStyle-Placingthecall"></a>Placing the call</h1>

<p>Now you should be able to place calls between the phones. You can dial each phone using the endpoint name for that phone. So for instance, if you wish to call phone <tt>2000</tt> then you can pick up phone <tt>1000</tt> and dial "2000".</p>

<p>With this base configuration in place, you can start to experiment with other configuration options, set up more advanced options like authentication, and maybe achieve inner peace...or inner peaches.</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=TOP">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
        <a href="https://wiki.asterisk.org/wiki/display/TOP/Hello+World+-+Asterisk+SCF+Style">View Online</a>
        |
        <a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=19007195&revisedVersion=11&originalVersion=10">View Changes</a>
                |
        <a href="https://wiki.asterisk.org/wiki/display/TOP/Hello+World+-+Asterisk+SCF+Style?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>