Monthly Archives: May 2013

How to calculate the current Stardate in C#

Recently, one of our developers needed to calculate the Stardate using C#.NET.  After much internal mental gymnastics regarding TOS, TNG, and newer calculations, the following code was produced:

string stardate = DateTime.Now.Year.ToString() + “.” + ((int)(DateTime.Now.DayOfYear / 3.65F)).ToString();

The developer was immediately harangued about inconsistent time zone support.  Of course, we are not exactly sure how time zones work in outer space….

…and management wants to know which customer CR this line of code now belongs to.

Avast! Small Office Administration / End Point Protection Suite and real-time alerts and notifications

The Avast! Small Office Administration console provides a rich set of reporting options which can be generated automagically at designated time and days.  This is a nice tool for reviewing your network infrastructure… but what if you want to know about infections *right now*?


Fear not!  immediate notifications and alerts are supported.  The configuration, however, is somewhat hidden.

Setting up real-time alerts

  1. Open Avast! Small Office Administration console via your favorite web browser
  2. Open Network in Group View
  3. Select the group you want to activate real-time notifications and alerts on
  4. Click Edit Group Settings
  5. Click Expert Settings at the bottom of the available options list (left side of the Edit dialog)
  6. Click the I’ll take the risk, show the expert settings button
  7. Find and modify the following settings:

Property Path Value
avastcfg://avast5/Common/NetAlert E-Mail address to receive the alerts
avastcfg://avast5/Communications/SMTPAuth set to 1 if your SMTP server requires authentication
avastcfg://avast5/Communications/SMTPFrom The From: e-mail address.
Something like “donotreply@yourdomain”
avastcfg://avast5/Communications/SMTPPort Usually 25, but configure as needed
avastcfg://avast5/Communications/SMTPServer The UNC or IP of your SMTP server
avastcfg://avast5/Communications/SMTPUserName Username. Must set SMTPAuth to 1
avastcfg://avast5/Communications/SMTPPassword Password. Must set SMTPAuth to 1

Using FreeSWITCH as a TCP/UDP bridge for Lync

In our Lync lab, we are always running into scenarios where we would like to test various functionality against known VOIP providers and equipment.  This usually results in an increased levels of frustration as Lync does not play well in the land of UDP SIP.  Enter FreeSWITCH.
Over the past two years, we have cooked up several FreeSWITCH configurations which support:

  • UDP to TCP bridging which allows Lync to work with VOIP providers such as FlowRoute and PBXs such as 3CX.
  • Full NAT support for those times when you just have to be behind a firewall.
  • Much better support for direct inbound (private) phone numbers into a Lync system using extensions.
  • Support for non-Lync conference phones such as the Polycom IP 6000.
  • Support for Lync 2010 as well as Lync 2013!

The configurations documented in this article are non-standard and, as such, are not supported by any of the vendors referenced within.  These configurations are designed in, and for a test environment.  Utilizing these configurations in a production environment will be undertaken at your own risk.
(OK, with that out of the way, on to the configurations)

IMPORTANT:  It is recommend you read and understand this entire blog entry before making configuration changes… it’ll make your life much easier.

Article Assumptions about Lync Versions
Lync 2010, 2013, Enterprise, and standard, oh my!
For brevity, this article was written using screen shots of a Lync 2013 Standard Edition install.  Most configuration instructions will directly apply to Enterprise Editions as well as Lync 2010 with some minor tweaking.


  1. A functioning install of Lync front end server
  2. A DNS entry pointing to the location running FreeSWITCH
    NOTE: In this article, the DNS entry is FREESWITCH.MYCOMPANY.COM
  3. Coffee or your caffeine of choice.

Configuring Lync Topology

  1. Launch Lync Server Topology Builder and load the current topology.
  2. Drill down to Mediation pools and highlight the mediation pool which will service outbound calls.
  3. Check the Enable TCP port and verify the TCP port range is set to 5068 – 5068image
  4. Close the dialog
  5. Drill down to Shared Components –> PSTN gateways
  6. Right click on PSTN gateways and select New IP/PSTN Gateway from the menuimage
  7. At Define the PSTN Gateway FQDN, enter your FreeSWITCH DNS entry
  8. At Define the IP address, take the defaults
  9. At Define the root trunk, make the following changes:
    Set the SIP Transport Protocol to TCP
    Set the Listening port for IP/PSTN gateway to 5060
    Set the Associated Mediation Server port to 5068 (it should already be set, but check it)image
  10. Publish your topology


Configure Lync Voice Routing

  1. Launch the Lync configuration web page and select Voice Routingimage
  2. Click Trunk Configuration, double click the Global record
  3. Set the following details for the trunk configuration
    Encryption support level to Not Supported
    Refer support to None
    Uncheck Enable media bypass
    Check Centralized media processing
    Uncheck all others.
  4. Click OK to save the trunk configuration
  5. Create PSTN routes to your preferences
    See for complete details


Configure FreeSWITCH

  1. Install FreeSWITCH using the Complete / Full option
    IMPORTANT: Be sure to install FreeSWITCH on the server pointed to by your DNS entry!
  2. Locate the \conf directory under the FreeSWITCH install and delete ALL the files
  3. Download the FreeSWITCH XML configuration file
    Configuration file (.ZIP’d) is available at
  4. Modify the FreeSWITCH configuration file to meet your needs and copy it into the \conf directory
    See FreeSWITCH Configuration XML below for more details
  5. Locate the FreeSWITCH Multi Protocol Switch service and set the service to Startup type of Automatic

FreeSWITCH Configuration XML

Include Section

  • published-name=SIPGateway
    This defines the name FreeSWITCH will respond with during SIP communication.
    Can be set to any value you desire
  • inbound-sip-port=6000
    The inbound SIP port used by external VOIP traffic.
    Make sure you configure you VOIP provider to communicate with FreeSWITCH using this port.
  • outbound-sip-port=5060
    The port used by your internal Lync and VOIP devices.
  • codec-prefs
    The default codec preferences for FreeSWITCH
  • internal-ip
    The internal IP for your FreeSWITCH server.
    Under a NAT/Firewall scenario, this will usually be a non-routable IP such at
  • external-ip
    The external IP address exposed outside your firewall


Inbound Gateway Profile
See <profile name=”Inbound”>

  • username=none
    Lync does not support user name registration.  Leave as none
  • password=none
    Lync does not support user name registration. Leave as none
  • proxy
    Set to the IP address and port of your Lync server.  I.E.


Outbound Gateway Profile
See <profile name=”Inbound”>

  • username=none
    Username provided by your VOIP provider
  • password=none
    Password provided by your VOIP provider
  • proxy
    IP or URL of your VOIP provider
  • register=true/false
    Set according to your VOIP providers configuration.


Dial Plans
See the .XML file for example inbound and outbound routing.
NOTE: All examples assume Lync is configured with three digit extensions

FreeSWITCH, Lync 2013 and AppFabric
Astute observers will have noticed the inbound (outside your firewall) SIP Port is set to 6000 in the FreeSWITCH configuration file.  This is not by accident.  Lync 2013 uses AppFabric under the hood.   As of this writing of this article, AppFabric will attempt to use several ports between 5060 and 5080.  If FreeSWITCH starts BEFORE Lync, the Lync Server Front-End service will fail to start.  There are two solutions:

Solution #1: Make sure nothing other than Lync’s own services use ports between 5060 and 5080.
This is the solution we selected as it is quick and easy.

Solution #2: Make sure FreeSwitch starts AFTER Lync Server Front-End service has started.


Happy calling!