Monday, January 30, 2012

Windows not syncing with NTP server

NTP (Network Time Protocol) is widely used for computer clock synchronization in  internet. There are various versions of NTP. Latest version as of Jun 2010 is NTPv4 and is well described in RFC5905. NTP4 is modified to accommodate IPv6 and other improvement has been done over NTPv4.

Are you getting 'Peer Unreachable' when you try to syc with NTP server?
Usually there are various reasons behind the problem.

1. Firewall or port filter : Make sure that default UDP port 123 is open. You can test this real quick just by turning off Firewall.

2. Windows Time Service (w32time) not running on the appropriate mode
There are various modes of operation for Windows Time Service as NTP supports several different packet types.
Normally NTP client sends 'client' mode request packets to a NTP server
NTP server responds back with 'server' mode packet with timing information

By default some windows (esp. XP and earlier) sends 'symmetric active' mode packet instead of 'client' mode request packets. 'symmetric active' mode packets is for NTP's peering feature where a pool of computers(peers) are configured to sync their clocks among each others to agree upon a common 'network time', which then can be supplied to the client.

Usually NTP server drops 'symmetric active' mode packets, unless it is told to do so.

Q: How can I switch to 'client' mode of Windows Time Service?

Ans: You have to change the Windows registry and it can be done easily via command line

 w32tm  /config  /manualpeerlist:ntp.myserver.com,0x8  /syncfromflags:MANUAL

Here, ntp.myserver.com is my NTP server

The valid settings for the mode used with the /manualpeerlist switch include the following:
  • 0x01 - use special poll interval SpecialInterval
  • 0x02 - UseAsFallbackOnly
  • 0x04 - send request as SymmetricActive mode
  • 0x08 - send request as Client mode
The mode that Windows Time uses to send requests is set by the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer

0x8  enables 'client' mode for Windows Time Service
syncfromflags:MANUAL  forces Windows Time Service to use manualpeerlist for the time query. 

Make changes effective immediately
w32tm  /config  /update

To resync manually
w32tm /resync


Additional Tips: 
If you want to sync with time server everyday, you can create a new 'Scheduled Task' under Control Panel --> Scheduled Task to run  'w32tm  /resync' everyday at your specified time.

Good Luck!

Friday, January 20, 2012

Integrate Asterisk with SIP enabled Wireless phone: Polycom SpectraLink 8030

If you are looking for SIP and 802.11a/b/g compatible wireless phone, SpectraLink 8030 can be one of your choices. It is compatible with Asterisk.  It has also Push-To-Talk (PTT) functionality that allows group communication just like Walky Talky.

Product information of SpectraLink 8030 can be found at
http://www.polycom.com/products/voice/wireless_solutions/wifi_communications/handsets/spectralink_8030_wireless.html

Software and documents for SpectraLink 8030 can be downloaded from following link from Polycom
http://support.polycom.com/PolycomService/support/us/support/voice/wi-fi/spectralink_8030_wireless.html

If you are using Polycom SpectraLink VIEW certified Wireless Access Point, you can call 1-800-Polycom and get the support. If not, there is no luck to get any kind of support from them.

In my case, we have
  • DHCP , DNS, NTP and TFTP server running on Linux
  • Xirrus Array - XN4, XN8   (Make sure your wireless AP supports WMM- Wi-Fi Multimedia; sometime you might have to upgrade to the latest firmware. Contact your  Wireless AP vendor if your AP doesn't have WMM enabled)
  • Asterisk Server (SIP server + PBX) : IP address 192.168.1.10
  • SpectraLink 8030 ( one has an extension 2000 and other has an extension 3000)
  • Voicemail (Extension 2100)
In this article, I am not going to show you how to configure DHCP, DNS, NTP, TFTP server. If you need any help, contact your Server Administrator or look for online help.

Step1: Publish the required firmwares and configs to  TFTP server
Download SIP software of SpectraLink 8030 from above link  
Unzip it and publish the content to TFTP server

You will see various .bin files and .cfg files.

In my case, I have following files
#tftpshare
 MIBs
 pd14csi.bin
 pd14odsi.bin
 pd14shim.bin
 pd14shsi.bin
 pd14udsi.bin
 pi1400si.bin
settings.txt
slnk_cfg.cfg
sip_allusers.cfg
sip_2000.cfg
sip_3000.cfg

You don't have to touch .bin files.  You don't even have to touch slnk_cfg.cfg file

All you need to do is edit sip_allusers.cfg and create the config files for individual extensions (in my case I have two SpectraLink. I want to extensions: 2000 and 3000)


#vi sip_allusers.cfg
#--------Configuration for Asterisk based system-------------
PROXY1_TYPE            = Asterisk
PROXY1_ADDR            = 192.168.1.10:5060  #IP address of Asterisk Server
PROXY1_KEYPRESS_2833   = enable
PROXY1_KEYPRESS_INFO   = disable
PROXY1_HOLD_IP0        = disable
PROXY1_PRACK           = enable
PROXY1_REREG_SECS      = 3600
PROXY1_KEEPALIVE_SECS  = 14
PROXY1_CALLID_PER_LINE = disable
PROXY1_MAIL_ACCESS     = 2100



Create a config file for an extension 2000
#vi sip_2000.cfg
LINE1         = 2000
LINE1_PROXY   = 1
LINE1_CALLID  = Spectralink x2000
LINE1_AUTH    = 2000; myp@ssw0rd


#Note- Password follows extension in LINE1_AUTH line


Similarly create a config file for an extension 3000

#vi sip_3000.cfg
LINE1         = 3000
LINE1_PROXY   = 1
LINE1_CALLID  = Spectralink x3000
LINE1_AUTH    = 3000; myp@ssw0rd

#Note- Password follows extension in LINE1_AUTH line


Step2: Configure Asterisk Server

Spectralink 8030 wouldn't register to Asterisk server. I have to go thru' rigorous troubleshooting before I could figure out the fact that SpectraLink 8030's latest SIP software is still based on the original SIP RFC 2543. [ Polycom support didn't want to talk about anything as I wasn't using their VIEW certified AP. ]

[Please read about fundamental SIP request header if you haven't done so far]

However Asterisk is designed on the basis of latest SIP RFC 3261. Asterisk server drops the REGISTER request coming from SpectraLink 8030 because as per RFC 2543 standard SpectraLink doesn't send tag id in SIP REQUEST FROM header.

Thus you have to tell Asterisk to ignore the tags in SIP request headers. You can do that by using global option in sip.conf

Asterisk 1.8 has pedantic=yes by default

;pedantic=yes ; Enable checking of tags in headers,
                                ; international character conversions in URIs
                                ; and multiline formatted headers for strict
                                ; SIP compatibility (defaults to "yes")


You have to use   pedantic=no  for SpectraLink 8030 to work with Asterisk


#vi sip.conf
[general]
bindport=5060
bindaddr=192.168.1.10
canreinvite=no
dtmfmode=auto
pedantic=no

 [2000]
type=friend
host=dynamic
context=YourContextinDialplan
username=2000
callerid="Dave One" <2000>
secret=myp@ssw0rd
mailbox=2000

 [3000]
type=friend
host=dynamic
context=YourContextinDialplan
username=3000
callerid="John One" <3000>
secret=myp@ssw0rd
mailbox=3000




Step3: Configure AP 
Different APs have different tools for wireless configuration. Make sure you are using 802.11a/b/g wireless APs. AP must be configured as WMM-PowerSave. Please go thru' the product guide that came along with your AP to enable WMM-PowerSave.

Create a SSID for your voice network. [You many not want to broadcast this SSID to minimize easy access to SSID by intruders]

You can use any kind of encryption you want to. I prefer WPA2 as it uses Pre-Shared Key(PSK) and it allows user to manually enter keys to initiate WPA security.

Example: 
SSID: spectralinknetwork
WPA2 passphrase: myp@ssword

Make sure various Radio bands are available  for use. I have enabled a/g band and I am going to use '802.11a standard'  for my SpectraLink phones. 

BONUS INFORMATION: Brief introduction on various wireless standards:
  • 802.11a standard operates in 5GHz band with maximum data rate of 54Mbps. It's range is lower than the range of 802.11b but offers higher number of channels and also higher data rate.
  • 802.11b standard operates in 2.4GHz band with maximum data rate of 11Mbps. It's range is higher range than 802.11a but it suffers interference from other devices like Bluetooth, cordless telephonesc etc operating at 2.4 GHz. Data rate offered is less than 802.11a.
  • 802.11g standard operates in 2.4GHz just like 802.11b, but operates at maximum data rate of 54Mbps. 
  • 802.11n standard operates in 5GHz and/or 2.4GHz using MIMO technology. 



Step4: Use SIP HAT(Handset Administration Tool) provided by Polycom to configure the initial configuration for SpectraLink 8030. You can download SIP HAT from above provided link 





Network Configuration of SpectraLink via SIP HAT Tool
  • Enable DHCP
  • Use SSID:spectralinknetwork  and WPA2 passphrase: myp@ssword and click on 'Generate PSK from Passphrase + SSID' button
  • Use QoS Type 'Wi-Fi Standard'
  • Admission Control: Optional
  • 802.11 Config: a
  • Enable the bands you want to use





SIP configuration and others via SIP HAT Tool
  • Change the TimeZone as required
  • Enter the SIP username: 3000 and password: myp@ssword
Follow the procedure as per instructed by SIP HAT Software to write the settings to SpectraLink 8030 handset. It might prompt for the password before you can write the settings to the handset. Default password is '123456'. Ignore any minor errors while writing the settings to handset as handset will download the latest firmware from your TFTP server anyway.

 Step5: Powercycle the handset. If your ducks are in row, it will work without hassle. If come across any issues, follow the SpectraLink 8020/8030 Wireless Telephone Administration Guide for SIP.

SpectraLink 8030 displays Startup Sequence: 1 thru' 9.  Let's say your handset is stuck at '1234567', it means it has successfully gone thru '8' and '9', but it is stuck at '7'. If you look on the administrative guide, '1234567' means DHCP response with bad DNS server configuration. So, you have to fix possible DNS/DHCP server issue.


If you need further help, you can email me at erdevendra@gmail.com or simply post the comment.