Seved Torstendahl

The open telecom platform (OTP) is a development system platform for the tools and building blocks that design- building telecommunications applications, and a control system platform for ers need to develop applications for spe- running them. The platform, whose aim is to reduce time to market, cific computer systems. Package types enables designers to build – from standard, commercially available comput- that are meant to be integrated into an er platforms – a highly-productive development environment that is based embedded application system (target on the Erlang. system) make up a basic part of that sys- The OTP also permits application designers who program in C, C++, Java tem and contain the building blocks whose functions are needed at run-time. and other languages to take full advantage of sourced components. More- Examples include a , or a sim- over, the OTP allows designers to consider costs when matching computer ple network management protocol platforms with requirements for processing power and component availabili- (SNMP) agent. ty. The author outlines the OTP system architecture, its tools and building OTP development environment blocks, while describing the strengths of the open telecom platform as Many of the application programs for either a development environment or as a target system. the OTP are written in Erlang. Applica- tion programmers will find that several tools in the OTP development environ- ment support the tasks of developing The open telecom platform (OTP) and testing applications. For example, described in this article is primarily the OTP development environment con- intended for new applications that com- tains: bine a need for reliable, high-performance – tools for translating into stub code the telecom characteristics with a need for interface specifications given in the using externally sourced hardware and form of C header files, simple network software components. This includes ATM- management protocol-management products for access networks and data information base (SNMP-MIB) defini- communications, such as Internet proto- tions, and abstract syntax notation col-related traffic. number one (ASN.1) definitions; – an Erlang-to-Emacs mode that facili- Multipurpose platform tates editing Erlang programs; – the Erlang and debugger for The open telecom platform is a develop- testing modules; ment system platform for building, and a – a test coverage tool, and a hot-spot control system platform for running, finder. telecommunications applications. How- Some programs are written in other lan- ever, the OTP is not a monolithic platform, guages, including C, C++ and Java. In but is made up of sets of tools and build- such cases, the application programmer ing blocks, which include: uses the tools provided by the supplier of – Erlang – a programming language com- the target system, or the tools that are plete with compiler, debugger, and available in the development environ- other development tools (as a rule, the ment. tools and building blocks that are Target systems Box A required for Erlang are already imple- mented in the language, Box D); An OTP that consists of a control system Abbreviations – SASL – systems architecture support with one or more processors may be con- API Application program interface libraries (SASL) contain functions for figured as a target system. If the system ASN.1 Abstract syntax notation number one building fault-tolerant distributed appli- comprises more than one processor, BOS Basic BSD Berkeley software distribution cations; then the processors must be able to com- DBMS Database management system – – a real-time fault-tolerant dis- municate with one another through a log- HTTP Hypertext transfer protocol tributed database management sys- ical network. Some processors, I/O Input/output tem (DBMS); equipped with secondary storage and IP Internet protocol JAM Joe’s abstract machine – the Erlang run-time system; various I/O units, supervise and control MIB Management information base – sourced programs; the general system by means of func- MMU Memory management unit – standard, commercially available tions in the systems architecture support OTP Open telecom platform RCS Revision control system operating systems; libraries (SASL)—the OTP’s central com- RPC Remote procedure call – computer hardware. ponent. SASL Systems architecture support libraries Different packages of OTP-related com- A communication mechanism joins SNMP Simple network management protocol ponents have been defined to suit differ- each processor to the distributed system. TCP Transfer control protocol UDP User datagram protocol ent user needs. Applications develop- If desired – depending on requirements ment packages, for example, contain all for reliability – the processors and the

14 Ericsson Review No. 1, 1997 communication mechanism may be dupli- als, documentation standards, and sam- cated. The OTP handles all the basic ple programs that show how application Applications telecommunications requirements for programs are designed. written in Applications the control system (real-time, fault-toler- Most programs are written in Erlang. C or other written in Erlang ance, live software upgrades, distribu- However, application programs for time- languages tion), thereby allowing application design- critical parts may be written in C. ers to fully concentrate on the unique aspects of their own work. Moreover, the Sourced programs Mne- sia SASL SNMP Web OTP can easily be ported to several dif- The OTP defines how sourced programs, DBMS agent server ferent commercial operating systems. which include protocol stacks and man- agement applications, may be incorpo- Erlang run-time system System architecture rated into a system and made to inter- work with programs that were developed All application systems that are built on by application programmers. the open telecom platform (OTP) adhere Commercial operating system and computer hardware to a basic architectural structure, SASL Figure 1. The systems architecture support libraries (SASL) contain basic software Figure 1 Bottom layer that supports system start/restart, live The OTP system architecture. Commercial computer systems make up system software updates, and process the bottom layer. The system hardware in management. The basic operating sys- this layer may also be designed in-house, tem (BOS)—a predecesor to SASL – was if the manufacturing cost and the volume used for several years in the Mobility Serv- of delivery can be justified. This is mere- er and other systems. ly an architectural view; in real systems, the bottom layer contains many comput- Mnesia ers which may be of different types. A real-time fault-tolerant distributed DBMS that supports fast transactions Middle layer for the telecommunications application, Support for telecommunications require- and a , called ments is provided by a robust real-time Mnemosyne, for handling complex distributed database management sys- queries. tem (DBMS); basic support for handling software and reporting events; an exten- SNMP support sible SNMP agent; a Web server; and a SNMP provides run-time support through library of routines for interworking an extensible agent, and development between applications written in C and support by means of agent/sub-agent Erlang. design principles and an MIB compiler.

Top layer Web server All applications have access to Mnesia The Web server permits data that refers and SASL. The SNMP agent and the Web to Erlang functions to be collected via server may also invoke functions that are Web pages. provided by the applications in this layer. Erlang run-time system Interfaces The basic system that supports the exe- Three interfaces are provided: an inter- cution of Erlang programs. The Erlang face to OTP software; an interface to the run-time system includes the Erlang operating system; and an interface abstract machine, which executes inter- between applications written in different mediate code, the kernel, and standard languages. In terms of logic, the third libraries. interface applies to the application level, but is implemented in the OTP and in the Computer platforms operating system. The operating system and computer hard- ware consist of standard commercially Application programs available systems. Testing environ- The OTP includes a set of application pro- ments, for example, use conventional gram interfaces (API), as well as rules and workstations. guidelines for writing application pro- OTP component packages are grams. It also includes teaching materi- defined to suit various purposes. Devel-

Ericsson Review No. 1, 1997 15 opment packages include software for several versions of the OTP exist, see Box B developing Erlang programs, as well as Table 1. Reducing time to market libraries and applications. The user The effort required to support many dif- Shortening time to market entails much more than organisation purchases the actual com- ferent operating systems is manageable, simply reducing the time it takes to write program puter platform, such as a Sun work- mainly because most support for non- code. The time spent on the other phases of a station with the Solaris operating sys- Erlang languages is obtained directly from project must also be reduced. tem, a PC with a Windows operating the vendors of computer systems. Only a One way to do this is to have program designers begin their work at the early stages, or at high lev- system, or some other computer sys- minor part of the Erlang run-time support els, of design – for example, starting with the func- tem for which an OTP development envi- is dependent on the computer platform. tional specification. Moreover, design phases can ronment is available. Most Erlang run-time support, and all be broken down into short incremental steps, Packages for embedded systems parts of applications that are written in where each step is fully integrated into and test- ed at the level where it will be implemented. The include libraries and applications, but do Erlang, are independent of system hard- initial step, for example, might consist of starting not contain the compiler and debugger. ware and related operating systems. all blocks. Next, critical parts can be added. Final- These packages also include references Moreover, “Joe’s abstract machine” ly, management functions and error handling can to agreements that have been reached (JAM) code is directly executable on any be added. This way, problems can be detected and corrected early on. with vendors of computer systems. Under platform provided that the Erlang code the terms of these agreements, various does not explicitly make use of a specif- licensing fees are paid automatically ic feature of the operating system. Appli- when specific brands of hardware are pro- cations written entirely in Erlang are eas- cured, or when specific versions of soft- ily ported, and in most cases their load Box C ware are copied. modules (compiled code) are directly exe- Getting the most out of Erlang’s cutible on other computer systems. easy-to-port functionality: Strengths of the open In any part of an application written in C, do not Hardware and software from external include functions that relate to a specific operat- telecom platform suppliers ing system. Otherwise, gather these parts into a The open telecom platform (OTP) runs on Sourced hardware and software play a cluster, or else mark them clearly. many computer platforms, and caters to decisive role in reducing time to market. Recommendation: Use the C compiler that is used for the Erlang run- applications that have been designed in Very often, software vendors can offer time system. Erlang as well as in standard program- special applications at prices far below ming languages. Moreover, the OTP is the cost of developing an in-house solu- designed to support typical telecommu- tion. Likewise, because computer sys- nications requirements for robustness, tems change rapidly, rather than invest- smooth software upgrades, distribution, ing considerable resources to develop a and real-time functionality. computer board, Ericsson can offer a wide range of attractive solutions that are Time to market based on existing, commercially available A major objective of the OTP is to pro- systems. To this end, the Ericsson exter- vide a highly productive environment for nal technology provisioning process is designing telecommunications applica- used to enforce competitive terms for tions. This objective is supported by: external hardware and software, and to – the Erlang programming language – a forge ties with reliable vendors. high-level functional language that sup- ports distribution, fault detection, and Software recovery; Software from external vendors falls into – building blocks three categories: • robust, real-time distributed DBMS; – Applications – which include the upper Table 1 • support libraries for creating appli- layers of protocol stacks. Operating systems and computer cations that can report errors, – Operating system (OS) kernels. platforms on which the OTP may restart themselves when errors – Software that is directly coupled to be run occur, and update themselves with hardware or to the OS kernel – for exam- Microprocessor new versions of software when ple, device drivers and protocol stacks. architecture Operating system ordered to do so; To handle support and maintenance, • an extensible SNMP agent and a sourced software should be imported as Intel Pentium Linux, Solaris 2, Web server that is closely integrat- object code. Because malfunctions can Windows 95, ed with the database. cause a system to crash, operating sys- Windows NT tem software and software that is direct- Multiple computer platforms; easy to ly coupled to hardware or to the OS ker- Motorola 680X0 Vx Works port; up-to-date computer technology nel must be thoroughly tested and proven Sun SPARC Solaris 2 To accomodate different microprocessor reliable. Some protection may be provid- architectures and operating systems, ed for applications by running them as

16 Ericsson Review No. 1, 1997 Very high-level functional/declarative language Box D The Erlang programming language Symbolic data representation Support of massive lightweight concurrency Background strating the language’s suitability for use in large pro- (parallelism) When introducing new technology, real-time systems jects. A key to achieving very high productivity, Erlang often lag behind other systems. Indeed, many real- has been used for some years in several Ericsson Support of designing distributed, time systems are written in the programming lan- products, including Mobility Server, ISO Ethernet, and non-homogeneous systems guage C. Some languages, however, have been NETSIM. developed specifically for programming concurrent Permits tailored-to-fit fault recovery schemes in distributed systems real-time systems. Some of the best known exam- Functions, modules and processes ples are Ada, Modula2 and PLEX. Erlang programs are made up of functions that have No pointers, no memory leaks Today, declarative programming languages such as been grouped into modules and packaged as soft- Prolog or ML are used for a wide range of industrial ware products. Functions spawn processes – the exe- No fixed sizes or limits applications. These languages drastically reduce the cuting elements of an Erlang system – that are very Easy to interface other software and hardware total volume of source code in applications, as well lightweight and that enable fine-grained concurren- as the efforts that are required to design and main- cy. Permits software to be updated while running tain them. However, declarative languages were not Processes communicate by sending and receiving primarily designed to be used in concurrent real-time messages. Communication with the external non- Modular concept for structuring applications systems. Erlang world is conducted through ports (which Easy to create reusable libraries Erlang, which is a small but extremely powerful lan- behave like processes). Processes may also be guage for programming concurrent real-time, fault- linked to each other in order to detect software errors. Figure D tolerant distributed control applications, combines Characteristics of Erlang. important attributes of declarative languages with A built-in distribution mechanism enables designers constructs for supporting concurrency, distribution, to create a system whose processes may run on dif- and error-detection. It is an expressive, high-level ferent computers. Erlang allows fault detection and functional programming language without pointers – recovery in a distributed system, and the OTP soft- a feature that greatly simplifies design and testing. ware implements customisable schemes for recov- ery after faults. Built on experience Erlang has been in use at Ericsson for more than five Reference: years. To date, many hundreds of thousands of lines "Concurrent Programming in Erlang" by Armstrong, of Erlang source code have been written, demon- Virding, Wikström and Williams.

separate processes, preferably with OTP are that every new board, from low- memory management unit (MMU) pro- to high-end, can be made available, and tection. Application software is best man- that development costs can be shared aged through its source code, where soft- with the rest of the market. Thus, ware management requirements can be Ericsson draw on the expertise of exter- adapted. nal vendors, while remaining focused on their own core areas of business. Hardware The OTP is designed to use different Erlang and other languages microprocessor architectures and com- Applications that use the OTP can be puter boards. For example, standard implemented in Erlang or in any other pro- workstations or PCs are used for devel- gramming language. The choice of lan- opment, and standard computer boards guage is governed by the characteristics are normally used for inclusion in embed- one hopes to derive. ded (target) systems. Programming in Erlang shortens devel- Computer technology is evolving very opment time and provides support for rapidly. Every nine months, PC vendors designing robust distributed real-time design a new generation of boards with applications. Support is provided in the faster processors, more and faster mem- form of ory, and new integrated I/O circuits. Com- – libraries of ready-to-use components; peting at this pace with in-house solu- – guidelines for using the components; tions would be very costly for Ericsson. – guidelines for designing the applica- However, by relying on external processor tions that provide desired characteris- hardware, Ericsson can transfer their tics. need for staying abreast of developments By means of careful system design, and to computer vendors. Other advantages by applying the “90/10” rule (fine-tune of using standard computer boards in the the 10% of Erlang code that occupies 90%

Ericsson Review No. 1, 1997 17 Port Erlang messages. Software units written Any for in another language perceive these mes- application Erlang comm. process sages as communication lines to anoth- (non-Erlang) with other Erlang er program. Ports may also be used for appl. messages accessing hardware or low-level features directly. Port (linked-in driver) for hardware access The socket library Delivered as part of the standard Erlang distribution, the socket library is a low- level mechanism that enables non-Erlang Hardware processes to communicate with Erlang processes by means of the transmission control protocol/Internet protocol Figure 2 The port mechanism in Erlang. (TCP/IP). The Erlang program is respon- sible for understanding and complying with the protocol that is used on top of the TCP.

The C/C++ interface generator Thanks to the C/C++ interface generator, of processing time), it is possible to functions written in C and Erlang can eas- obtain good run-time performance from ily communicate with one another. The Erlang. interface generator includes conversion Development in other programming lan- routines on both sides of the interface for guages (usually C) is sometimes neces- encoding and decoding transferred data. sary for reducing execution time. Highly This enables applications written in optimised C code is very efficient, and Erlang to access and manipulate C data may be required in time-critical parts of structures. To use the conversion rou- applications. The OTP offers different tines, some programming is required on Box E ways of integrating applications written in the C side of the interface. All underlying Reliability C into applications written in Erlang or in communication is conducted using the A key requirement of the OTP is to provide a robust mixed programming languages. port mechanism, or the socket library. environment for implementing fault-tolerant One reason for using C is that a mar- telecommunications applications. By robust envi- ket already exists for applications or com- C programs that imitate an Erlang node ronment is meant a system that provides speci- fied services despite the presence of hardware ponents written in that language, includ- Erlang data can be encoded to byte faults or software errors. The minimum require- ing applications for implementing sequences in a format known as the ments of a robust environment are error detec- communication protocols. Obviously, Erlang external format. A library of useful tion, damage assessment, and error correction. being able to use existing products is a functions has been provided to enable Each of these aspects is necessary for meaning- ful error-recovery at run time. desirable feature. Thanks to a component programs written in C to decode byte Other requirements of the control system are as in the OTP and to an adaptation unit writ- sequences of this kind. The library has follows: ten in C, these parts can be integrated been extended to facilitate communica- – The “outage” time (that is, the time during which services are unavailable) must be short. into the software management principles tion with a distributed Erlang node using – While error recovery operations are under way, used by the OTP. the Erlang distribution protocol. Because only a minimum of services may be disrupted. There are several ways of creating inter- they behave like an Erlang node, C pro- This implies that some kind of "hot" or "warm" faces between applications written in grams that decode byte sequences of standby solution must be used. Erlang and other programming languages: Erlang code are called C nodes. C nodes, Hardware considerations – through the port mechanism; which have very limited functionality, are Hardware is made fault-tolerant by duplicating – using the socket library; not visible to Erlang, and are therefore resources; for instance, by means of redundant – through the C/C++ interface generator; said to be hidden. CPUs and dual communication paths. The provi- sion of a redundant CPU structure is more impor- – by enabling C programs to imitate an tant than synchronous duplication of CPUs, since Erlang node. OTP support for high reliability identical CPUs executing in parallel do nothing to An Erlang system that is run as a task by guard against software errors – that is, given the The port mechanism a host operating system is called an same error, both machines would fail at the same time. According to the port mechanism, which Erlang node. In the OTP, processes in dif- is the standard mechanism for interfac- ferent nodes communicate as easily with Software considerations ing applications, Figure 2, a port on the one another as processes within the Reliable software systems are built by carefully Erlang side of the interface is perceived same node. Erlang processes may also structuring the system so that an error in one part of the system may not affect its other parts. and behaves as an Erlang process. Here, be linked together. Should one of the all communication consists of standard processes die, due to an error, then a sig-

18 Ericsson Review No. 1, 1997 nal is sent to each process that is linked Development process to it. Since error signals can be trapped by supervisory processes, highly reliable External interface Translators When layered systems can be designed. applicable The Erlang programming technique of definitions dividing computations into “supervisory” Stub code and “worker” roles can be employed to Specifications build a robust system architecture. SASL Manual provide patterns that facilitate design creation according to these rules. Errors Source The system structure consists of a crit- Missing code ical "safe kernel" that must always be parts correct, and an application area where Compiler the requirement for correctness is some- what less stringent. The safe kernel is Load provided by SASL. module Erlang has a real-time garbage collec- tor, very few operations with side effects, Debugger Target/test and no pointers. Thus, when Erlang is environment used, a large class of problems com- monly associated with programming real- time systems is eliminated. Figure 3 Updating sourced software Applications may be developed from interface defi- Ordinarily, operating system software and nitions (C header files, ASN.1 specifications, CORBA/IDL interface definitions). After the source device drivers can only be replaced by code has been written, compiled and tested, it is rebooting the processor. Thus, where reiterated until satisfactory results are reached. continuous operation is a requirement, system software may only be updated in systems that make use of multiple processors. In a multiple-processor sys- tem, the system software is replaced on itoring programs then use small informa- one processor while the other processor tion agents on each monitored node. continues to execute as usual. By contrast, even in single-processor ASN.1 compiler systems, individual applications can usu- The ASN.1 standard, which is used for ally be replaced while the system is run- describing data representations in com- ning; however, the applications them- munication, defines unambiguously the selves must typically be terminated, interpretation of transferred data units. updated, and then restarted. Again, if this An ASN.1 compiler is provided for trans- method is not acceptable, then a multi- lating interface definitions in ASN.1 nota- ple-processor system may be necessary. tion into stub code together with calls to translation routines for packing and Tools in the OTP unpacking transferred data. In this context, tools are programs that C interface generator are used to develop software. A brief This tool facilitates communication description of the tools included in the between programs written in C and OTP follows below. Erlang. An interface specification received in the form of a header file is Application monitoring. translated into stub code. The stub code The appmon program has two main parts: may then be used for calls between Erlang the node window, which shows an and C to convert data representations. overview of the applications on all known nodes; and the application window, which Compiler shows the process tree of each applica- The Erlang compiler translates Erlang tion. source code (text files) into object code Because both windows run on one node that is independent of the CPU in use. (called the server node), graphics need This means that the resulting code may only be installed on one node. The mon- be loaded onto any computer platform

Ericsson Review No. 1, 1997 19 that supports Erlang without the code hav- ics interface for Erlang. The interface is ing to be changed or recompiled. easy to learn, and may be ported to many different platforms. If future applications Coverage tester in Erlang are written to the same graph- The coverage tester is used to ensure ics API, then it will be possible to run each that all code in a module has been exe- supported platform without having to cuted during a test. change a single line of the application code. Cross-reference tool The exref tool is an incremental cross-ref- Profiler erence server that builds a cross-refer- The profiler is used to determine which ence graph for every module that is parts of code, "hot spots", occupy the loaded into it. A great deal of information, most CPU time. This tool is useful for opti- including graphs and module dependen- mising programs. cies, may be derived from the cross-ref- erence graph. The call graph is repre- SASL sented as a directed graph in text. The systems architecture support libraries (SASL), which are used as build- Debugger ing blocks by applications that are run- The Erlang debugger provides mecha- ning, provide usage rules for designing nisms for visualising what happens when robust applications that may be started, code is executed in specified modules, stopped, and restarted, and that can or when processes crash. Because it report errors or events. allows breakpoints to be set, and because it performs sophisticated trac- SNMP MIB compiler and instrumentation ing, the debugger interferes with the The OTP provides support for using the behaviour of the system being debugged. simple network management protocol Figure 4 The debugger is mainly used to locate (SNMP) for operating and maintaining After building blocks of the OTP are compiled, a selection of generated load modules are combined errors in code (bugs). However, design- applications on the platform. SNMP sup- to form a platform – for example, to form a develop- ers may also use it to learn about, or to port consists of ment environment to be used on a Sun SPARC with Solaris 2, or to form an application system that better understand, applications that were – run-time support – in the form of an includes the computer platform. Likewise, a project written by other designers. extensible agent; may define its own OTP application system. Because Erlang is a distributed con- – development support – in the form of a current language, conventional debug- management information base (MIB) ging techniques do not apply. Thus, the compiler and a programming model for Erlang debugger provides mechanisms implementing MIBs. Source system building blocks for attaching to, and interacting with, sev- The extensible agent uses two mecha- eral processes simultaneously, includ- nisms – dynamic MIB loading and sub- GS ing local processes and processes locat- agent handling – that provide an envi- SNMP EA ed in other Erlang systems in a network ronment where MIB modules can be of Erlang systems. Every process that loaded/unloaded in an efficient plug-and- SASL Mnesia Web runs code in debugged modules is mon- play fashion. The sub-agent concept also server itored, and continuous information on supports distributed applications; that the status of any given process may be is, different MIBs can be implemented at displayed. different nodes. If necessary, the trans- action mechanism for SNMP set Development environments Erlang mode for Emacs requests may be customised. Emacs is a widely-used text editor whose The MIB compiler may be used to gen- SASL Mnesia SNMP GS Tools .... EA behaviour can be customised. A defini- erate the prototype instrumentation of ERTS tion file is distributed with the OTP that MIBs automatically. The results may then allows the Emacs editor to recognise be incrementally refined and tuned. This Erlang syntax, and that helps designers feature enables designers to start devel- to write well-formatted, syntactically cor- oping manager applications at the early Application systems rect code. The Emacs editor is not stages of a project. included, but may be obtained free of Support is also provided for using the SASL Mnesia SNMP GS EA charge from many sources on the Inter- Mnesia DBMS together with the SNMP net. tool kit. This means that Mnesia tables ERTS can be read and manipulated with Force computer board Graphics interface for Erlang SNMP, and that an SNMP table can be (SPARC and Solaris 2) The graphics system is a general graph- implemented as a Mnesia table. The

20 Ericsson Review No. 1, 1997 SNMP tool kit provides an API for imple- menting application-specific MIB mod- Box F ules, including a mechanism for send- Components of supporting design of robust applications ing traps. Component Description

Trace tool Standard libraries The standard libraries contain Erlang modules, such as lists, “ordsets”, and “dict”. An important property of these libraries is that the code they contain is free of side effects. The debugger-tracer has a graphical front- Thus, calls to functions in these modules work the same in every environment. end. When used in a running system, it causes little disturbance to the system. Behaviour In this context, behaviour is a formalised pattern of design that can be reused to build Trace tool supports distributed debug- new applications. Behaviour is implemented in the form of call-back modules: a call- back module must export a specific set of functions that are called by the system to ging, which means it may be used to evoke a particular pattern of behaviour. Examples of behaviour are: debug Erlang processes running on the - gen_server – a behaviour that implements a generic client-server machine; same system as well as processes that - gen_event – a behaviour that implements a generic event-handling machine; - supervisor – a behaviour that implements a specific style of supervisor-worker pro- are running on several remote systems. gramming which allows supervision trees to be constructed dynamically. The remote systems may each run on dif- ferent operating systems and CPUs. Also Applications Applications are named collections of objects that are used for encapsulating system included is a simple line-oriented inter- components. The basic properties of an application are that it can be named, loaded and unloaded, as well as started and stopped. The aim of an application is to provide face to the trace functions. a mechanism that enables users to divorce themselves from the internal details of the application, and to think instead about the relationships between applications. xerl A complete integrated Erlang environ- ment, xerl is an X Window-based interface to the standard Erlang shell. The inter- face may be used to compile, edit, debug and run Erlang. Moreover, because xerl is sensitive to Erlang syntax, it checks and formats code as it is written. yecc parser generator – Memory allocation and real-time A parser generator for Erlang that is sim- garbage collection, which effectively ilar to yacc. From a grammar definition eliminates memory leaks. (input), the generator produces Erlang – Lightweight concurrency and support of code for a parser. thousands of simultaneous tasks. – Transparent cooperation between all Other tools computers in the system. At present, tools for managing different – Location and encapsulation of run-time versions of software are not delivered as errors. a part of the OTP. Nonetheless, a man- – Supervision of run-time code as it loads agement tool, such as the revision con- or is replaced, and while it is linked. trol system (RCS) or ClearCase, is highly The structure of the Erlang virtual recommended. machine allows it to be easily incorpo- rated into new operating systems. The Building blocks in the OTP Erlang virtual machine is the only build- ing block that was not written in Erlang. When the OTP is used to create an embed- ded system, some of its components are Kernel retained by the delivered system. OTP run- The kernel is always the first application time applications are also available as to be started. In a minimal OTP system, building blocks in the development envi- the kernel is one of only two applications. ronment (Figures 3 and 4). The kernel application contains the fol- lowing services: Erlang virtual machine – application_controller The Erlang virtual machine runs on top of – auth a host operating system. The Erlang run- – code time system frequently runs as a single – error_logger process in the host operating system. The – file Erlang virtual machine provides the fol- – global_name_server lowing support for Erlang programs: – net_kernel – Consistent operating system interface – rpc on all platforms. – user

Ericsson Review No. 1, 1997 21 The kernel application also includes stan- tem. It also bars inconsistencies from dard error_logger event handlers. being introduced into the data (status control) when several corresponding Mnemosyne – the query language changes are made. The Mnesia DBMS is organised as a basic – Data may be distributed transparently layer that takes first-order predicate logic over several Erlang nodes. Important with Erlang data types as values. Recur- data is copied to several nodes; less sion, negation, and a simple constraint important data may reside at only one system are also supported. The evalua- location. The distribution of data over tion is set-oriented. In practice, users nodes cuts access time drastically. have a choice of several query shells in – Data is declared to reside in RAM, on which to type their queries and receive secondary storage, or both. their answers. – If a hardware or software node crash- Views of data are displayed according es, the data that it contained may be to the rules defined in the modules. Each reconstructed from redundant copies module corresponds to a file and is com- of the data stored at other nodes, or piled and stored in the database itself. from logged updates. Assuming that The modules and rules are declared in a the data at a particular node is repli- schema. In some instances, even when cated at other live nodes, then the addi- the table is used in the module, the tion or removal of that node will not be schema may be changed by simply recom- observed by users in the system. piling the module. – Data is organised in tables. This pro- vides a sound theoretical basis, and a Mnesia real-time DBMS broad range of well-known, proven In most applications some data must (a) methods for modelling the data. be stored safely and (b) remain easy to – The tables, their organisation, location, access. Requirements vary a great deal; storage type, and other aspects are for example, the amount of data may declared in a schema. Views of data are range from a lot to very little. On the one supported from the API and from the hand, the loss of data from a system query language. crash may be acceptable, whereas in – An optimising query-language compiler other instances, data must survive prac- and evaluator is available for use by tically any kind of system failure. Simi- operators and in the API. larly, some applications require near- instantaneous access time – perhaps OS monitoring only fractions of a millisecond – whereas The OS monitoring application defines in other instances a longer access time the following services: may be acceptable. Moreover, some – disksup – which checks the available applications require a valid prediction of disk space and sends an event if a stat- the access time – real-time access. ed threshold has been passed; In short, despite a broad spectrum of – memsup – which checks the available requirements, it must be easy to update primary memory and sends an event if data without introducing inconsistencies, a stated threshold has been passed. especially when several corresponding changes are made. Also, for operations Read, write and search from the API and maintenance purposes, operators From the basic API, a program – with or must sometimes be able to access data without a transaction – can read and write by means of complicated and non-stan- table entries or merely search a table. dard queries. Multiple, related accesses that involve In response to these requirements, the writing without a transaction are strongly Mnesia DBMS was developed with the fol- discouraged, since they can severely lowing basic properties: damage data. Nonetheless, this option – Data is accessed in two basic ways: has been provided to give immediate • through an API for programs; access to experienced programmers who • using a query language, called need to perform concurrency control Mnemosyne, for humans themselves. Each time the data is read – Read and write access is protected by without a transaction a snapshot is means of transactions. This method taken. gives each user (program or person) the A query language has been provided to impression that he is alone in the sys- facilitate complicated queries, such as

22 Ericsson Review No. 1, 1997 when data from many tables needs to be designers to program a remote procedure combined. The query language, which is call in one line of source code. Examples Box G mainly based on first-order logic, is of standard modules are lists, “ordsets”, Sockets accessed through list comprehension. A “gen_server” and “gen_event”. A socket is a duplex communications channel list comprehension is a functional lan- between two UNIX processes, either over a net- guage construction that is well-suited to Web server work to a remote machine, or locally between processes running on the same machine. A sock- the Erlang programming language. The Web server is a hypertext transfer pro- et connects two parties, the initiator and the con- tocol (HTTP) daemon implemented in nector. The initiator is the UNIX process that first SASL Erlang. Access to the server looks up a opens the socket. It issues a series of system calls to set up the socket and then waits for anoth- The systems architecture support requested Web page and sends it to the er process to create a connection to the socket. libraries (SASL) are designed for building browser. The page may fetch data from a When the connector makes its connections, it embedded real-time Erlang applications, database table or from a function call. also issues a series of system calls to set up the and include a set of standard design tem- Integration is very efficient. socket. Each process then continues running. The communications channel is bound to a file plates that can be used to solve common descriptor that each process uses for reading and programming problems on application Conclusion writing. start, restart and supervision. The open telecom platform (OTP) enables SNMP extensible agent designers to build and run telecommuni- The OTP facilitates use of the SNMP for cations applications on a broad range of operating and maintaining applications standard, commercially available hard- on the OTP. SNMP support consists of ware and software platforms. The OTP run-time support in the form of an exten- also allows designers who program in C, sible agent, and development support in C++, Java and other languages to inte- the form of an MIB compiler and a pro- grate sourced components – protocol gramming model for implementing MIBs. stacks, APIs, I/O units and drivers – into The extensible agent uses two mecha- their applications. nisms that provide an environment where The OTP comes with an exhaustive col- MIB modules can be loaded/unloaded in lection of tools and building blocks, such an efficient plug-and-play fashion. These as the programming language Erlang, sys- mechanisms include dynamic MIB load- tems architecture support libraries ing and sub-agent handling. (SASL), a real-time database manage- ment system (DBMS), an extensible Sockets SNMP agent, and a Web server. Sockets are the Berkeley software distri- As a design environment, the main bution (BSD) UNIX interface to communi- strengths of the OTP are: time to mar- cation protocols. Various protocols may ket; compatibility with many different be accessed through sockets. The sock- computer platforms and sourced com- et module provides an interface to the ponents; up-to-date hardware and soft- BSD UNIX sockets. The udp module sup- ware technology; and reliability. What is ports user datagram protocol/Internet more, the OTP permits designers to con- protocol (UDP/IP) sockets. sider costs when they match computer platforms with requirements for pro- Standard modules and libraries cessing power and component avail- The Erlang programming environment ability. contains several standard reusable soft- As a target enviroment, the OTP meets ware modules. The functional program all basic telecommunications require- paradigm on which Erlang is based great- ments. It has a real-time distributed con- ly facilitates reusing software. trol system that is fault-tolerant, and that Many standard modules are specially can handle software upgrades while it is adapted to the needs of concurrent dis- running. In addition, the OTP can easily tributed systems. The remote procedure be ported to several different commercial call (RPC) module, for example, allows operating systems.

References 1 Däcker, B.; Erlang – A new program- ming language. Ericsson Review 70 (1993:2), pp. 51-57.

Ericsson Review No. 1, 1997 23