Jelajahi Sumber

tmemo separated from sip_router

Jiri Kuthan 22 tahun lalu
induk
melakukan
3fbc410777

+ 0 - 19
doc/tmemo/README

@@ -1,19 +0,0 @@
-This directory contains short technical memos documenting 
-operational practices and technical decisions made or proposed
-for ser or accompanying applications. The memos serve as 
-requests for comments in the literal sense (not to be confused
-with IETF's RFCs).
-
-The documents here are drafts, for whose technical maturity
-no guarantee can be provided.  They may advocate non-workable
-design ideas, frequently change, or be replaced by better
-technology suggestions. They may or may not be implemented.
-
-The memo texts follows IETF traditions: they are encoded
-in plain ASCII. Their filenames consists of
- - tmemo (=technical memo -- to avoid confusion with IETF prefixes)
- - author id
- - text id
-For example: tmemo-johndoe-backtobackua.txt
-No version numbers are used in filename -- these are displayed 
-in text and assigned by CVS server. 

+ 0 - 182
doc/tmemo/tmemo-jiri-b2bua.txt

@@ -1,182 +0,0 @@
-$Id$
-
-Draft Design Options for Building Prepaid Scenarios Using SIP/SER
-==================================================================
-
-Jiri Kuthan, iptel.org, January 2003
-
-Abstract
---------
-Prepaid scenarios for making calls to PSTN gateways require the 
-ability to terminate an exising call when user's credit is 
-exhausted. Though it seems appropriate to implement such 
-a feature in the device providing the service (i.e., in the gateway),
-we are currently not aware of such gateways. We thus first
-recommend a session-timer based approach which possibly works,
-and requires limited support in end-devices (session-timer)
-and proxy servers (session-timer and call length determination).
-We then discuss another alternative, based on a B2BUA middlebox,
-which works even with the dumbest PSTN gateways but puts
-a considerable workload on SIP server.
-
-TOC
----
-Section 1 explains design alternatives which can be made when
-designed a "forced" call termination (FCT). The design alternatives
-are FCT support in end-devices (nice, but not doable with current 
-gateways), FCT support using session-timer (nice, hopefuly doable, 
-requires session-timer support) and FCT using a B2BUA (ugly
-and costly, but best backwards-compatible).
-
-Section 2 details known drawbacks of the B2BUA technology.
-
-Preliminary hints how to implement the B2BUA using ser,
-which has no B2BUA support, are detailed in section 3.
-
-1. How To Terminate a Call When No Money Is Left
---------------------------------------------------
-
-In general, there are many ways to implement a service operator
-driven call cut-off. We argue, that architecturally best acceptable
-place for this functionality is in the terminating PSTN end-device.
-The device already keeps session state, it knows too when things
-go wrong on the PSTN site, it is able to detect caller's media
-inactivity -- it is simply full in control of the call. Thus it
-seems an ideal place for implementing a call termination functionality.
-No other element in the network knows all the things the end-device 
-knows. 
-
-The missing piece is then the ability to determine maximum call
-duration. A consequent application of the approach of placing the
-logic in end-device would make the gateway query some database.
-(It is of limited use to include this information directly in
-in gateway, as multiple devices may want to share this piece of
-information.) However support of such a "query-credit" protocol
-does not exist in PSTN gateways. Other solutions are thus sought.
-
-One way to make the gateway aware of the maximum call duration is
-to determine it in a proxy server (which typically has programming
-capabilities that allow doing so) and propagating it to gateways 
-using SIP session timer. 
-  http://www.iptel.org/ietf/callsignalling/#draft-ietf-sip-session-timer
-This solution is scalable in that the element determining the maximum
-call length is a proxy server, which is at most transactionally
-stateful. No call state needs is maintained except in the
-end-devices. 
-
-The behaviour of the session-timer-based construct is as follows:
-a caller intiates a call through a proxy server. The proxy server
-determines maximum acceptable call length and inidiacates it using
-the session timer mechanisms. The timer is then propagated to
-the end-device using SIP. If it actually hits, the terminating 
-gateway will try to revitalize the session using a re-INVITE. 
-The proxy server then can recalculate available credit, and if too 
-low, deny the re-invitation. The end-device is then supposed 
-to terminate the call using a BYE.
-
-  Note: a similar technique can be used to keep firewall
-  pinholes alive.
-
-We have never experimented with the session-timer-based solution.
-We do not know if some session timer negotiation troubles can
-occur. We do not know how widely support of session timer is
-deployed in gateways. We do not know whether the standardization
-effort for session-timer will result in some changes and when
-it will complete. Nevertheless, we think it is worth trying.
-Its appeal is it leaves call-termination, a call-stateful
-feature, down in the end-devices and does not pose too big
-burden on server developers and especially operators. The
-scenario is mentioned in [ccframework], section 7.2.12.
-
-WE THUS ENCOURAGE VOLUNTEERS TO EXPERIMENT WITH THIS OPTION.
-TAKE THE GATEWAY YOU HAVE, LOOK AT IT IF IT SUPPORTS ST,
-ADD ST TO SER PROXY AND CHECK IF THINGS WORK.
-
-If end-devices do not make the job of call cut-off well, someone
-else, a third-party, will have to. That is where B2BUA comes
-in. It is a singaling entity that terminates signaling dialog
-with both call parties and keeps dialog state during the whole
-conversation time. Acting as a UA allows it to generate SIP
-messages on its own (as opposed to just realying someone 
-else's messages, as proxy do). Because it appears as a simple
-UA to each party in the call, it works with any phone without
-need for support for any extensions. Problems with use of
-B2BUA are described in the next section.
-
-One could perhaps make the cut-off component easier to
-implement than a whole B2BUA. Well, as long as the implementation
-is expected to be 100% conform, there is no way around it.
-The BYE initiator needs to be aware of current dialog state,
-it will not be able to do its job otherwise. Obvisouly,
-it needs to remember initial constant information such as
-call-id. However, it needs to keep information that changes
-too. Particularly, it must know current CSeq -- Cseq gets
-updated with in-dialog transactions and failure to send
-a proper CSeq would result in denied BYE. An implementer
-wishing to make his life easier and avoid the B2BUA
-machinery could feel tempted just to "spoof" dialog state
-in a proxy, (i.e., not to translate one into another one) and
-if it decides to cut-off, send a BYE using the current
-status. That introduced race conditions, however, as
-another transaction may show up in middle of the cut-off
-process, increase remote party's CSeq and disqualify the
-delayed cut-off BYE.
-
-So design choices are either B2BUA, or a "dialog spoofer"
-with a risk of race conditions.
-
-2. What Are B2BUA limitations?
-------------------------------
-B2BUA features all drawbacks of a centralized solution. Whereas
-B2BUAs are applicable in the prepaid scenarios one should not
-forget the price.
-
-a) it is a single point of failure. When in the middle of
-   a conversation additional sigaling occurs and the B2BUA
-   is down, signaling will fail. (Doesn't happen if signaling
-   runs only between end-points.) Call persistency must be
-   implemented, signaling will otherwise fail on server
-   reboot.
-b) scalability issues: a B2BUA needs to keep state for two
-   calls for the whole duration of a conversation. That might
-   be an issue with too heavy traffic. Transaction state
-   takes 3k per transaction and lasts seconds. Call state
-   consumes at least twice so much and lasts minutes.
-c) e2e security does not work -- implementations willing to
-   achieve high security will want to encrypt and sign
-   SIP message bodies. B2BUA breaks the e2e security if
-   it needs to change the body.
-d) economical aspects: it is simply yet another piece of
-   non-trivial software you need to purchase or develop and
-   operate. that's maybe the strongest argument: it is
-   expensive.
-
-Lot of this conversation has taken place on IETF SIP
-and SIPPING mailing lists. Few messages from these
-discussions are referred from  
-   http://www.iptel.org/info/trends/#b2bua
-
-3. How to Implement a B2BUA Using ser
--------------------------------------
-
-One of the design decisions is whether to make B2BUA work
-as a module or an external application bound to ser via some
-of its interfaces. 
-
-You will have to keep dialog table keyed by callid and tags,
-update it on INVITE complition, remove on BYE, updated on
-e.g. INFO changing dialog state.
-
-The cut-off timer needs to be started too.
-
-Also note, that these scenarios are based only on signaling -- there
-are no PSTN-prepaid-style anouncement "you can call 5 minutes"
-and "your call will be cut off in 20 seconds". It is doable too,
-but it is probably more meaningful to start with the signaling.
-See [tmemo_media] for more on that.
-
-Appendix: References
---------------------
-[ccframework] http://www.iptel.org/ietf/callprocessing/#draft-ietf-sipping-cc-framework
-
-

+ 0 - 498
doc/tmemo/tmemo-jiri-media.txt

@@ -1,498 +0,0 @@
-$Id$
-
-
-Draft Distributed Media Server Architecture
-===========================================
-
-Jiri Kuthan, iptel.org, January 2003
-
-
-Abstract
---------
-
-We describe design considerations made when expanding voicemail 
-application to a more general media server. The objective of
-media server is to bind voice to SIP applications with optional
-support of other tools (SIP SUB/NOT, mysql, TTS, etc.) It has
-to be configurable in such a way it can act in different component
-roles: click-to-dial server, voicemail server, conferencing server, 
-text-to-speech anouncement server, etc. (see [ccframework] for
-a longer listing of related applications)
-
-TOC
----
-
-Section 1, Scenarios and Component Models, explains background 
-assumptions on how services can be composed using Rosenberg-advocated 
-model. This section is essential to understanding how a media
-server can be plugged-in in a SIP network consisting of multiple
-components, each delivering a part of a complex service. The section 
-also suggests a decentralized architectural improvement for connecting 
-SIP components without a need for a B2BUA, a technology we consider 
-suboptimal.  (This network architecture puts only very little addition
-requirements on the media server.)
-
-Note that this section tends to focus on specific design choices.
-A nice review of the whole spolution space for composing services
-is provided by Mahy at al in [ccframework]. This document is 
-referred to many times throughout this memo -- it is a really
-nice piece of work. 
-
-Section 2, Media Server Requirements, explains basic requirements
-a media server needs to fulful to make a good job in the component
-architecture. Design ideas for server's key part, a programming
-script, are explained in section 3.
-
-Related work, references and example scripts are attached in
-appendices.
-
-1) Targeted Scenarios and Component Model
---------------------------------------
-Many application scenarios can provide a pleasant experience to users 
-when users are played explanatory messages or users' voice feedback 
-can affect service logic. That is what media servers are basically
-good for. The whole service logic may be complex and composed of multiple 
-stages (initial anouncement, PIN verification, text-to-speech) which 
-form together a longer conversation. The individual stages may be 
-implemented as parts of a single media server or distributed accross 
-specialized (or specially configured instances of the same) media servers.
-
-Examples of such multi-stage conversations are voicemail, conferencing, 
-click-to-dial, and prepaid calls. Some of these scenarios have been 
-addressed in J. Rosenberg's disseration and an almost identical Internet 
-Draft co-authored by P. Mataga [components]. (See also [featureinteraction]). 
-They proposed a component model, in which a B2BUA faces a caller on its 
-UAS part, and connects to different SIP devices on its UAC part. This 
-B2BUA, so-call call controller, acts as a glue: it connects all possible 
-SIP-enabled application components together. It maintains a "service 
-state machines" which defines how to link components with each other 
-as a session proceeds. It uses HTTP as a complementary protocol for 
-the components to report on their progress to the controller. For example, 
-the controller may first connect on caller's behalf to a "pre-paid prompt 
-component", which queries user's PIN and reports it to the controller. 
-On success, the controller can then hand-off the call to a PSTN gateway.
-
-This architecture is extremelly good in that it introduces distributed 
-components. Decomposition, an imporant design principle, is performed 
-in a fair, peer-2-peer manner that allows linking SIP devices in
-a very flexible way. No additional mechanisms (except perhaps HTTP
-reporting) like CTI are needed -- SIP is the service glue.
-
-The biggest shortcoming of this architecture is imho its central piece, 
-the controller. It is simply too central. A B2BUA design  inherently causes 
-many concerns: security, scalability, and reliability ones. B2BUA solutions 
-proposed in 3pcc draft [3pcc] by Rosenberg have several signaling drawbacks 
-too: tricky media matching (flow III), backwards compatibility
-(flow IV), etc. There is also the economical aspect, which is possibly
-the biggest one: a B2BUA costs money or development effort, and the
-aforementioned issues cost more operational overhead too.
-
-We believe it is beneficial to avoid such B2BUA constructs. The mechanism
-we are advocating is distributing the service state machine accross 
-participating components. With such a scheme, it is the current component
-that decides what to do next, i.e., when to proceed to which next component.
-A caller contacts an initial component (say a PIN prompting media server) 
-identified by an URI, which is in fact an identifier of the initial service 
-state. An initial conversation is carried out then ("give me your PIN: 
-1-2-3-4"). The component collects the PIN and when finished, it passes 
-over to the next component. There is a choice to verify the PIN in the 
-first component and pass over the final authorization status ("no" or 
-"yes" or "yes but no longer than 5 mintues call") or to pass the PIN 
-and leave its authorization to the next component. 
-
-This construct is more distributed: the controller permanently involved
-in caller's conversation is gone. It is always the current component
-that decides what to do next. There are alway only two parties in 
-a relationship: caller and the current component. "middlebox" B2BUA
-is away.
-
-Another benefit of this more e2e-oriented approach is a better way
-of dealing with caller's preferences. Caller preferences are about the 
-ability to gain user's consent with transitions in conversation -- e.g., 
-is it acceptable for a caller to be transferred to a CIA server? With
-the REFER approach, all transition decisions are actually made
-by client, which is good. Other solutions, in which a downstream
-entity decides on caller's behalf are imho too limiting. They
-require the caller to upload his preferences in a standardized
-format to the upstream client. As the preference space is almost
-infinitely big, the way of standardizing caller's preferences does
-not seem too beneficial to us. There may be always some preferences,
-which the preference format does not capture. Make it simple and
-allow caller to decide on his own behalf. He is responsible, know
-what he wants and possibly does not trust the upstream client
-to interpret his preferences as desired.
-
-Mechanically, the transition to the next component can be easily
-achieved using REFER[refer]. When current component completes, it hints
-caller to proceed to the next one using REFER. The URI in Refer-To 
-represents the next component (a PSTN proxy) as well as some
-service attributes ("pin ok, 5 minutes permitted") with which
-the component can begin. When like in this case the URI carries
-security-sensitive information, the information may be encrypted
-or a message integrity check may be attached. Note that this mechanism
-eliminates a need for the "HTTP reporting hack" in jdr's architecture. 
-Session status is reported in SIP URIs. Cooperating components just 
-need to agree on a scheme for URI usage. That should be easy for SIP 
-servers as URI processing is a primary SIP ability.
-(A similar proposal for such use of URIs was stated in [msuri]
- and [ccframework].)
-
-A simple application of this more distributed approach is REFER-based 
-"click-to-dial" service. In this scenario, a media component gets somehow 
-instructed to initiate a call. It first calls the first party, optionaly 
-plays a short anouncement ("you will be transfered now") and than transfers 
-this initial call to the other call party. It then completely disappers
-from sebsequent conversation.
-
-The "pre-paid verification component" referred to in this section is another 
-example use of this model. It establishes a call with caller, looks at 
-desired destination, processes PIN in media stream, and makes a decision 
-to hand-over to a gateway. It than disappears from the conversation.
-(See the [b2bua] tmemo for how to implement call cut-off, a feature
- esential to operation of prepaid scenarios. the memo explains how
- to achieve cut-off without a B2BUA.)
-
-Note that the application call-control framework [ccframework] by Mahy et al. 
-explicitely mentions a more peer-2-peer oriented approach based on REFER as 
-a good alternative to a centralized B2BUA approach and gives some more
-details.
-
-  Quicknote: this multi-stage conversation model based on REFER use has
-  some appeals for charging too -- in case separate stages need to be
-  charged in a different manner (like initial anouncement "this
-  800 number is free only from US" for free, and then the real
-  IVR for whatever charges apply). It clearly separates these
-  stages in terms of calls and transactions. We think that is a clean
-  way of doing things as opposed to breaking transaction model
-  by some 18x provisional "half-talk"  constructs. (Which raise
-  unclarity like "is the call established or not", "how long does
-  a proxy server need to keep provisional transactional state",
-  "when should I charge for 18x", and whatsoever.)
-
-
-
-2) Media Server Requirements: Flexibility and Extensibility
------------------------------------------------------------
-
-In all such application scenarios, a media component has a central
-role. It plays anouncements, records messages, and interacts with
-caller via signaling too: it can terminate or transfer a call. 
-
-There are two major requirements on its design to make it useful
-for applications as mentioned above: it needs to be flexible 
-and extensible.
-
-Flexibility is desired to be able to configure the media server
-for its particular purpose without having to rewrite it each time. 
-It should be possible to configure whether on receipt of a 
-specific URI, the server plays or records a message. It should 
-be possible to dictate maximum call length and define what happens 
-when the length timer really strikes:  should the call be transferred 
-to another component (and if so, to which) or simply bye-d? Etc.
-
-We suggest, that like in SER this flexibility is achieved
-by a scripting language (see bellow).
-
-The other requirement is exensibility. The media server scripts
-should be able to leverage other available tools. A particular
-example is coupling of script logic with MySql databases --
-feature that made PHP an ultimate success. In context of the
-previous prepaid examples, it can be used to verify user's PIN and
-maximum possible call length. Text-to-speech software such as
-festival [festival], AT&T's Natural Voices [nv] or CMU
-speech software  [cmuspeech] (!!!) including Sphinx, festvox,
-openvxi are examples of other pieces of work worth intergrating
-with.
-
-Another important example of what should be achievable with
-the externsibility framework is updating SUB/NOT state. Whatever
-the udpate mechanism is, it must be doable to allow things such as 
-message waiting indication [mwi].
-
-3) On Scripting Language
----------------------
-
-scope)
-
-The scripting language should be able to define call processing:
-establish, transfer, terminate a call, provide media processing
-and use external libraries (php, tts, etc.) in an extensible manner.
-It should stay open to integration with Internet services and
-allow things like HTTP queries or SIP instant messaging.
-
-call/transaction abstractions)
-
-The language should hide well protocols detail to make programming
-easy. While access to lower-level features should not be precluded, 
-abstraction and simplicity are the key for application programming. 
-
-The primary living space of the media server programming language
-should be calls. Scripts should be able to deal with calls:
-initiate, terminate and transfer them. [ccframework] coins
-additional ones: "replace", "join", "fork". It also well explains
-how to compose some well-known services using these features.
-
-An important lower-level escape way should be the ability to initiate
-in-call (in-dialogue) transaction. That is what allows the server
-to go beyond simple VoIP/media services. An example of use of
-such an ability would be sending notifications on some events
-(like when a new party joins a multi-party call conference)
-or subscribing to some call-related events:
-  ret=$call.new_transaction("INFO", 
-     "headerfield: value\n\hf2: ".$some_var."\n", "two USD");
-
-
-events)
-
-All of us have agreed that event-oriented approach is a good
-abstraction. The event system should be very universal and
-accept events from a variety of sources in a unified manner.
-The sources include but are not limited to SIP messsages, timers 
-(so that for example voicemail app can set the longest possible 
-recording), external events from local apps (perhaps via FIFO), 
-media events (DTMF), SIP notifications.
-
-The SIP notifications should be easy to map to the the event
-system. Scripts can subscribe to event, and when they occur,
-SIP NOTIFIes are translates to the script's event system.
-It can be used for implementing things such as "retry
-when a user is no longer busy" [dialogpackage], or keep
-updated on list of participants in a conversation.
-
-I think a great simplification of event processing is to guarantee their 
-processing in series. It avoids all sorts of nasty issues which pop up 
-when events related to a call are processed in parallel. The synchronization 
-issues will reduce to event queue maintenance and execution logic will be 
-easier to understand. I think we can happily trade it for some - probably 
-marginal - performance decrease.
-
-That would imply an event queue associated with each call. Its filled in from 
-all sort of event sources (Web, FIFO, media, timers, etc.). Events are picked 
-up from the queue in order of arrival. On call termination, the queue is 
-destroyed, empty or not.
-
-A question is how to deal with some long jobs -- such as recording or playing
-media. Waiting until they complete may take infinitely, and result in blocking
-such event like incoming BYE, which should actually stop a recording.
-
-I suggest that well-known long jobs, such as playing or recording
-are simply sent to background and then script processing continues.
-The question is what qualifies as "long job" -- I think quite few
-things which may potentially take infinite time. Recording and playing
-are important examples, call set-up (time until callee answers) or
-NOTIFY during call transfer other ones. When such background
-"infinite" jobs complete, user can be notified via the event system.
-
-  An alternative would be to introduce a background operator
-  like & in shells. However I suspect that unwise users could
-  forget to use it and cause infinite blocks. Defining in a 
-  case-by-case way that certain operations are blocking seems
-  safer to me.
-
-
-Most other jobs are transaction-related and are short enough,
-so that processing of other events can wait until they complete.
-BYE/REFERR, whateverver, takes in the worst case of an error
-time until final response timer hits -- delay which should be 
-tolerable to any other signaling. If I for example initate
-an INFO transaction and BYE arrives in the meantime, it is
-imho not so bad to let the BYE wait until INFO completes.
-
-
-requriement summary)
-
-So far, we have identified the following requirements:
-    - programming effectivity (easy and intutitive to use); abstraction
-	  from protocol details, focusing on calls and primitives about
-	  them (initiate, terminate, transfer, perhaps join, fork
-	  and replace too); some simple in-dialog transaction processing
-	  should be an escape for other signaling things
-    - parallelism (mutltiple scripts processed at the same time, 
-      multiple calls refered from a single script)     
-    - variables (refering to multiple calls)
-    - event processing -- ability to map a variety of events
-	  to the event system (SIP NOTIFIes, FIFO requests, 
-	  call-related SIP requests such as INVITE/BYE, timers,
-	  media events, etc.); events processed in series
-    - services described in [ccframework] should be verified
-      to be doable with the language
-    - ability to change script without rebooting the server
-	- uri processing is an absolute must to be able to implement
-	  the component model as described above
-	- textual processing -- one should be able to compose new
-	  transactions out of parts of existing requests (there should 
-	  be some automated request->var casting, e.g., $Request.from) and
-	  dialog state. 
-           ret=$call.new_transaction("INFO", 
-               "headerfield: value\n\hf2: ".$Request.from."\n", "two USD");
-    - extensibility (i.e., the ability of the environment to link 
-      external binary libs and refer to them from scripts); particular
-      items of interest are mysql support, http support, tts,
-	  support for updating SUB/NOT status (such as for [mwi])
-
-Some design options mentioned so far (nice but not required)
-    - have some casting from input to variables (e.g, $request.header.callid)
-    - use OO -- there are many people for whom OO is easier
-    - exceptions to group error processing
-	- variable scope and context -- it would be imho nice if
-	  all variables related to a call would be tightened to
-	  it, so that they are accessible whenever another
-	  call-related event occurs, and they are not accessible
-	  from anywhere else
-
-main-loop language)
-
-We have not made any determination yet on whether to resuse an
-existing scripting language (and bind SIP code or any other code
-to it from C/C++ librariries) or design our own from scratch.
-
-Proponents of language reuse (Python may be a reasonable option)
-are primarily concerned about too much unnecessary development 
-and debugging effort for both the basic language and especially 
-for its extensions.
-
-Opponents were concerned about difficulties with integration of
-the scripting languages with code libraries. Other cons are
-bigger image size and dependency on third-party software.
-However, risks of bugs and unability to tweak things are rather 
-low with well-established open-source software like python.
-
-Also, a new language would have the benefit of making the
-syntax more visibly tied to the semantics model.
-
-As said, no determination has been made yet. Author of this
-memo changes his opinion on this issue in hourly intervals.
-The amount of work to be done with a new language is
-scaring and may become an overkill. On the other hand
-making sure that the language well expresses the
-nature of the server is appealing. Perhaps one could
-reuse some API for linking external libraries like 
-those used in PHP or python, so than getting access to
-the libraries would be easy.
-
-BEFORE ANY DECISION IS MADE, WE SHOULD BEST GO THROUGH
-FEW MORE EXAMPLES ([ccframework]) AND SHOW HOW THEY CAN
-BE ACHIEVED USING THE DESIGNED ENVIRONMENT.
-
-see more )
-
-Appendixes include pseudo-examples of scripts written in such
-languages. (An XML-based language was discussed too, but its
-proponent gave up on it since it was really big and difficult
-to read.)
-
-
-A) Related Work
-------------
-There has been a whole bunch of related work. Traditional IVRs
-were programmable decades ago. Related technologies include 
-[kpml], [mscl]*, [vxml], Cisco's use of TCL [ciscotcl]. 
-[Bayonne] has some too.  snom uses an xml-based language, 
-there is a voicemail system based on JavaScript and NIST SIP stack.
-
-* one of the differences between kpml and mscml is kpml uses HTTP
-  for reporting (similarly to [components]), MSCML uses SIP
-
-
-B) References
-----------
-[3pcc] http://www.iptel.org/ietf/callprocessing/3pcc/#draft-ietf-sipping-3pcc
-[bayonne] http://www.gnu.org/software/bayonne
-[ciscotcl] http://www.cisco.com/univercd/cc/td/doc/product/access/acs_serv/vapp_dev/tclivrv2/chapter1.htm
-[cmuspeech] http://www.speech.cs.cmu.edu/speech/
-[components] http://www.iptel.org/ietf/callprocessing/apps/#draft-rosenberg-sip-app-components-01
-[ccframework] http://www.iptel.org/ietf/callprocessing/#draft-ietf-sipping-cc-framework
-[dialogpackage] http://www.iptel.org/ietf/callprocessing/#draft-ietf-sipping-dialog-package
-[featureinteraction] http://www.iptel.org/ietf/callprocessing/apps/#draft-rosenberg-sipping-app-interaction-framework
-[festival] http://www.cstr.ed.ac.uk/projects/festival
-[mscml] http://www.iptel.org/ietf/callprocessing/apps/#draft-vandyke-mscml
-[msuri] http://www.iptel.org/info/players/ietf/allsipdir/draft-burger-sipping-msuri-01.txt
-[mwi] http://www.iptel.org/info/players/ietf/callprocessing/#draft-ietf-sipping-mwi
-[kpml] http://www.iptel.org/ietf/callprocessing/apps/#draft-burger-sipping-kpml
-[nv] http://www.naturalvoices.att.com/
-[refer] http://www.iptel.org/ietf/callprocessing/refer/#draft-ietf-sip-refer
-        (recently approved by IESG for publication as RFC)
-[vxml] http://www.iptel.org/ietf/callprocessing/apps/#draft-rosenberg-sip-vxml-00
-
-
-C) Appendix: pseudo-scripting language
-------------------------------------
-
-/* voicemail */
-event{new_call}(call $c) {
-   $c.play("welcome"); /* play blocking */
-   new_timer(too_long, 200 sec, $c, terminate_call);
-   $c.record("/var/spool/voicemail/"+$c.callee; /* record non blocking */
-}
-event{eo_call}(call $c) {
-   // do nothing; by default, all what has been started is closed 
-}
-event{too_long}(call $c) {
-   $c.terminate();
-}
-
-/* 3pcc a la call transfer */
-event{click_to_dial} (uri $to, uri $from) {
-    $c=new_call("sip:[email protected]" /*our daemon invites caller */, $from /* caller */);
-    $c.play("you will be transfered now");
-    $c.refer($to); /* refer creates an event ... NOTIFY */
-}
-event{notify}(call $c) {
-    /* great, caller has established conversation with the other party --
-       we can hang-up now */
-    $c.terminate();
-}
-
-
-
-D) Appendix: use of python
------------------------
-
-
-class App(SIPApplication):
-    def doInvite(req):
-        trans = req.transaction()
-dlg = req.dialog()
-app = dlg.application()
-
-if (req.uri().domain() == "voicemail.org"):
-    try:
-        media = req.sdp.negotiate()
-trans.reply(200)
-    except:
-trans.reply(500)
-
-    file = "/home" + req.uri().username() + "/ann.au"
-    if !file.exists():
-    file = "/ann.au"
-    media < file
-
-    file = "/home" + req.uri().username() + "/msg.au"
-    media.maxlength(200) > file
-
-    def doBye(req):
-        trans = req.transaction()
-trans.reply(200)
-req.dialog().media.stop()
-
-    def doHTTP(req):
-try:
-    dlg = placeCall(req.uri1)
-    dlg.media() < tts("just a moment")
-    dlg.refer(req.referto)
-    dlg.application().click = true
-
-except:
-    log "error"
-
-    def doNotify(req):
-        dlg = req.dialog();
-if dlg.application().click:
-    req.transaction.reply(200)
-    dlg.bye()
-else:
-    req.transaction.reply(...)
-
-    def doTimeout(app):
-        dlg = app.dialog("caller")
-        dlg.bye

+ 0 - 231
doc/tmemo/tmemo-jiri-multidomain.txt

@@ -1,231 +0,0 @@
-$Id$
-
-Draft Requirements for Automated Multidomain Support in SER
-============================================================
-
-Jiri Kuthan, Jan Janak
-iptel.org
-January 2003
-
-
-Summary and Status
-------------------
-
-Currently (ser version 0.8.10), maintenance of multiple domains is 
-a very manual process in SER -- one needs to introduce new SQL tables, 
-change scripts and restart SER on introduction of a new domain. This 
-memo summarizes requirements for automation of this process. The goal 
-is to make domain provisioning as easy as manipulating list of supported 
-domains via FIFO server in run-time. This memo currently ignores
-current implementation status -- parts of it have been implemented
-in existing (auth, usrloc, registrar) or new (domain) modules.
-
-Most of issues raised here come from private or [serhelp] discussions
-with Jan and Juha -- forgive me if I missed something when I was
-compiling it.
-
-
-Requirements
-------------
-
-a) Identification of Served Domains
-
-   when a request comes, it needs to be understood, whether it belongs
-   to one of maintained domain, or shall be forwarded somewhere else;
-
-
-      SQL_TABLE:     domain(domain)
-      SER module:    domain
-      COMMANDS:      is_from_local()
-                     is_uri_host_local()
-
-      FIFO commands: domain_reload
-                     domain_dump
-
-
-      comments: jh: "I use now 'is_uri_host_local'"
-
-
-
-b) Domain Name Canonization
- 
-   situtations can occur when a domain is reachable under multiple
-   names; if that is the case, name canonization needs to be carried
-   out before the domain check in (a); this for example happens if 
-   phones are connected, which use IP addresses in URIs.
-
-       SQL_TABLE: domains(name,canonical_name)
-       COMMANDS: canonize_domain
-
-      Note that such scenarios increase implementation and deployment
-      complexity. We thus better recommend using phones which do use
-      domain names.
-
-	Domain Name Canonization hasn't been implemented yet.
-
-
-c) Multi-Domain User Lookup
-
-   user location module identifies users by username and canonical domain
-   name; 
-
-       SQL_TABLE: location(user,domain,contact)
-       COMMANDS: lookup(table_name)
-
-     To enable multi domain support in registrar, use the following
-     parameters: modparam("usrloc", "use_domain", 1) and
-                 modparam("registrar", "use_domain", 1)
-
-
-d) Domain Verification in From HF 
-
-   one needs to be able to learn, whether request sender claims
-   a relationship to served domains in his From header field. to prevent
-   unauthorized use of a served domain name in From, which -- if relayed
-   by SER and rubber-stamped with its transport address -- could look
-   trustworthy, one needs to authenticate the request sender
-
-
-        COMMANDS: is_from_local()
-        SER module: domain
-
-       Note: If (b) can occur, canonization should take place first
-
-
-e) Username Verification
-
-   users may display one or more names legally in From header fields;
-   for example, a gateway operator is committed by law to forward only
-   user names (phone numbers) to PSTN which are "owned" by that user;
-   it is thus important to be able to check whether a pair {digest_id,
-   From user name} is valid; there may be many of these pairs (i.e., 
-   there may be N valid Froms for 1 digest id); digest id may or may
-   not be the same string as From; (the second case for example
-   occurs when an ISP already has a user database, he wants to reuse
-   for authentication, but wishes users to show their "phone numbers"
-   in From); 
-
-   Similar practise should apply to validation of To header field for
-   registrations. Otherwise, nothing would prevent users with valid
-   credentials to claim someone else's address in To and grab all his
-   incoming requests.
-
-          SQL TABLE: uri(user, domain, uri_user)
-          SER module: auth
-          COMMANDS: check_from
-                    check_to
-
-
-     if you use modparam("auth", "use_uri_table", 1) then uri table will
-     be used to map From or To username to a generic one and the generic
-     username will be compared to digest credentials username. If you do
-     not use the parameter, From or To username and digest credentials
-     username must be same.
-
-f) Generating Realm in Digest Challenges
-
-   users need to be challenged with a proper realm; to automate this process,
-   one can generate realm out of domain names in requests;  xxx_challenge should 
-   then use domainname in From HF as realm; the only exception is www_challenge, 
-   in which case To HF is to be used for REGISTERs (not proxy_challenge, though);
-----?? does he do that??--------
-
-
-    ACTION: {proxy|www}_challenge(AUTO);
-
-      The function accepts realm as the first parameter, if you use an
-      empty string "" then the realm will be extracted from From or To
-      header field (depending on function used and message type).
-
-      Note: If having (realm==domain name) is for some reasons too limiting, the 
-      served_domains table should include realm name associated with a given domain.
-      Hopefully, there is no case for such automated realm generation.
-      Not implemented, realm must be equal to domain name if f) is used.
-
-      Note: if (b) can occur, canonization should take place first.
-
-
-g) Verifying Digest Credentials
-   
-   users need be authenticated properly; that takes in multi-domain
-   environment looking up their entry in subscriber database correctly;
-   the entry is identified by digest username (without domain name if
-   present) and realm; if credentials are hashed, one needs to maintain
-   and verify two hashes: one for users putting domain name in digest
-   id and one for users not doing so
-
-    ACTION: {proxy|www}_authenticate(AUTO);
-
-      Comment: jh: the authenticate functions check that to/from matches
-                   digest realm (which integrates (d))
-
---------???----------
-     If there is a domain name in username in digest credentials, it
-     will be extracted and used as domain. realm parameter if digest
-     credentials cannot be used to pass domain because it is not
-     protected by the digest (username is protected). realm parameter in
-     digest credentials is used only to identifiy which credentials in
-     the message belong to the server.
---------???----------
-
-
-g) User Aliases 
-
-   aliases are same as  usrloc -- now, they are looked by name and domain name,
-   that's it.
-
-To-Do
------
-
-All tables should be ideally hashed and cached for rapid processing. All but
-usrloc (domains,served_domains,valid_user, and also subscribers, grp) are 
-read all the time and rarely updated. That's a reason why use of 
-a read-write lock would be beneficial. Writes only occur via FIFO 
-process when administrative changes occur.
-
-serctl and serweb should be enhanced to provide the ability to
-manipulate domains, served_domains and valid_user.
-
-
-Script Example:
-----------------
-
-  modparam("usrloc", "use_domain", 1)
-  modparam("registrar", "use_domain", 1)
-  modparam("auth", "use_uri_table", 1)
-  modparam("auth", "use_domain", 1)
-
-
- 
- /* does it belong to any of my served domains ? */
- canonize_domains();  /* 195.37.77.101 ->iptel.org */
- if (is_uri_host_local()) {
-      if (method=="REGISTER") {
-            if (!www_authenticate("")) {
-                 www_challenge("" /* realm from request HFs */...
-                 break;
-            };
-            if (!check_to()) ..../* can digest-id "u123" register as "jiri"? */
-                 sl_send_reply("500", "Forbidden");
-                 break;
-            };
-            save("location");
-            break;
-       };
-       if (!lookup("location")) {
-            sl_send_reply("404", "NotFound");
-            break;
-       }
- };
- 
- /* does someoneclaimto belong to one of our served domain? prove it! */
- if (is_from_local()) { 
-    if (!proxy_authenticate("")) {
-       proxy_challenge("" /* realm from request HFs */...
-       break;
-    };
-    if (!check_from() ..../* can user "jiri" have 7271 in from? */
-       sl_send_reply("500", "Forbidden");
-       break;
-    };
-

+ 0 - 242
doc/tmemo/tmemo-jiri-nats.txt

@@ -1,242 +0,0 @@
-$Id$
-
-Deployment Experience with NAT Traversal
-========================================
-
-
-Jiri Kuthan, iptel.org, February 2002
-
-TOC
-----
-1. Summary
-2. Background
-3. Summary of NAT Traversal Methods
-   - using symmetric communication
-   - UPnP
-   - geek tweaks
-   - ALG
-   - STUN
-   - media relay 
-   - FCP
-4. Hints for SER Usage
-5. More references
-
-
-1. Summary
-----------
-
-We summarize currently deployed techniques for NAT traversal. This
-memo focuses on practical experience of users of SIP or/and SER have
-had with getting over NATs. It attempts to capture aspects like
-known configuration pitfalls, available devices, and known
-operational limitations. It also includes subjective, unverified
-user experience encountered on our mailing list to give readers
-rough feeling for how people tackle with NATs.
-
-2. Background
--------------
-NAT is one of the most annoying issues that have ever happened to SIP.
-SIP communication is very dynamic -- it allows many parties to 
-participate in many sessions of various types and flavors. To address
-this dynamicity, transport addresses are dynamically negotiated using SIP.
-IP addresses and transport port numbers are advertised in SIP
-headers and SDP payloads. Unfortunately, all these addresses
-are invalid once they cross a NAT and leave an addressing realm.
-That means that signaling "as is" simply does not work with NATs. Many 
-techniques have been developed to deel with this ugly, ugly, really ugly
-problem. None of them is perfect -- it is all patchwork fixing
-what NATs have broken. Some of them better fit in some scenarios
-then others do, but there is no "best" method.  It will be probably
-affordability of the methods, easy of configuration and market who 
-will decide popularity ranking for the available methods.
-
-The problem is really big. Noone really knows how big, that is one of
-NAT properties -- they hide users. Many residential users use NATs
-to save money for IP addresses. GPRS networks are told to be NATted
-by 90%. Brian Carpenter (January 2001): “My hand waving estimate is 
-that 40% (160M) of users are behind a firewall and/or NAT, 50% (200M) 
-on dial-up, and 10% (40M) have direct always-on access. But there is 
-no way I can justify these numbers.”
-
-For sake of completeness: a straight-forward solution would be to
-deploy IPv6 and have so many addresses, that there would be need for
-NATs. However, as this memo is focused on practicability, issues
-related to IPv6 are not mentioned here.
-
-See the following link for a detailed discussion of NAT traversal scenarios:
-http://www.iptel.org/ietf/firewall/nat/#draft-ietf-sipping-nat-scenarios
-
-
-
-3. Summary of NAT Traversal Methods
------------------------------------
-
-
-----------------------------------------------------------------
-technique:    using symmetric communication
-description:  the method is based on limiting peer-to-peer communication
-              to client-server communication; server always sends to where
-              client is sending from
-requirements: phone devices that support symmetric communication;
-              existing species: Cisco's ATA
-configuration 
-practice:     ATAs need to be configured to advertise public address 
-              in signaling (Contacts, SDP), or learn it from REGISTER 
-              replies; alternatively, one can rewrite signaling using ser's
-              nethelper module; one needs to rewrite SIP anyway
-              because ATAs don't advertise their symmetricity;
-              http://www.cisco.com/univercd/cc/td/doc/product/voice/ata/atarn/186rn214.htm#xtocid17;
-              see more on use with ser in section 4
-limitations:  non-symmetric devices, like Messenger don't work;
-              servers need to be reachable -- it does not work if both 
-              devices are behind NAT
-comments:     jku: ATA is a very simple device, it has no display, I am 
-                anxiously waiting for more vendors to support symmetric signaling
-              jt, maxim: the "received" workaround in version 2.15 does not work
-references:   http://www.iptel.org/ietf/firewall/nat/#draft-ietf-sip-symmetric-response
-
-----------------------------------------------------------------
-technique:    UPnP
-description:  the method is based on controlling NATs from end-devices
-requirements: NATs and phones with UPnP support; Messenger and 
-              snom are known to support UPnP; there is linux
-              support for it
-configuration 
-practice:     of course, upnp requires by definition no configuration ;-)
-              (I'm not serious -- anyone actually tried it?)
-comments:     jh: but how many nat boxes support upnp?  last time i looked at 
-                ms upnp page, the list was very short.
-
-----------------------------------------------------------------
-technique:    geek tweaks
-description:  set-up port forwading manually
-configuration  
-practice:     you need to configure NATs to split its public-side port
-              numbers accross your private-side phones, and configure
-              the phones (if they allows so) to use these port numbers;
-              also, phones need to be configured to use publicly
-              reachable address in their payloads
-requriements: configurable NATs (many residental NATs are configurable)
-              and configurable phones (ATAs do that, I heard pingtel did
-              it too)
-----------------------------------------------------------------
-technique:    ALG
-description:  NATs need to have built-in application awareness which fixes
-              signaling and replaces private realm addresses with public
-              ones
-requirements: SIP-capable NAT 
-hardware:     we are currently aware of residential Intertex, bigger-scale
-              Ingate, enterprise Cisco/PIX
-comments:     jh: i like this one.  cisco ios nat that is built in every 
-                cisco router now has sip alg.  you must have very recent ios 
-                version though.
-              jdr (in a private chat): it requires too much application
-                awareness from router vendors
-              jku: not all Ethernet devices work with it; sometimes turning 
-                it off and on is needed
-
-----------------------------------------------------------------
-technique:    STUN
-description:  STUN is a simple protocol, with which phones can query the public
-              addresses with which they appear outside, and use them in signaling
-requirements: STUN-enabled phone (like k-phone, snom)
-limitations:  doesn't work over symmetric NATs 
-software:     - Maxim's working stund, which works on BSD too:
-                http://people.freebsd.org/~sobomax/stund_0.8.2.tgz.
-              - kphone from wirlabs supports Stun
-comments:     jh: we have tried kphone's stun in all mojor dsl providers in finland 
-                that nat their customers and haven't had problems with any.  in some 
-                cases you have to run stund in your outbound proxy and not in some 
-                other ip address. 
-              nils: kphone/stun is nicely working, except it expects replies on 
-                other port number than it sends from (i.e., it behaves like
-                a server rather than like a client); then, replies go to the
-                port advertised in Via, for which no association in NAT exists,
-                because the original request created one with another port
-                number
-              jku: many residential NATs are claimed NOT to be symmetric
-                (just jabber I heard)
-References:   http://www.iptel.org/ietf/firewall/nat/#draft-ietf-midcom-stun
-
-----------------------------------------------------------------
-technique:    media relay
-description:  make all communication go through a server; if the communication
-              is symmetric, this method works even if both parties are behind
-              symmetric NATs
-limitations:  scalability issues with bandwidth load put on the relay; RTT doubles
-hardware:     JAsomi has some, it is in use in FWD; other devices exist from
-              Kagoor Networks, and Newport Networks
-----------------------------------------------------------------
-technique:    FCP
-description:  Firewall Control Protocol allows proxy server to align NATs to needs
-              of applications; the technique is similar to ALG, except the application
-              logic is moved away from router builders to application builders
-limitations:  there is no standard -- the IETF/MIDCOM WG has failed to deliver 
-              reasonable output in reasonable time; no FCP client exists right now
-software:     FCP server for linux nats exist; FCP client for ser is still work
-              in progress
-References:   http://www.iptel.org/fcp/
-----------------------------------------------------------------
-
-
-4. Hints for SER USage
-----------------------
-
-ad symmetric communication -- how nathelper works)
-
-- It takes symmetric devices. ATAs are such, but they do not advertise their
-  capability. One needs to grant specil handling for devices claiming to be
-  ATA in their requests.
-- It takes fixing Contacts before they are stored or forwarded. That's what nathelper 
-  does. It replaces phones' contacts with requests' transport origin. It also
-  adds "symmetric ad" to SDP payload ('active')
-- Replies need to be checked too to see if UAS supports symmetric signaling.
-- UAS needs to understand the 'active' option. IOS does so.
-
-fone F: A:B     NAT N: X:Y       proxy/registrar D                       
-
-                  ~                                                /--------\
-/------\          ~            /-----------------\                 |        |
-|phone | -------->~----------->|ser w/nathelper  |<--------------->|other   |\
-\------/          ~            |as outbound      |                 |domains ||\
-                  ~            |proxy + registrar|                 \--------/||
-                               \-----------------/                    \------/|
-                                                                        \-----/  
-
-nathelper script example: (subject to ongoing changes, as ser is being refurbished)
-
-
-
-route {
-        if (search("User-Agent: Cisco ATA.*")) {
-                add_rport();
-                fix_nated_contact();
-        };
-        rewriteFromRoute();
-
-
-        [REGISTRATION STUFF STRIPPED]
-
-
-        if (method=="INVITE") {
-                addRecordRoute();
-        };
-
-
-        t_on_positive("1")
-        # forward to current uri now
-        if (!t_relay()) {
-                sl_reply_error();
-        };
-}
-
-
-reply_route[1] {
-        if (search("Server: Cisco ATA.*") {
-                fix_nated_contact();
-        }
-}
-
-Acknowledgments: nathelper module is courtesy of MAxim Sobolev.
-
-

+ 0 - 113
doc/tmemo/tmemo-jiri-policy.txt

@@ -1,113 +0,0 @@
-$Id$
-
-Recollection of Messages on Policy
-==================================
-
-Jiri & Juha: sipping, private exchange:
-(2003-02-24)
----------------------------------------
-
-> for example, when someone calls me at sip:[email protected], the to header
-> may include any local way to make a call to a phone number, for example,
-> sip:[email protected];user=phone.  enum will then return for that
-> number sip:[email protected].  in this case, neither to or from header is
-> my sip uri.
-
-
-Why do we need to authenticate? My understanding was that you would like
-to challenge in case someone was claiming your domain in From and trying
-to get it rubberstamped by your domain's proxy. Do we need to worry about
-a BYE from 0123@foo to 0321@foo? Well, I think so, to avoid relaying
-(spam). That could be accomplished by challenging any requests to outside 
-domains. The question then is what realm should we use? We don't know
-it any longer, and we don't want to keep sessions. Keeping it with
-record-routing might be an option.
-
-Juha:
-yes, the proxy would not know the realm unless it keeps dialog state.
-more that authentication, i'm worried about accounting.  if my policy is
-to account dialogs (calls) that are initiated by my own users, how do i
-know when i see a bye, if it terminates such a call or a call initiated
-by non-local party?
-
-Jiri: There are actually two issues: decide whether the subsequent BYE needs to
-be authenticated, and if so, with what realm. There is no way around it
-except keeping dialog state, better in record-routes rather than in
-server's memory. If in record-routes, integrity needs to be preserved.
-See my sipping posting (2003-03-04):
-First of all, as said previously, live with realms from UAC. They
-are as trustworthy as user's id -- all is supplied by user and what
-really matters is whether the credentials are ok. (And again, forget
-interfaces, please.)
-
-The real questions is whether to authenticate at all, and if so
-which realm the server should use to challenge.
-
-Let me give an example. A proxy maintains a policy which is 
-a no relaying: drop requests which neither have my domain 
-  in r-uri nor have my domain in From
-b verify from: if request originator claims to be a part of
-  my domain in From of a request, authenticate
-c watch all: sessions are record-routed
-
-Scenario:
-1) a@other calls b@other which gets forwarded to b@mine
-2) b@mine sends a BYE, it looks like:
-
-BYE sip:[email protected]
-From: b@other
-To: a@other
-Route: <proxy@mine;lr>
-
-What will you do now? Well with the policy above you would drop
-it (point a). If you are smarter, you will see your Route and
-infer "that's my Route, I must have accepted the previous INVITE"
-and will not drop it. The questions are now:
-- should you authenticate? (remember, you can't authenticate
-  request originators from other domains)
-- if so, with what realm
-- how far can you trust the information in Route (actually, not at all)
-
---
-
-solution space? Well, it is actually about call-state policy. To enforce
-it, we would have to maintain call state. That would be a way ugly and
-we better put the call state somehow in Record-Routes. Doing so would
-be a very useful thing anyway. That would be a useful thing for a dozen
-of other cases too -- Frmo rewriting, or 200/ACK matching at an accounting
-proxy.
-
-
-
-Mike Graff, serusers
---------------------
-I implemented something much like this:
-
-if (to me):
-        if register
-                www_authorize or fail if not a valid register
-                done
-        if claiming to be "From" one of the domains I accept
-        registrations for
-                proxy_authorize
-                done
-if not to me (I'm relaying for a local phone to an external address)
-        proxy_authorize (once again, based on from address)
-        done
-
-
-Another Concern Raised by Juha
-------------------------------
-What if users with valid credentials in a domain will call
-someone, whose SIP address is rededirected/referred/forwarded
-to an accounted PSTN destination? Callers will then "dial"
-a sip URI (bob@iptel) which will be turned without their
-awareness to (900-666666@iptel), challenged by gateway,
-automatically answered by most of existing software today
-and accounted then.
-
-Solutions?
-- don't submit credentials automatically in UAC if challenge uri!=
-  dialing uri; pop up a confirmation prompt in UA
-- challenge with a different realm which will take authentication
-- be restrictive and ban forwarding, REFERs, 3xx

+ 0 - 244
doc/tmemo/tmemo-jiri-sat.txt

@@ -1,244 +0,0 @@
-$Id$
-
-About Rewriting From in SIP Requests
-====================================
-
-
-Jiri Kuthan, iptel.org, February 2002
-
-
-Summary
--------
-After giving an introduction about general packet (1) and particular SIP
-rewriting (2) and claiming it is harmful, we describe an IP2PSTN scenario
-which asks for username translation. It is about the ability to display
-phone number associated with a SIP caller in PSTN networks. We show three 
-methods (3) then:
-a) translation in gateways, which is little invasive and little 
-   deployable 
-b) NAI, which is architecturally still clean and takes fortunately 
-   little knowledge of user-provisioning in gateways, but relies on
-   an non-existent protocol extension
-c) brute request rewriting which is architecturally ugly but works now
-We also give some implementation hints for number three (4).
-
-
-
-1. Packet Rewriting Harmful
----------------------------
-
-
-Generally, message rewriting by elements in middle of a communication
-path is a questionable practise threatening transparency. 
-
-
-The best historical example is that of NATs. These devices are widely 
-adopted by user community because they help to preserve IP address 
-space and save consumers' money charged for IP addresses. Unfortunately, 
-they mangle messages between end-devices in a way that makes life very
-difficult. Particularly, with SIP signaling IP addresses advertised
-in payload are invalid once a SIP message leavs a natted network.
-
-
-As the NAT example shows, rewriting packets by elements in the middle 
-is a ticket for problems and is likely to introduce operational confusion. 
-Readers wishing to learn more about Internet transparency, and threats to it
-are encouraged to read 
-
-
-http://www.iptel.org/ietf/arch/#rfc2775
-http://www.iptel.org/ietf/arch/#draft-iab-arch-changes
-http://www.iptel.org/ietf/firewall/midcom/#rfc3234
-
-
-
-2. Background on SIP Rewriting
-------------------------------
-In SIP, the most important element in the middle of the end2end path
-is a proxy server. With few exceptions, it operates in read-only mode.
-As requests and replies traverse SIP proxy servers, the servers update
-request-URI, put/remove themselves in routing-related parts of message 
-headers (route/via/record-route header field stacks) and decrement 
-Max-Forwards.  Other well-known exception is removal of consumed 
-credentials at authentication proxies.
-
-
-Rest of SIP messages remains untouched. Message body, header fields
-identifying transaction and dialog (From/CSeq/To/Call-ID), and other
-header fields including those unknown are not modified. That establishes
-transparent end2end communication, which is a prerequisity to many
-end-2-end based features, such as reliability or security.
-
-
-Consider the security implications as an example of "what happens
-if I rewrite". If end-2-end security is striven for and say signed
-digests are attached to a message to prove its integrity, rewritten
-messages will be recognized as such and denied.
-
-
-3. Rewrite or Not
---------------
-There may be cases in which rewriting some header fields may have
-benefits. A particular case raised has been a scenario with users
-owning both "nice" e-mail-like SIP addresses as well as numerical
-aliases for interoperation with PSTN. While the users commonly use
-their e-mail like addresses (sip:[email protected]), when they call
-to PSTN, a gateway needs to advertise user's phone number to the
-PSTN world. User's From needs to be translated to his phone number
-before PSTN signaling is started.
-
-
-There are multiple solutions. The safest is to make the gateway
-implement this translation. This solution takes no rewriting in
-the SIP path, the translation occurs at the place where the rest
-of all other signaling translations occurs too. Whereas architecturally
-nice, it is not easy to deploy. PSTN gateways are typically hardware
-boxes with limited configuration possibilities. Also, the translation 
-database is typically stored in a specialized user-provisioning system,
-with interfaces which most likely are not supported by the gateway.
-
-
-It seems thus easier to place this translation capability in proxy
-servers. Proxy servers have been designed as open platforms for
-programming. Like web servers, they can have many programming
-interfaces, interact with databases and exercise request processing
-logic. The translation can also occur without mangling the original
-request -- the translation just needs to be _appended_ to the
-request. Some of the NAI proposals in IETF can be used, as long as 
-the NAI information is understood by terminating gateway:
-http://www.iptel.org/ietf/security/identity/
-
-
-The problem with NAI is it does not exist yet. To address cases
-like the one above right now, users are left with brute rewriting of
-From header field.
-
-
-4. How to Rewrite
------------------
-
-If you are not yet discouraged by all the evil aspects of packet 
-mangling and do not wish to wait until NAI is deployed, here you are. 
-When rewriting From header field, caution is advised: all requests and 
-replies in both directions need to be  translated consistently. Transaction 
-and dialog matching will fail otherwise and break signaling completely.
-
-To achieve that, a proxy server must stay in the path and understand
-direction of a transaction wrt to session. That is because unlike
-in requests from callers, in requests from callee the To header
-field needs to be rewritten. Both these features can be achieved 
-using record-routing. 
-
-
-When an initial INVITE arrives, the proxy server looks at From,
-and may decide to rewrite it using a database. If it does so
-(ser's action "replace" from module "textops" is a good example
-of how to achieve it), it puts a record-route (RR) in the forwarded
-request. The RR enforces subsequent communication to visit the
-proxy and can be used to include helpful hints in uri parameters.
-(In general, any parameters can be added as RR is "owned" by 
-a proxy and extension uri parameters are permitted for RR in 
-SIP spec.)
-
-
-The parameters that a proxy server appends to the RR-uri may 
-describe the translation so that it can be used for subsequent
-messages without having to consult the translation database
-again. Also, they may be used to identify transactions's
-direction. From tag may be good for this purpose. If the
-recorded value matches From tag in subsequent requests, it is
-request from caller and From needs to be rewritten. If it matches
-to-tag, it is request from callee and To needs to be rewritten.
-
-
-
-UAC                     proxy       gateway (UAS)
----                     -----       -------------
-
-
-T1
-
-
-INVITE                              INVITE
-From: joe;tag=123 ---->   X   ----> From: 729-927-1234;tag=123
-                                    RR: ;ifrom=joe;ojoe=729-927-1234;ftag=123
-
-180               <----   X   <---- 180
-From: joe;tag=123                   From: 729-927-1234;tag=123                                    
-
-
-200               <----   X   <---- 200
-From: joe;tag=123                   From: 729-927-1234;tag=123
-                                    RR: ;ifrom=joe;ofrom=729-927-1234;ftag=123
-
-
-T2
-
-
-BYE                                 BYE   
-From: joe;tag=123 ---->   X   ----> From: 729-927-1234;tag=123 
-R: ;ifrom=joe;ojoe=729...                                                   
-
-
-200               <----   X   <---- 200
-From: joe;tag=123                   From: 729-927-1234;tag=123
-
-
-T3
-
-
-BYE                                 BYE   
-To: joe;tag=123   <----   X   <---- To: 729-927-1234;tag=123 
-                                    R: ;ifrom=joe;ojoe=729-927-1234;ftag=123
-
-
-200               ---->   X   ----> 200
-To: joe;tag=123                     To: 729-927-1234;tag=123
-
-
-  RR denotes record-route, R route, only parameters are shown in
-  RR and R
-
-
-Note that one has to address rewriting of replies too; one needs to
-know which replies should be rewritten and how. There are two ways.
-One is through use of stateful transaction processing. A "rewriting"
-flag is stored along with rewritten transactions. It tells, whether
-From or To has been rewritten in relayed requests. If so, value from
-the original request is put back in relayed replies.
-(Transactional processing is best utilized in ser using TM callbacks.)
-
-The other design choice is stateless: putting all the translation
-information in Via, similarly to like it is put in RR.
-
-Also, one needs to establish aliases that make the rewritten address
-routable. Otherwise, attempts to use the translated address in From
-header field for subsequent communication would fail. That is (unlike
-with NATs, fortunately) a workable option.
-
-
-  Note: with RFC3261, rewriting of From/To could be perhaps less
-  voluminous. The major reason for rewriting consistency as explained
-  above is the need to keep consistency for transaction and dialog
-  matching. Pre-3261 implementations use header these fields to
-  identify dialogs and transactions. It has been later recognized 
-  that such dialog/transaction matching is bloated and it has been
-  simplified in 3261. Transactions are identified by sentby/branch in 
-  topmost Via, and dialogs by {callid,from-tag,to-tag}. If URI in From
-  is then changed, dialog/transaction is not affected and one does
-  not need to worry about rewriting replies (UAC does not care they
-  have a different From URI) or subsequent requests (UAC does not 
-  care UAS's To-URI != UAC's From URI).
-    (See In RFC 3261 in section 12.2.1.1: "...Usage of the URI in To
-     and From...for backwards compatibility..mandatory reflection...
-     will be deprecated.)
-
-  Again -- this simplification would only be doable if there were no
-  backwards-compatibility concerns. It would be probably more confusing 
-  than "consistent rewriting" as described above. On the other hand,
-  things would be simpler, and neither stateful processing nor 
-  record-routing would be required.
-
-  A guess is that NAI will work before pre-3261 implementions disappear.
-  That means, that now the fully consistent rewriting needs to be applied
-  and later, rewriting will be (hopefuly) replaced with NAI.

+ 0 - 274
doc/tmemo/tmemo-jiri-vmail.txt

@@ -1,274 +0,0 @@
-$Id$
-
-
-Draft Voicemail Architecture
-============================
-
-Jiri Kuthan, iptel.org, January 2003
-
-Abstract
---------
-
-We describe design decision made when building media 
-support to iptel.org's SIP server suite. We discuss
-how to introduce a voicemail component most effectively,
-i.e., without voicemail programmer's too big involvement
-in SER. We also mention some design choices which
-can be in general made to couple external applications
-with SER.
-
-TOC
----
-
-We first discuss interfacing methods used between SIP
-server/stack and applications in section 1, interfacing.
-We explain why we chose FIFO for the purpose.
-
-Section 2, IPC, gives details on use of FIFO, call flows
-examples and use of FIFO is detailed in Section 3.
-
-Possible extensions of the FIFO interface are mentioned
-in section 4.
-
-We show how the IPC/FIFO mechanisms compare to CGI-BIN
-which is architecturaly close in Section 5.
-
-1) Interfacing
---------------
-
-A primary design objective is to hide SIP/SER internals from
-application builders. The SER code is not easy: it includes
-lot of shmem access along with its synchronizations, quite
-dynamic memory use and management. Data structures are rich
-and dynamic. That makes life of an application programmer
-quite difficult and is likely to result in higher bug rate. 
-Thus, it is desirable to decouple application from the stack.
-
-We have considered two approaches: API-based and FIFO-based.
-API-based approach takes a clean encapsulation of parser,
-memory management and other frequently used code in a library.
-The library should take away as much details as possible from
-application developer.
-
-While librarization of SER is a very desirable objective,
-it is a time-expensive task and we do not want it to become
-a road-block for application creation. That's the primary
-argument why we are going FIFO now. 
-
-There were technical arguments related to FIFO use in this
-context too. Some (myself) were arguing that FIFO provides 
-the cleanest separation of applications from ser. It is 
-language-independent, allowing use of effective scripting  
-languages and whatever an app programmer is familiar with. 
-It is no way tied to ser's architecture and the burden of 
-its parallel processing, synchronization, data structures 
-and memory management.
-
-Counter-arguments (by almost anyone else) against FIFO included
-concerns that SER will become too bloated by exporting too
-much of its functionality through FIFO. It is certainly 
-true that a technology may become a victim of its own
-success if it grows too big. SIP itself is unfortunately 
-becoming an example of such technology. 
-
-A demarcation line we agreed to draw was dialog maintenance,
-which shall stay away from SER whereas transaction-related
-stuff will stay in SER.
-
-
-2) IPC
-------
-
-1) voicemail server will not be cranked via fork/exec
-   as it is too expensive. Instead, it will be multi-
-   threaded and await INVITE's via its FIFO server.
-   SER will then dump incoming INVITE requests to
-   voicemail's FIFO server. (non-blocking) A drawback 
-   is that the FIFO server will not be able to inherit 
-   pre-parsed header fields in environment variables.
-
-2) subsequent requests, such as BYE, will take the
-   same FIFO path
-
-3) the external application will communicate with SER
-   using FIFO. For the purpose of replying original
-   INVITEs, there will be a t_fifo_reply command.
-   The command will identify a transaction to be 
-   replied using the pair hash:label. It will be further 
-   parametrized by first reply line, optional header fields and 
-   optional body. (The pair hash:label will have to be
-   communicated via the method described in 1.)
-
-4) to-tags will be generated in the external app.
-   That's a change from previous suggestions. It's
-   a consequence of moving process/thread control
-   from SER to the app. In general, to-tags identify
-   a call and thereby the process/thread associated with
-   it. So the generation of to-tags should be owned by
-   the piece responsible for spawning new processes/threads
-   -- this is the place which will have to dispatch
-   subsequent requests to previously spawned processes.
-
-5) BYE's from voicemail (on timeout) will be done using
-   fifo t_uac. fifo t_uac will have to be changed to
-   allow parametrization of call-id/cseq. (it is ephemeral
-   only now). Call-IDs and Cseq known from previous
-   requests will be passed to SER via FIFO as t_uac
-   parameters.
-
-6) As for CANCEL: the voicemail app doesn't care of it.
-   It is automated and responds immediately, CANCEL is thus
-   not relevant. It is responsibility of the transaction 
-   machine to take care of CANCELs. If they come when the 
-   transaction is still alive, the CANCEL will not affect 
-   the call state, it will be replied with 481 otherwise. 
-   See section 9.2 of RFC 3261 for details.
-
-3) Call Flows and FIFO Use
----------------------------
-
-a) call setup
-
----> ... SIP
-===> ... FIFO
-
-UAC               SER            VM
-         INVITE
-         ----->
-         100                          ; 100 generated automatically
-         <---                         ; by t_fifo
-                     t_fifo(INVITE)   ; if request acceptable, VM
-                     =========>       ; stores dialog state indexed by
-                                      ; newly created, unique to-tag and replies
-                     t_reply(200)
-                     <========
-                     200 ok           ; (FIFO/200 means tranaction found and
-                     ========>        ; reply accepted for delivery
-         200
-         <---
-
-b) voicemail terminates call on timer
-
-UAC              SER             VM
-                     t_uac(BYE)      ; VM generates BYE using dialog context
-                     <=========      ; created and stored on receipt of INVITE
-                                     ; (see session 8 in rfc3261, particularly
-                                     ; dealing with RR is tricky)
-        BYE
-        <---
-        200           200
-        ---->        ==========>     ; uac completed -- FIFO returns
-                     
-
-c) caller terminates
-
-UAC              SER              VM
-
-      BYE            t_fifo(BYE)
-     ------>         ==========>     ; VM attempts to look-up the call; on look-up 
-                                     ; failure or if CSeq low, it initiates t_reply 
-                     t_reply(200)    ; with a negative code; otherwise, it completes
-                     <==========     ; recording and confirms the BYE with a 200
-
---
-use of FIFO:
-
-  t_fifo is a tm action -- it creates a new transaction (t_newtran),
-  sends a provisional 100 back (interaction with media component may
-  take long) and dumps request to a file (presumably media server's
-  FIFO):
-     t_fifo("/tmp/media_fifo", "some parameters");
-  The following items are dumped:
-  - t_fifo (media component may receive other requests)
-  - parameters
-  - to_tag (optimization for a quick dialog look-up)
-  - transaction identification: hash and label (used to refer
-    to transaction when replying)
-  - received requests
-  Eventually, t_fifo sets a timer (otherwise, the application could fail
-  to reply and transaction would be never released).
-
-  t_reply is a FIFO command, which is part of tm too -- it allows external 
-  apps to reply a pending transaction. It is parametrized as follows:
-  - to_tag (to be used if there is no tag in original request; important
-            for looking up dialog for future requests)
-  - transaction identifier: hash, table
-  - code
-  - phrase
-  - optional header fields and body
-  
-4) Possible Extensions of the FIFO interface
----------------------------------------------
-
-All these extensions are thought to help coupling of external
-applications with ser.
-
-A reasonable alternative for some other applications would be to 
-use exec instead of FIFO for the SER->APP path. That would
-have the benefit of getting header fields conveniently 
-parsed in env vars in the same way like exec module does
-it (since release 0.8.11). Application would then not have to parse 
-header fields.  That however makes only sense if the executed apps are 
-small -- forking is expensive and all is much worse if the started 
-application is big and starts slowly. 
-
-Some other applications may wish to have other triggering
-points than just request receipt. For example, they may wish
-to be triggered on transaction completion (e.g., some
-accounting applications) or receipt of a reply
-(with the possibility to initiate  serial forking,
-for example). That is implementable: transaction completion
-exec can be implemented in a similar way like exec
-module runs and bound to transaction machine via
-a TM callback.  Care needs to be paid to the case
-of exec on reply receipt -- it is called from a callback 
-installed within reply processing mutex, which poses
-some implementation caveats: it has performance
-implications and deadlock potentials. In particular,
-an exec-ed app bound to reply processing could result
-in deadlock if it called FIFO/t_reply.  Also at least
-an evnironment variable describing reply status would
-have to be added, so that the script sees more than
-the original request.
-
-5) SIP CGI-BIN (RFC3050) comparison
------------------------------------
-SIP-CGI BIN is a nice mechanism for coupling external applications
-with SIP servers. It is textual, language-independent, separated
-from server processes. From this perspective, it is similar
-to SER's app-coupling mechanisms, which include execution of external 
-applications as in exec module potentialy integrated in TM's transaction 
-management. The reason why SER is somewhat different is of historical 
-nature: we have been trying to address mainstream scenarios with
-compact solutions. They developed in course of time to bigger beasts 
-comparable to SIP CGI-BIN today, but still different. We now try to
-explain how SER/FIFO/exec compares to SIP CGI-BIN. 
-
-   Note that there are some applications, in which ser's FIFO server
-   can be used whereas CGI-BIN is not applicable. Particular, the
-   FIFO server can be used if an application wants to initiate
-   transactions or dialogs. CGI-BIN is only evoked when server
-   (through receipt of a messages) want to run applications.
-
-Also, knowledge of the gaps may be used to implement CGI-BIN for
-SER, if ever wanted.
-
-Similarities:
-- both CGI and t_exec (as suggested in #4) can start external apps
-  on request receipt; retransmissions and other transaction burden
-  is handled by the server
-- both CGI apps and t_exec apps can steer proxy server's 
-  transaction logic; CGI apps do so by returning instructions 
-  on stdout, t_exec apps can do so through FIFO server
-
-SER Defficiencies:
-- enabling applications to remove header fields (CGI permits that)
-  through FIFO currently not possible -- there is no such a FIFO
-  command; should not be difficult to implement
-- request forwarding neither, for the same reason -- no such a FIFO
-  command; easy to change, though
-- the application can be re-execed on receipt of a reply from
-  a reply_route like in CGI BIN; however, there are no meaningful
-  FIFO actions that can be used; use of FIFO/t_reply can result
-  in a deadlock as reply_route is called from within a reply_lock,
-  which is initiated by t_reply called from FIFO server too