14 April 2011

It's a kind of magic

There can be only one. But which one?
Photo by Alexander Doljenkov.

15 March 2011

SIP Loop Detection - Part 1: RFC3261 Summary

This post is a short summary based on RFC3261. The goal of this post is to filter RFC content relevant to loop detection prior detailed investigation of looped call behaviour on Cisco gateways.

There are two kinds of "looped" calls described in RFC3261: spiral and loop.
Spiral is not an error. A typical example is call forwarding. Look at the picture, the call was forwarded to bob@example.com. Changed request content (typically, changed Request-URI) is the most important distinguisher of a spiral. The result is different processing decision than the original request.
.                          |=======|                           |=======|
  INVITE joe@example.com   |       |  INVITE joe@example.com   |       |
 ------------------------> | Proxy | ------------------------> |Proxy 2| --|
  INVITE bob@example.com   |       |                           |       |   |
 |-----------------------> |=======|                           |=======|   |
 |                                                                         |
 |-------------------------------------------------------------------------|
Loop is an error. A request that arrives, is forwarded and later comes back. Request-URI and other header fields that affects proxy operation are unchanged, processing decision would be the same. SIP relies on special procedures for loop detection and handling.

28 January 2011

No comments

Dilbert.com

FAQ: 'no ip domain lookup' vs 'transport preferred none'

An easy but a very frequent question: "how to prevent DNS lookup for mistyped IOS commands?"

The frequent answer is: "Yes, it's annoying. Use 'no ip domain lookup' or 'transport preferred none'"
But be careful! Both command will work. Still 'no ip domain lookup' turns off DNS. Usually it's not a good idea for production router. Just imagine, what if you'll have to use 'ping cisco.com' urgently? =)

On the other side 'transport preferred none' prevents your router from session spawn to 'dfgfsdg' or 'x.x.x.x' without 'telnet' or 'ssh' keywords. But you'll be able to use 'ping cisco.com'.

So the right answer is: "Use 'transport preferred none'. And please forget about 'no ip domain lookup'!"

PS: Do not confuse 'no ip domain lookup' global configuration mode command and 'no domain-lookup' line configuration command. The latter will not stop DNS resolution for all commands, only for show output, traceroute, etc.

06 January 2011

Tetrios - tetris for Cisco routers

IMPORTANT NOTE: Please, do not play Tetrios on production routers. It is possible that router will stop responding in case of incompatible IOS release. Also I assume that if you want to play Tetrios your Tcl skills are sufficient to fix some minor bugs without assistance.

Tetrios is a text based tetris with Tcl code adopted for Cisco IOS. Actually, it is side effect of learning Tcl on New Year holidays. It is very simple, especially if you are able to imagine tetris game like a string. =)

Tetrios code strictly follows 'everything is a string' concept. Another goal was to keep it readable for learning and future modification. I do not pretend that it is optimal. I don't even know tetris algorithm. It is just a result of few days of coding and testing ideas and reading Tcl man. This code was born in my head from the beginning to the end. Hope, it's not bad for a network engineer.

I want to thank Ivan Pepelnjak. His blog is a great source of IOS Tcl tricks. Actually, the first problem with tetris for Cisco routers was that IOS read calls always block for console or vty lines. That's the reason why you can't play Tetrios directly from IOS console and have to use network connection. Also, event loop works very unusual for Cisco IOS, even if we consider all restrictions mentioned on CCO.

Here is a small instruction for Tetrios players:
1) use 'exec-timeout 0' command for those lines, that'll be used by Tcl interpreter
2) adjust delay variable to reduce or increase tetrominoes falling speed; depending on IOS release add or remove 'update' after 'fileevent' in TSERV procedure
3) copy Tetrios code to router flash or some network location as tetrios.tcl
4) enter 'tclsh [tetrios location]/tetrios.tcl' command
5) connect to Tetrios server TCP port (1111 by default):
It is possible that I'll implement a subset of telnet server functionality in future. But currently you have to use raw mode.
6) Enjoy! =)
7) Use 'Ctrl+C' to stop the script. Problems with script termination can arise in some IOS releases. Try to add/remove 'update' after 'fileevent' or use another release.

One of Tetrios cool features is the possibility to log the whole game to a text file from Putty. =)

P.S.: Tetrios is very slow on GNS. It's a little bit faster on real routers. Also, Tetrios works perfectly with ActiveTcl.
P.P.S.: Code still contains some bugs (some problems with boundary check while rotating or shifting tetromino). If you'll play carefully, you should never find them out. May be I'll fix them later. But if you've found a bug with a solution - please post it in comments.

Supported IOS releases (updated):
+ 12.4(15)T8 - version 1.1 tested, works perfectly
+ 15.0(1)M - version 1.1 tested, works perfectly
+ 12.4(24)T - use version 1.0, or remove 'update' after fileevent (looks like a bug)

IOS releases not supported currently:
- 12.4(15)T7 - version 1.1 works, but problems with script termination arise

The code is here temporarily:
Tetrios code on ieoc.com
Tetrios version 1.1 code ('update' after 'fileevent', minor rotation bug fixed)
I hope, it's not a significant fault to use ineoc.com as a storage for a small text file.

And here is a screenshot:

01 November 2010

How to force G.711 for ephone with virtual voice gateway

NOTE! This is the second, updated version of this post. Some minor bugs still exist, but easy to fix. I do not recommend to deploy this configuration on production routers, only if it is your last option.

The best cisco-breeders state: use G.711 for local calls and some narrowband codec (like G.729) for remote calls. That is clear. But what if you have a free voice recording software that supports only G.711 (cause G.729 requires licensing) behind your router with CUCME? By default IP Phone will negotiate G.729 to avoid transcoding and save router DSP resources. So we have to force transcoding manually. But it is not so simple as it sounds (that's valid for IOS 12.4 and I don't expect significant change in nearest future).
The problem is clarified in CUCME System Administrator Guide: "Transcoding is enabled only if an H.323 call with a different codec from the remote phone tries to make a call to the remote phone. If a local phone on the same Cisco Unified CME as the remote phone makes a call to remote phone, the local phone is forced to change its codec to G.729 instead of using transcoding". The same is valid for SIP. It seems to be unsupported. But that doesn't mean it is not possible. There is one mad feature that can be useful in some cases. That is tunnel interface with source and destination on the same router. Yes, it works. And we'll use it to force transcoding by hair-pinning SIP and RTP sessions. Lets examine simple lab topology: