Open Access BASE2018

Simulation of a Message Switching System with Ada Objects ; Technical Report 2018-07-ECE-020 Technical Report 88-CSE-14

Abstract

Ada is a general-purpose programming language with considerable expressive power. It is a language that embodies and enforces the modern software engineering principles of abstraction, information hiding, modularity, and locality. Following an object-oriented design technique, this paper illustrates the use of Ada for the design and implementation of a message switching simulation system. Message switching simulation poses a number of interesting problems: a high degree of concurrent activity, a variety of I/O devices to be considered, and messages with multiple destinations. In this paper, we will discuss how Ada is used in an object-oriented fashion in solving these problems. ; Technical Report 2018-07-ECE-020 Technical Report 88-CSE-14 Simulation of a Message Switching System with Ada Objects W. P. Yin Murat M. Tanik This technical report is a reissue of a teclmical report issued March 1988 Department of Electrical and Computer Engineering University of Alabama at Birmingham July 2018 Technical Report 88-CSE-14 SIMULATION OF A MESSAGE SWITCHING SYSTEM WITH ADA OBJECTS W. P. Yin M. M. Tanik Department of Computer Science and Engineering Southern Methodist University Dallas, Texas 75275-0122 March 1988 Simulation of a Message Switching System with Ada Objects 1-'V. P. Yin J.1. M. Tanik Department of Computer Science and Engineering Southern Methodist University Dallas, TX 75275 Abstract - Ada is a general-purpose programmmg language with considerable expressive power. It is a language that em bodies and enforces the modern software engineering principles of abstraction, information biding, modularity, and locality. Following an object-oriented design technique, this paper illustrates the use of Ada for the design and implementation of a message switching simulation system . Message switching simulation poses a number of interesting problems: a high degree of concurrent activity, a variety of I / 0 devices to be controlled, and messages with multiple destinations. In this paper, we will discuss how Ada is used in an object-oriented fashion in solving these problems. 1. Introduction Ada is a general-purpose programming language developed with the initiative of the U.S. Department of Defense in response to the crisis in software development [1]. As Wegner points out, there are several features in Ada that directly support modern software engineering principles [2 ]: • A rich variety of program units, including subprograms, packages, and tasks. • Systematic separation between visible syntactic interface specifications and hidden bodies that allow the programmer to separate concerns of module interconnections from concerns about how modules perform their task. • Strong typing, which imposes constraints on module interconnections and allows consistency between formal parameters of module definitions and actual parameters of module invocations to be enforced at compile time . • Genetic program units, which are parameterized templates for generating software components. • Program libraries with separately compiled reusable program units. There is a trend that software engineers treat Ada as an expressive language rather than just a programming language . Ada, thus serves not just to program some computer but as a program design language (PDL) that captures the concrete implementation of software compo n en ts [ 1] . In this paper, the design of one specific example, a message switching simulation system [3] is developed using Ada. Our objectives are : 1) to present an object-oriented system design technique; 2) to illustrate the use of Ada as an assistant for design documentation; 3) to describe the use of Ada as implementation language . A message switching simulation - 2 - system was chosen as the application because it shows the range of Ada's applicability and presents a number of interesting implementation problems. Ada was chosen as the target language because it is specifically intended for dedicated real-time, multitasking systems, and provides much needed facilities for parallel execution. The specific design technique used here is described m section 2. The communication system itself is developed in section 3 through 5. Section 3 specifies the functions and external interfaces of the system . Section 4 presents the system organization, information and control flow, and module interfaces in terms of Ada components. Section 5 describes some related simulation issues by giving outlines of Ada programs for the most interesting parts of the system. Finally, section 6 summaries the utility of Ada for the design of software systems by reflecting on aspects of the communication systems and reusable software components. 2. Design Technique The design described here is developed in two major steps: system decompositions and component abstractions. We use the object-oriented decomposition because it gives system designers a good opportunity to concentrate on both structures and functions of entities in the application . Therefore, designers can work at the level of general construction and function descriptions, but not to the degree of precision necessary for executability. The decomposition step involves specifying the major components of the system, their structures and their behaviors. It includes outlining the data blocks and operations for each component. This step will characterize what information is processed and express the user's view of system. The abstraction step will specify the way of system integration. It involves changing the level of decomposition, ignoring certain details in an effort to couple the system components. In our simulation system design with Ada, various organizations were considered to support the system components. The specification of integration includes specifying the information [ flow, control sketch and other connections. 3. Specification of a Message Switching Communication System A typical message switching system [3] has been chosen as an example to show the details of Ada's capabilities because it is a problem that is realistic in nature and implements many of the concepts of em bedded systems. This generalized system is typical of several communication systems used by the U.S. government and NATO. The complete system consists of a network of switching nodes connected via high-speed trunk lines. Each switching node has an auxiliary memory, an archive facility and an operator, and can support up to fifty subscriber terminals. Figure 1 shows the configuration for a given node in the system . The general function of each node is to accept input messages from the trunk or local subscriber lines, and route them to one or more output destinations. Input can be received from local subscribers or from another switching node (via the trunk line). The input message is stored in the auxiliary memory and then forwarded to the output destinations, which - 3 - Subscriber- Switching Node Trunk Huniliar-y Me10or-y Hrchiue Tape Table Figure 1. The typical configuration for a local node. Can be either the local subscribers or another node in the network. Since messages must be completely received before forwarded , this type of communication is often called store and forward message switching. Three successive phases are required to process each message: input, switching, and output. The following summary describes the processing that must be done during each of these phases. Input Read the input message from a subscriber or trunk link and store the message on both auxiliary memory and archive tapes. Each input message consists of a header, a body and an end mark (end-of-message indicator) . Switch Examine the header to determine the output destinations. For each destination, consult a directory to determine the appropriate output line. to use (local subscriber or trunk to remote destination) . Add a copy of the message header to the output queue on each line. Output Retrieve the message from the auxiliary memory and display it. Each message contains a priority-at all times the message with the highest priority is transmitted first. Each node has an operator who can send and retrieve messages like a subscriber. In addition , he can monitor and control the message activity at the node . For example, he can cancel a message or check the messages in each output queue. Also the operator is notified of exceptions-for example, end of archive_ tape . In our simulation system design , we will - 4 - ignore the operator because the mam function of our design is to simulate how the switching node process messages. The simulation system addresses the following requirements. • Maximum 1/ 0 parallelism must be provided. • There are two different types of 1/0 devices (trunks and terminals), both process messages. • Switch must coordinate output to multiple destinations. • All the messages have a priority. • The auxiliary memory and terminal devices must be controlled and synchronized because we are simulating more than one 1/0 device. Now, we turn our attention to the design of a message switching simulation system m Ada that solves those problems. 4. System Architecture in Ada The Ada programming language supports modern programming practices and integrates features. Ada packages offer the opportunity for defining data structure and operations on those structures. This capability provides abstraction previously not available in widely used languages. A package consists of a specification which is all the user of the abstraction need to know and a body (implementation) which provides application specific facilities which other programmers may use. The specific implementation details may be hidden by the use of the PRIVATE facility. A design using these facilities will provide a good level of modularity and information hiding. Ada tasks provide facilities to define and control concurrent processes. Independent tasks may be defined and synchronized by rendezvous. Those tasks will proceed in parallel, at least logically, execute on separate processors. A task may call another task by specifying an ENTRY point. A called task is synchronized by executing an ACCEPT statement. The type of synchronization offered by this rendezvous model allows a natural implementation of a number of communication and synchronization protocols such as message passmg. For our purposes, the Ada package and task concepts are adequate to model the set of activities of the message switching system. A . System Components According to Grady Booch [2]: "simply stated, object-oriented development is an approach to software design and implementation in which the decomposition of a system is based upon the concept of an object. An object is an entity whose behavior is characterized by the operations that it suffers and it requires of other objects." Using object-oriented design methodology, an object existing in the model of reality will have a corresponding structureentity in the solution . As specified in the previous section, each message processed by a switching node goes through three phases: Input, ·switch, and output. Analyzing the problem space , it is observed that there are several different objects participate these three phases (1 / 0 - 5 - de vices for sending and reading messages, a temporary memory for storing messages, a long term memory for backup messages, a refere nce table for destination list, and a switching node schedules message transmission) . The decomposition is show in the figure 2. Using Ada, we can design the system decompositio n in the following way. Msg. boay 1 Ruailiary ~ : Memory 'I / 1 ,_' Msg. header-- ·,, 1\ I I L Oest. line5 Input lines i 1 / I \ . utput --- .t-•\lnput 1-•'-.-tt-~, Switching . _ '._, --~--~ !IIIII --~ Msg. body & header Hn:hiue Tape ·=· =j I I ·· .'i . c-·,.) I Table · l_.~ Figure 2. Message switch system components The auxiliary memory provides a temporary storage for messages. In particular, it provides READ and WRITE processes with sequential structures. For the efficiency reasons, we need to handle each message by blocks rather than characters. It, therefore , has two levels, en tire message level and a block level. The block level is nested inside the message level, since a message is composed of several blocks. This leads to the following Ada specification. package AUX_MEMYKG is type MSG_ACCESS is private; type DIRECTORY_ACCESS is private; procedure WRITE_BLOCK (NEW_BLOCK : in BLOCK; NEW_CELL :in out MSG_ACCESS; AUX_MEM_BLOCK: outMSG_ACCESS); procedure WRITE_DIRECTORY (FIRST_BLOCK :in out MSG_ACCESS; AUX_MEM_HEADER: out DIRECTORY _ACCESS) ; - 6 - procedure READ_BLOCK (NEW _BLOCK :out BLOCK; AUX_MEM_BLOCK :in outMSG_ACCESS); procedure READ _DIRECTORY (FIRST_BLOCK : out MSG_ACCESS; AUX_MEM_HEADER: in out DIRECTORY ACCESS); AUX_MEM_ERROR : exception ; AUX_MEM_OVERFLOW : exception; private end AUX_MEM_FKG Subscribers and trunks are full-duplex, they have both input and output capabilities. Input capability provides the facility for subscribers and trunks reading messages sent to them ; and output capability provides the facility of sending messages to others. Subscribers and trunks handle different devices, but the functionalities are similar. It results the following Ada package design . package NOD E_FKG is function GET_HEADER(PORT : in DEVICE) return HEADER; procedure GET_BLOCK(MSG_TEXT: out BLOCK; EOF :out BOOLEAN); procedure PUT_HEADER(MSG_HEADER: in HEADER; PORT : in DEVICE) ; procedure PUT_BLOCK(MSG_TEXT: in BLOCK); end NODE_FKG; The switch is the central control process of our simulation system. It serves as a coordinator for multiple message destinations . It needs to talk to every subscriber and trunk , knowing the message source and distinguishing the multiple destinations. Therefore switch itself needs "READ " and "WRITE" functions , too. The Ada specification is as the following. package SWITCH_FKG is procedure PUT_HEADER(MSG_HEADER: in HEADER; PORT: in DEVICE) ; procedure PUT_BLOCK (MSG_TEXT : in BLOCK); end SWITCH_FKG; - 7 - B. System Integration Components in a software system are not isolated, but connected together to do a specific task. One important information in the software design is the component integration specification which includes the data flow and control flow specification . Figure 2 shows the data flow. Based upon the system requirement: maximum I/0 parallelism, we choose Ada tasks as interfaces for these components. Ada provides a direct communication mechanism without memory between tasks [4]. It supplies static interfaces between tasks, (i.e., fixed number and type of the entries, and synchronization with rendezvous before communication). This feature also provides necessary visibility requirements in network system . On the other hand, fixed number and type of entries for Ada tasks provide the facility a discrete event system needed. In the message switching system, the messages are transmitted one by one. At all times, a component in the system processes the information not in stream style but a single message. Subscribers and trunks need to communicate with archive tape and auxiliary memory. They also need to communicate with the switch in order to coordinate the message transmission. Those two components repeat the receiving (reading from the auxiliary memory and output to the terminal) and sending (reading from the terminal and writing into both auxiliary and archive tape) actions. During the processing, they only care whether there is any coming message. When they send messages out, they do not concern whether others will read or not. In the same way, the switch needs to communicate with all subscribers and trunks, noticing them there is a message coming. Thus, we add the following specification into the subscriber and trunk package. task COMMUNICATION is entry STARTINGYROCESSING; end COMMUNICATION; For the switch, we add the following task specification into the switch package . task SWITCH is entry STARTING; end SWITCH; The auxiliary memory and archive tape act passively. Until other entities require their actions, the auxiliary memory and archive tape will not communicate with any others. They just wait for request. We specify the interfaces for them as the following. task ARCHIVE_TAPE_HAND LER is entry STARTING; entry ARCHIVE_REQUEST (NEW_MSG : in WHOLE_MSG) ; - 8- en try RETRIEVE_REQUEST (MSG_ID : in ID _RECORD; NEWJvfSG :out WHOLEJvfSG); end ARCHIVE_TAPE_HANDLER; task AUXJvfEM_HANDLER is en try starting; entry WRITEJvfSG (NEWJvfSG.SIZE :in POSITIVE; MSG_BOD Y : in MSG; MSG_ADDRESS :out DIRECTORY _ACCESS) ; entry READJvfSG (NEWJvfSG.SIZE : in POSITIVE; MSG_BODY : out MSG; MSG_ADDRESS : in out DIRECTORY _ACCESS); end A UXJvfEM_HANDLER; 5. Implementation and Simulation Issues We choose Ada as the implementation language, since Ada offers anum ber of features that facilitates the expression of reusable software components, which helps to increase the productivity. For example, generic program units are parameterized templates for generating software components; tasks operates in parallel with other program units; systematic separation between visible syntactic interface specifications and hidden bodies allow the programmer to separate concerns of module interconnections from concerns about how the module performs it task. Ada is used here as an implementation language for message switching system also because it is available in our VAX 11 / 780 under Unix operating system (Verdix Ada 4 .51) , the design written in Ada serves as an intermediate step between detailed system design and coding that helps one develop and reason about the design decisions. A. Global Data Types Subscribers, trunks and switch processes exchange several types of information . The two most important kinds are message header and message body. To facilitate the declaration of variables referring to these types of information and to make use of Ada's type checking facilities, the format of header and block are specified using an individual data package which does not have a body. In particular, a message header and body are specified as the 'followmg. package D A TA_FKG is type DEVICE is (PORT1, POR1'2, PORT3, PORT4, PORTS, PORT6, '@') ; type DESTINATION_LIST is array( l . MAX_OUTPUT_COUNT) of DEVICE; type ID_RECORD 15 --Unique message identifier record _ 9 _ ORIGIN :DEVICE; -- Device ID DATE : CALENDAR.TIME; --Date and time (seconds) end record; type PRIORITY_TYPE is (INFO, ROUTINE, FLASH); -- Possible priorities type HEADER is -- Header record for each message record IDENTIFIER : ID_RECORD; --Message identifier PRIORITY :PRIORITY _TYPE; -- Priority rating SIZE : NATURAL; -- #of blocks of text OUTPUT_COUNT: NATURAL; -- #of destinations DESTINATION : DESTINATION_LIST;-- Destinations of this msg. end record; subtype BLOCK is STRING( 1 . CHARYER_BLOCK); --Block of message text type MSG is array ( LMAX.JviSG_SIZE) of BLOCK; --Entire message text end DATAYKG; B. Message Queue Based upon the requirements for the system , each message has a priority. We decide to use a priority queue to implement priority message transmission. Each time, the switch will process a message that has the highest priority by inserting the message into the destination message queue based upon its priority. And each time, subscribers or trunks will read amessage which has the highest priority from its message queue. Since the message queue is dedicated to its owner, for each subscriber, trunk and switch , we need create one message queue . Ada's generic package· provides a powerful tool in this situation. Generic packages have the ability to create templates of program units with generic parameters that needs at translation time. The specification of generic priority queue is the following. genenc type QUEUE_ENTRY is private; type PRIORITY is limited private; with function PRIORITY_OF(THE_ENTRY : in QUEUE_ENTRY) return PRIORITY; with function " SIGNAL, PRIORITY => PRIORITY_TYPE, PRIORITY_OF => CHECKYRIORITY, " " PORT2, PORT_QUEUE => QUEUE_FKG.SUBSCRIBERLQUEUE, PORT_QUEUE_SEMAPHOR => TABLEYKG.SUBSCRIBERl_QUEUE_8EMAPHOR, GET_HEADER GET_BLOCK PUT_HEADER PUT_BLOCK - 12 - => D EVICE_D RIVERSYKG .GET _HEADER_ VT100, = > D EVI CE_j) RIVERS_?KG .G ET_BLOCK_ VT100, = > D EVI CE_D RIVERSYKG .PUT _HEADER_ VT100, = > D EVICE_D RIVERS_?KG .PUT _BLOCK_ VT100) ; package TRUNK is new NODEYKG (PORT => PORTS, PORT_QUEUE => QUEUEYKG.TRUNK_QUEUE, PORT_QUEUE_.SEMAPHOR => TABLEYKG.TRUNK_QUEUE_8EMAPHOR, GET_HEADER = > DEVICE_DRIVERSYKG.GET_HEADER_TRUNK, GET_BLOCK = > DEVICE_DRIVERSYKG.GET_BLOCK_TRUNK, PUT_HEADER PUT_BLOCK => DEVICE_DRIVERS_?KG.PUT_HEADER_TRUNK, = > D EVICE_j) RIVERSYKG .PUT_BLOCK_TR U NK) ; Here, we need to mention Ada's another good feature , rename. During the system modelling, we specified that it was possible to send messages to the switch . Therefore, the switch also needs function , writing messages to the terminal, just as subscribers and trunks do. For the simulation reasons, we do not need to program two different sets of code to do this. Ada's rename facility provides what we need. The rename facility is used in SWITCHYKG to benefit the reusable component and avoid the ambiguities. The clearer specification for SWITCHYKG is the following. package SWITCHYKG is procedure PUT_HEADER(MSG_HEADER : in HEADER; PORT : in DEVICE) renames D EVI CE_j) RIVERSYKG .PUT _HEADER_ VT100; procedure PUT_BLOCK (MSG_TEXT : in BLOCK) renames D EVI CE_D RIVERSYKG .PUT _BL OCIL VT100; task SWITCH is entry STARTING; end SWITCH; end SWITCHYKG; D. Simulation Control Message switching system is a multiple processing system, but we simulate this multiple 1/ 0 device activities on a single I /0 device -one terminal. It's necessary to synchronize the access to the terminal. This synchronization is implemented by an Ada task. The semantics of - 13 - Ada tasks guarantee the mutual exclusion. Only one task can access the terminal at a time , and if more than one task try to access at the same time, the rest have to wait in an implicit queue so as not to interfere with each other. If those tasks arrive at different times, the first task will be permitted accessing first, the rest wait in the queue based upon the time stamp. The task for synchronizing the terminal access is the following. task IO_$YNC is entry REQUEST.JO_DEVICE; entry RELEASE.JO_DEVICE; end IO_$YNC; task body IO_$YNC is BUSY : BOOLEAN := false ; begin loop select when not BUSY=> or accept REQUEST.JO_D EVICE do BUSY := true ; end REQUEST.JO_DEVICE; accept RELEASE.JO_DEVICE do BUSY :=false; end RELEASE.JO_DEVICE; end select; end loop; end IO_$YNC; Actually, all the message queues should be accessed in a mutual exclusive manner, since subscriber task, trunk task and switch task logically operate in parallel with each other. In our implementation, all message queues are shared by two tasks , the switch task and queue owner task. The switch will insert the coming message to the message queue, and the queue owner will remove the message from the message queue . We need to consider the mutual exclusion problem because the queue operations are not atomic operations based upon our software implementation. If we did not treat queue operations in a mutual exclusive manner then there would be errors. 6. Conclusion Through the design and implementation activities of message switching system, we feel that Ada is suitable for dedicated multiprogramming systems such as the message switch implementation. The major units of Ada-packages, tasks and subprograms-were both - 14 - appropriate and easy to use. One of the easiest ways to tell if a language is suited to the problem is to see whether it helps or hinders the design of system functions into a program implementation. A good target language should guide the organization and implementation by providing a structured framework and adequate facilities [3]. Ada worked well for this switch simulation program organization. For example, the tasks made it easy to implement process communication and synchronization, the package with private data type provided encapsulated implementation algorithm, data abstraction and information hiding. The second positive aspect of Ada is the facility of generic package . It provides much needed reusability and flexibility. The parameters of generic packages can not only be usual variables, but also data types, functions, and procedures. In addition, generic packages can be nested. Those features are just what we needed when we deal with the problems that are logically same. Thirdly, Ada's programming environment allows systematic separation between visible syntactic interface specifications and hidden bodies. Here the separation includes syntactic separation, and compilation separation . Many errors, not only syntax error, but also the static semantics errors, are discovered during the compilation. References [1] G. Booch, Software Components With. Ada, The Benjamin/Cummings Publishing Company, Inc., 1987. [2] P. Wegner, "Capital-Intensive Software Technology," IEEE Software, vol. 1(3), July 1984. [3] G. R. Andrews, "The Design of a Message Switching System: An Application and Evaluation of Modula," IEEE Tran. Software Eng., vol. SE-5(2), March 1979. [4] A. Fantechi, P. Inverardi and N. Lijtmaer, "Using High Level Languages for Local Computer Network Communication: A Case study in Ada," SOFTWARE-PRACTICE and EXPERIENCE, vol. 16(8), August 1980.

Problem melden

Wenn Sie Probleme mit dem Zugriff auf einen gefundenen Titel haben, können Sie sich über dieses Formular gern an uns wenden. Schreiben Sie uns hierüber auch gern, wenn Ihnen Fehler in der Titelanzeige aufgefallen sind.