-
Notifications
You must be signed in to change notification settings - Fork 1
/
scscp.tex
1415 lines (1227 loc) · 52.2 KB
/
scscp.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\documentclass{amsart}
\usepackage{graphicx}
\hyphenation{ge-ne-ra-tors}
\title[SCSCP Specification]{Symbolic Computation Software Composability Protocol (SCSCP) specification \\ Version 1.3}
\author{S.~Freundt, P.~Horn, A.~Konovalov, S.~Linton, D.~Roozemond}
\address{Sebastian Freundt
\newline Fakult\"at II - Institut f\"ur Mathematik,
\newline Technische Universit\"at Berlin, Berlin, Germany}
\email{[email protected]}
\address{Peter Horn
\newline Fachbereich Mathematik, Universit\"at Kassel, Kassel, Germany}
\email{[email protected]}
\address{Alexander Konovalov
\newline School of Computer Science, University of St Andrews,
\newline North Haugh, St Andrews, Fife, KY16 9SX, Scotland}
\email{[email protected]}
\address{Steve Linton
\newline School of Computer Science, University of St Andrews,
\newline North Haugh, St Andrews, Fife, KY16 9SX, Scotland}
\email{[email protected]}
\address{Dan Roozemond
\newline Department of Mathematics and Computer Science,
\newline Technische Universiteit Eindhoven,
\newline HG 9.55, Postbus 513, 5600 MB Eindhoven, Netherlands}
\email{[email protected]}
\thanks{The project 026133 ``SCIEnce - Symbolic Computation Infrastructure in Europe'' is supported by the EU FP6 Programme}
\begin{document}
\thispagestyle{empty}
\hspace{-15mm}
\begin{minipage}{60mm}
\rule{0pt}{0pt}\par\vfill
\includegraphics[width=60mm]{SCSCP_logo}
\par\vfill\rule{0pt}{0pt}
\end{minipage}
\ \hspace{50mm}
\begin{minipage}{40mm}
\rule{0pt}{0pt}\par\vfill
\includegraphics[width=40mm]{SCIEnce_logo}
\par\vfill\rule{0pt}{0pt}
\end{minipage}
\vspace{15mm}
\begin{center}
\sc
\Large
S. Freundt,
P. Horn,
A. Konovalov, \\
S. Linton,
D. Roozemond \\
\vspace{10mm}
\Huge
Symbolic Computation Software Composability Protocol \\
\vspace{10mm}
SCSCP\\
\vspace{10mm}
Specification,
Version 1.3 \\
\vspace{10mm}
\Large
\today \\
\vspace{40mm}
{\Small The project 026133 ``SCIEnce - Symbolic Computation Infrastructure in Europe'' \\
is supported by the EU FP6 Programme}
\end{center}
\newpage
\tableofcontents
\newpage
%#########################################
\section{Introduction}
%#########################################
This document specifies the requirements for the software to be developed
by the NA3 activity of the SCIEnce project for the subsequent usage in the
NA3 and JRA1 activities.
Specifically it describes a protocol by which a CAS may offer
services and a client may employ them. This protocol is called the
{\it Symbolic Computation Software Composability Protocol}, or {\bf SCSCP}.
We envisage clients for this protocol including:
\begin{itemize}
\item A Web server which passes on the same services as Web services
using SOAP/HTTP to a variety of possible clients;
\item Grid middleware;
\item Another instance of the same CAS (in a parallel computing context);
\item Another CAS running on the same system.
\end{itemize}
Note that the specification assumes two possible ways of implementation.
One is the standard socket-based implementation, where a CAS can
talk locally or remotely via ports, as described in the section \ref{implement},
in fact an SCSCP service rather than a Web service.
The other implementation is a proper Web service using standard SOAP/HTTP wrappings for SCSCP messages.
In the SCSCP specification we will use the term {\it Web services} in the broad sense,
meaning both kinds of symbolic computation services.
Our vision of the SCSCP usage is described in the following scheme.
\centerline{\resizebox{130mm}{!}{\includegraphics{scheme_SCSCP}}}
\centerline{\small{Figure 1. SCSCP usage.}}
\vspace{15pt}
In Section \ref{semantic} we describe the meaning of the possible messages
that can appear during communication between various software and the
allowed sequences of such messages. In Section \ref{tech} we
specify how these messages are encoded as OpenMath objects.
Finally in Section \ref{implement} we describe one
solution (suitable for UNIX systems, at least) for the practical
problems of establishing a connection and delivering these messages.
In Appendix A we specify the list of necessary OpenMath symbols.
Examples of OpenMath messages are given in Appendices B and C.
More examples may be found in the {\tt scscp1} and {\tt scscp2} OpenMath
Content Dictionaries: \cite{scscp1}, \cite{scscp2}.
\vspace{5pt}
List of abbreviations used in the document:
\begin{description}
\item[CAS] Computer Algebra System
\item[CD] Content Dictionary
\item[OM] OpenMath
\item[PI] processing instruction (in XML)
\item[SCSCP] Symbolic Computation Software Composability Protocol
\item[WS] Web Service
\item[WSDL] Web Services Description Language
\end{description}
%#########################################
\section{Semantic descriptions}\label{semantic}
%#########################################
\subsection{Messages from client to server}
\subsubsection{Procedure call}\label{sec_semantic_msgs_procedurecall}
This is an OM message containing the following information:
\begin{itemize}
\item {\it Procedure name} - the name of the procedure registered as a web-service;
\item {\it Arguments} - arguments that will be passed to the procedure being called;
(Remark: we treat procedure options, such as guidance options for used algorithms, as
arguments as well);
\item {\it Options/Attributes} - attributes and options that specify the expected behaviour
of the system. Mandatory options are:
\begin{itemize}
\item call identifier (unique in the scscp session);
\item type of action performed with the result (precisely one must be given)
\begin{itemize}
\item storing the result at the server side and returning a cookie referring to it;
\item returning the result of the procedure (that may involve the actual computation or the retrieval of a previously stored result);
\item not returning the result itself, only a message indicating whether the procedure completed successfully or not;
\end{itemize}
\end{itemize}
Non-mandatory options are, for example:
\begin{itemize}
\item procedure runtime limit;
\item minimal/maximal memory limits;
\item debugging level, determining degree of output detail;
\item other options that might appear during the development; may be system dependent.
\end{itemize}
\end{itemize}
There are some standard procedures predefined in Section \ref{spec-proc}.
Besides this, in order to provide specific SCSCP services, the service provider should
develop and make available their own customized procedures, which may range from
generic services (e.g. we may imagine some procedure named like {\sf EVALUATE\_OMOBJ}
to evaluate given OM object) to specific (e.g. compute the determinant of a matrix).
\subsubsection{Interrupt signal}
This signal implies that the results of one particular computation are not needed, so the CAS need not complete the computation. After receiving an interrupt signal, the server must, as always, reply to the procedure call with the mentioned call ID. It must still reply to the procedure calls in the order they were received in. For example, if the client sends procedure calls $A$,$B$,$C$ and then an interrupt signal for $B$ while the server is still computing $A$, the server must still reply to $A$ before it sends a procedure terminated message for $B$.
Note that it is always correct for a CAS to ignore an interrupt, and thus simply reply with a procedure completed message. This may be appropriate when procedure calls are quick.
Note also that in earlier versions of the protocol the Interrupt signal was implemented using POSIX signals, but from version 1.3 onwards the signal is implemented by the {\tt <?scscp terminate?>} processing instruction. See Section \ref{sec_impl_interrupt}.
\subsection{Messages from server to client}
\subsubsection{Procedure completed}
This is an OM message containing the information about the result of the procedure:
\begin{itemize}
\item {\it Result value} - if the procedure returns a result, it must be contained in
this section of the message.
If the procedure only produces side-effects, such a section is not necessary since
this message itself acts as a signal about its successful completion;
\item {\it Mandatory additional information:}
\begin{itemize}
\item call identifier;
\end{itemize}
\item {\it Optional additional information:}
\begin{itemize}
\item procedure runtime;
\item memory used;
\item other information that we might need (may be system dependent).
\end{itemize}
\end{itemize}
\subsubsection{Procedure terminated}
This is an OM message that acts as a signal about procedure termination.
\begin{itemize}
\item {\it Error}\,: in its body, the message must contain an appropriate error, as described for example in the {\tt scscp1} OpenMath Content Dictionary.
\item {\it Mandatory additional information:}
\begin{itemize}
\item call identifier;
\end{itemize}
\item {\it Optional additional information:}
\begin{itemize}
\item procedure runtime before termination;
\item memory used;
\item other information that we might need (may be system dependent).
\end{itemize}
\end{itemize}
\subsection{Allowed sequences of messages}\label{sec_semt_allowedseq}
Once a connection has been established and any initial technical
information exchanged (the mechanism for which is
part of an implementation of this protocol and addressed in Section
\ref{implement}) the SCSCP session is considered to be opened.
Until the end of the session, the communication from client to server is
a stream of procedure calls and the response is a stream of procedure
completed and/or procedure terminated messages. The client is permitted
to send as many procedure calls as it likes, subject to the buffering
capabilities of the channel used in a particular implementation. The server must
process them in sequence and send {\it either} a procedure completed,
{\it or} a procedure terminated message (but not both) for each procedure call received.
Apart from this, the client can send an interrupt message to the server.
The interrupt message can be sent to the server at any time.
It entitles the server to stop processing one procedure call and
respond to it with a suitable procedure terminated message.
\section{Special Procedures}\label{spec-proc}
This section documents certain predefined procedures which every
compliant client is expected to support. OpenMath symbols corresponding
to these procedures are defined in the \verb|scscp2| Content
Dictionary \cite{scscp2}.
\subsection{Determining the list of supported procedures}
\subsubsection {Representing Collections of OpenMath Symbols}
A number of the procedures defined in this section return values which
are intended to represent sets of OM symbols. For convenience, we
define a standard way of representing these sets.
Such sets should be represented as applications of the symbol
\verb|symbol_set| which may take any number of arguments. Each of those
arguments should be one of the following:
\begin{enumerate}
\item An OpenMath symbol, representing itself,
\item An application of one of symbols \verb|CDName| or \verb|CDURL|
from the \verb|meta| CD, representing all the symbols in the referenced CD;
\item An application of one of the symbols \verb|CDGroupName| or
\verb|CDGroupURL| from the \verb|metagrp| CD;
representing all the symbols in all CDs in the referenced CD group.
\end{enumerate}
As an alternative, the symbol \verb|symbol_set_all| can be used, to
represent the set of all OpenMath symbols from any CD.
\subsubsection {Transient CDs}\label{sec_special_transient}
In describing its allowed procedure calls according to the conventions
of this section, a server is permitted to refer to symbols from CDs with
names beginning \verb|scscp_transient_| (note the lower case).
These are content dictionaries
defined by this server, and valid only for the duration of the
session. If needed, the client can request these CDs using the
\verb|get_transient_cd| procedure (see below).
\subsubsection{Requesting the Allowed Procedure Names}
The first standard procedure defined in this section is
\verb|get_allowed_heads|, which takes no arguments.
This returns, in the above format, the set of
OpenMath symbols which might be allowed to appear as ``head'' symbol (ie
first child of the outermost \verb|<OMA>|) in an SCSCP procedure call to
this server. These may be symbols from standard OpenMath CDs or from
transient CDs as described above.
A second standard procedure is \verb|is_allowed_head|. It takes only one
argument, which is to be an OpenMath symbol. The server returns a boolean,
\verb|logic1.true| or \verb|logic1.false|, depending on whether it accepts this
symbol. This enables the client to check whether a particular symbol is allowed
without requesting the full symbol list.
Note that it is acceptable (although
not necessarily desirable) for a server to
``overstate'' the set of symbols it accepts and use standard OpenMath
errors to reject requests later.
\subsubsection{Requesting Signature Information}
The standard procedure \verb|get_signature| takes one argument: an
OpenMath symbol. If the supplied symbol is one of those accepted as a
head symbol by the server then it returns an application of the \verb|signature|
symbol. This symbol takes four arguments:
\begin{itemize}
\item an OpenMath symbol indicating which signature is described;
\item a minimum number of children ({\it min});
\item a maximum number of children ({\it max}),
which could be the \verb|infinity| symbol from the \verb|nums1| CD);
\item a set of symbols, represented as an application of the
symbol \verb|symbol_set|, or a list of \verb|symbol_set|s:
\begin{itemize}
\item if the list of \verb|symbol_set|s is given, then its $i$-th entry
corresponds to the $i$-th argument;
\item if just one \verb|symbol_set| is given, it represents that every argument
should come from this set.
\end{itemize}
\end{itemize}
\subsubsection{Requesting Transient CDs}
The standard procedure \verb|get_transient_cd| takes one argument -- an
application of the \verb|CDName| symbol from \verb|meta|, which should
start with \verb|scscp_transient_|, and returns the corresponding CD, encoded
using symbols from the \verb|meta| CD. If no such transient CD is
defined by this server it returns the \verb|procedure_terminated| message
with OM error containing the symbol \verb|no_such_transient_cd|
(from the \verb|scscp2| CD) and the name of the CD that caused the problem.
\subsubsection{Requesting general description of the service}
The service provider may have various parameters describing an offered service.
The connection initiation message contains only the service name, version and
identifier, and this is not enough. Instead of this, some meta-information
about the service may be structured and retrieved by a special standard
procedure \verb|get_service_description|. It takes no arguments, since it is
completely determined by the server to which it was sent, and returns the
symbol \verb|service_description| that takes the following three arguments as OM strings:
server name, version and the description of the service. The latter may include
for example functions exposed, resources, contact details of service provider, etc.
%\footnote{should we specify more precisely what must be in the description
%or provide a template for it? I (AK) think the description may be a list
%of pairs "field\_name" - "string description", and the template may have
%some recommended set of field names. Then I can convert them into a GAP
%record, for example)}
\subsection{Operations with remote objects}
\subsubsection{Storing, retrieving and deleting remote objects}
The following symbols are defined in the \verb|scscp2| CD \cite{scscp2}
to work with remote objects:
\begin{description}
\item[\tt{store\_session}] store an object on the server side (possibly
after computing or simplyfying it),
returning a cookie (actually, an OM reference) pointing to that object.
This cookie is then usable within the current session to get access
to the actual object;
\item[\tt{store\_persistent}] store an object on the server side (possibly
after computing or simplyfying it),
returning a cookie (actually, an OM reference) pointing to that object.
This cookie is then usable in the foreseeable future, possibly from
different sessions, to get access to the actual object;
\item[\tt{retrieve}] using the cookie that was obtained earlier by
one of the store procedures or another procedure call, return
an OM object representing the object referred by the cookie;
\item[\tt{unbind}] remove the object referred by the cookie from the server.
\end{description}
The service provider should be able to decide whether clients are
allowed to create remote objects or not.
%#########################################
\section{Technical descriptions}\label{tech}
%#########################################
\subsection{Messages from client to server}
\subsubsection{Procedure call}
The procedure call is an OM object having in general
the following structure:
\begin{verbatim}
<OMOBJ>
<OMATTR>
<!-- call_id and option_return_... are mandatory -->
<OMATP>
<OMS cd="scscp1" name="call_id" />
<OMSTR>call_identifier</OMSTR>
<OMS cd="scscp1" name="option_runtime" />
<OMI>runtime_limit_in_milliseconds</OMI>
<OMS cd="scscp1" name="option_min_memory" />
<OMI>minimal_memory_required_in_bytes</OMI>
<OMS cd="scscp1" name="option_max_memory" />
<OMI>memory_limit_in_bytes</OMI>
<OMS cd="scscp1" name="option_debuglevel" />
<OMI>debuglevel_value</OMI>
<OMS cd="scscp1" name="option_return_object" />
<OMSTR></OMSTR>
</OMATP>
<!-- Attribution pairs finished, now the procedure call -->
<OMA>
<OMS cd="scscp1" name="procedure_call" />
<OMA>
<OMS cd="..." name="..."/>
<!-- Argument 1 -->
<!-- ... -->
<!-- Argument M -->
</OMA>
</OMA>
</OMATTR>
</OMOBJ>
\end{verbatim}
Remarks:
\begin{enumerate}
\item
The first OM object in the argument of \verb|procedure_call| is the
name of the procedure, the remaining OM objects are its arguments. It may come
from any (standard or non-standard) content dictionary, including transient CDs
such as described in Section \ref{sec_special_transient}.
\item
OM symbols for options will be introduced accordingly to the list of options
given in Section \ref{sec_semantic_msgs_procedurecall}.
If the need for new options is discovered, new OM
symbols for them will be added to future CDs.
\item
Options (except the \verb|call_id| and one of the options \verb|option_return_cookie|, \\
\verb|option_return_nothing| or \verb|option_return_object|)
may be omitted in the procedure call,
and in this case their default values must be used.
The default values of options may be determined by
the service provider, and they are not regulated by the
SCSCP specification.
\end{enumerate}
\subsubsection{Interrupt signal}
See Section \ref{sec_impl_interrupt}.
\subsection{Messages from server to client}
\subsubsection{Procedure completed}
The procedure completion message is an OM object having in general
the following structure:
\begin{verbatim}
<OMOBJ>
<OMATTR>
<!-- Attribution pairs (only call_id is mandatory) -->
<OMATP>
<OMS cd="scscp1" name="call_id" />
<OMSTR>call_identifier</OMSTR>
<OMS cd="scscp1" name="info_runtime" />
<OMI>runtime_in_milliseconds</OMI>
<OMS cd="scscp1" name="info_memory" />
<OMI>used_memory_in_bytes</OMI>
<OMS cd="scscp1" name="info_message" />
<OMSTR>some extra information</OMSTR>
</OMATP>
<!-- Attribution pairs finished, now the result -->
<OMA>
<OMS cd="scscp1" name="procedure_completed" />
<!-- The result itself, may be OM symbol for cookie -->
<!-- OM_object_corresponding_to_the_result -->
</OMA>
</OMATTR>
</OMOBJ>
\end{verbatim}
In case the procedure returns a cookie, the returned OM object must
have the following structure:
\begin{verbatim}
<OMOBJ>
<OMATTR>
<OMATP>
<OMS cd="scscp1" name="call_id" />
<OMSTR>call_identifier</OMSTR>
</OMATP>
<OMA>
<OMS cd="scscp1" name="procedure_completed" />
<OMR href="CAS_variable_identifier" />
</OMA>
</OMATTR>
</OMOBJ>
\end{verbatim}
\subsubsection{Procedure terminated}
The procedure termination message is an OM object having
in the most general case the following structure:
\begin{verbatim}
<OMOBJ>
<OMATTR>
<!-- Attribution pairs (only call_id is mandatory) -->
<OMATP>
<OMS cd="scscp1" name="call_id" />
<OMSTR>call_identifier</OMSTR>
<OMS cd="scscp1" name="info_runtime" />
<OMI>runtime_in_milliseconds</OMI>
<OMS cd="scscp1" name="info_memory" />
<OMI>used_memory_in_bytes</OMI>
</OMATP>
<!-- Attribution pairs finished, now the error message -->
<OMA>
<OMS cd="scscp1" name="procedure_terminated" />
<OME>
<OMS cd="scscp1" name="name_of_standard_error"/>
<!-- Error description depends on error type -->
<OMSTR>Error_message</OMSTR>
</OME>
</OMA>
</OMATTR>
</OMOBJ>
\end{verbatim}
%#########################################
\section{Reference Implementation}\label{implement}
%#########################################
In this section we describe a simple implementation.
To facilitate the implementation, we use XML processing instructions (PI).
All PIs defined by SCSCP specification have the form
\begin{verbatim}
<?scscp [key] [attribute="value" [attribute="value" [...]]] ?>
\end{verbatim}
where:
\begin{itemize}
\item {\tt key} is an alphanumerical identifier,
\item {\tt attribute} is an alphanumerical identifier,
\item {\tt value} is an arbitrary string with the same constraints as an XML URI,
unless stated otherwise.
\end{itemize}
A single SCSCP processing instruction must not exceed 4094 bytes
in total, including \verb|<?| and \verb|?>| elements.
Furthermore, any processing instruction with an unrecognized key must be ignored.
\subsection{Connection Initiation}
The software wishing to provide an SCSCP service should listen on port 26133.
This port has been assigned to SCSCP by the Internet Assigned Numbers Authority
(IANA) in November 2007, see \\ \verb|http://www.iana.org/assignments/port-numbers|.
If the port is already in use, for example in a parallel computing context, the SCSCP
service may listen on another port, for example by increasing the port number by one
until an available port is found.
When a client connects, the server should send it a Connection Initiation
Message, agree about the protocol version, and then commence an
exchange of messages as desribed in Section \ref{sec_semt_allowedseq}.
\subsubsection{Connection Initiation Message}
This processing instruction is the first message that the client
receives from the server in the beginning of the SCSCP session.
Is has the following format:
\begin{verbatim}
<?scscp service_name="name" service_version="ver"
service_id="id" scscp_versions="list_of_supported_versions" ?>
\end{verbatim}
where
\begin{itemize}
\item {\tt "name"} is a string containing the service name,
e.g. {\tt "GAPSmallGroups"}, {\tt "KANT"}, {\tt "MapleIntegration"}, {\tt "MuPAD"}, etc.
\item {\tt "ver"} is a string containing the version of the service,
e.g. {\tt "11"}, {\tt "3.1"}, {\tt "4.1.5beta"}, etc.
\item {\tt "id"} is an identifier for the service, {\bf unique} within
the SCSCP session (e.g. a hostname-pid combination, a pid, etc.).
Note that when the hostname is used, it is advised not to trim off any domain
information from the hostname to avoid situations when the client connected
to multiple hosts may get coinciding service identifiers.
\item \verb|scscp_versions| is a space-separated list of identifiers of
SCSCP versions supported by the server. Identifier of every single
version of SCSCP may contain digits, letters and dots.
Versions can be listed in any order.
For example, valid value of \verb|scscp_versions| is
\verb|"1.0 3.4.1 1.2special"|.
\end{itemize}
The format of the control sequence is compulsory, and server implementations
must not change the order of the attribute/value pairs nor omit some of them.
This strict restriction makes it sure that even very simple clients should be
able to parse this control sequence.
After receiving an incoming connection from a client, the SCSCP server must not
send to the client anything else before the connection initiation message.
The client must wait for this "welcome string" from the server, and must
not send any data to the server before obtaining it.
\subsubsection{Version negotiation}
To ensure compatibility of various versions of the protocol both upwards and
downwards the following version negotiation procedure
should be performed.
After obtaining the connection initiation message from the server,
the client informs the server about the version of the protocol
used by the client, sending the message
\begin{verbatim}
<?scscp version="client_version" ?>
\end{verbatim}
where \verb|"client_version"| is a string denoting the
SCSCP versions supported by the client (for example,
{\tt "1.0"} or {\tt "3.4.1"} or {\tt "1.2special"}).
As the current rule, we require that an official SCSCP client/server
should always support at least the version {\tt "1.0"}.
We expect that the client choose one of the versions listed in the
connection initiation message received from the server. However,
a simple client may ignore that information, because
the server is able to reject any incompatible versions the client may propose.
After receiving the client's SCSCP versions, the server replies with one of two
possible messages:
\begin{itemize}
\item \verb|<?scscp quit reason="not supported version" ?>|,
if the server does not support the version communicated by the client.
The server should subsequently close the connection.
\item \verb|<?scscp version="server_version" ?>| if the server does
support the version communicated by the client. Here \verb|"server_version"|
is a string representing the preferred SCSCP version of the server.
The server should subsequently wait for messages from the client.
\end{itemize}
Remember that in the connection initiation phase, the order of messages is very strict:
\begin{itemize}
\item after receiving an incoming connection, the SCSCP server must not
send anything to the client before the Connection Initiation Message,
\item the client must wait for the Connection Initiation Message from the server,
and must not send any data to the server before obtaining this message,
\item after receiving the Connection Initiation Message the client must send
its version to the server,
\item after receiving the client's version, the server either confirms this
to the client and starts to wait for procedure calls, or rejects it by replying
with the quit message,
\item only after receiving the server's confirmation of the protocol version,
the client is allowed to send procedure calls to the server.
\end{itemize}
Any other data sent in this phase may be ignored.
The only other allowed control sequence during this phase of the protocol
is {\tt <?scscp quit ?>} or \verb|<?scscp quit reason="explanation" ?>|,
issued, for example, when one side is not able to
accept any version proposed by the other side, or issued under external
circumstances, for example, sending messages that are not allowed in this
negotiation phase. In either case, the rules of quitting (see below) are applied.
An example of successful version negotiation:
\begin{verbatim}
Server -> Client:
<?scscp service_name="MuPADserver" service_version="1.1"
service_id="host:26133" scscp_versions="1.0 3.4.1 1.2special" ?>
Client -> Server:
<?scscp version="1.0" ?>
Server -> Client:
<?scscp version="1.0" ?>
\end{verbatim}
An example of failed version negotiation:
\begin{verbatim}
Server -> Client:
<?scscp service_name="MuPADserver" service_version="1.1"
service_id="host:26133" scscp_versions="1.0 3.4.1 1.2special" ?>
Client -> Server:
<?scscp version="1.5beta" ?>
Server -> Client:
<?scscp quit reason="non supported version 1.5beta" ?>
\end{verbatim}
\subsection{Ongoing message exchange}
All messages except interrupts are delivered as XML processing instructions and
OpenMath objects in either the XML or the binary OpenMath encoding, transmitted
via the socket connection.
To locate OpenMath objects in the input/output streams, we put them into
{\it transaction blocks}. The transaction block looks as follows:
\begin{verbatim}
<?scscp start ?>
[a valid OpenMath object]
<?scscp end ?>
\end{verbatim}
Another kind of transaction block have the form
\begin{verbatim}
<?scscp start ?>
[something]
<?scscp cancel ?>
\end{verbatim}
and the {\tt <?scscp cancel ?>} instruction indicates that
the started transaction block is cancelled. The receiver need not to
wait for a matching {\tt <?scscp end ?>} directive, and must not
process/evaluate the data in this transaction block.
Another instruction is {\tt <?scscp quit ?>}, which may also be
used in the long form \verb|<?scscp quit reason="explanation" ?>|,
that indicates that the
sender is about to leave the SCSCP session. Then each side may close
the socket (and at least the receiver may safely disconnect). This
instruction may appear anywhere throughout the session.
Any data after successful version negotiation which are located
outside of transaction blocks (apart from PIs) may be safely ignored.
\subsection{Interrupt}\label{sec_impl_interrupt}
The client may send a processing instruction carrying an
interrupt signal as follows:
\begin{verbatim}
<?scscp terminate call_id="someidentifier" ?>
\end{verbatim}
This PI implies that the results of the computation with call ID \verb|someidentifier|
are not needed, so the server need not complete the computation.
The server may still choose to complete the calculation.
The server must, as always, reply to the \verb|procedure_call| with the mentioned
call ID. It may do this either by sending a \verb|procedure_terminated| or, if the
result is already available, a \verb|procedure_completed| message.
Note that it is always correct for a server to ignore an interrupt, and
that this may be appropriate when procedure calls are quick.
\subsection{Info messages}
We finally describe PIs carrying some information that is not critical for the
functioning of the protocol. These PIs have the form
\begin{verbatim}
<?scscp info="some interesting information" ?>
\end{verbatim}
and may be sent by both the client and the server. They may aid in
debugging a protocol implementation.
\subsection{Other ways of implementation}
We assume that in most cases it will be enough for the SCSCP-compliant
server to support the scheme outlined above, since this provides the
opportunity to ``talk'' in clean SCSCP with other servers supporting this
scheme.
It also allows communication with the SCSCP-proxy server, that accepts
SOAP/HTTP requests from the outside and then sends their SCSCP
content to servers.
However, it is not unconceivable that the server itself is able to receive
SOAP/HTTP requests without the mentioned proxy.
The same refers to the client functionality: if there is a server
that accepts only SOAP/HTTP requests, then this server can send an SCSCP-request
to the proxy which will then act as a proper Web services client, or might
be able to wrap an SCSCP procedure call into a SOAP/HTTP envelope itself.
\newpage
\appendix
\section{The {\tt scscp1} and {\tt scscp2} OM CDs}
\vspace{5pt}
\centerline{ \bf {The list of OM symbols defined in the {\tt scscp1} CD}}
\vspace{10pt}
The {\tt scscp1} CD \cite{scscp1} defines OM symbols
for main types of messages and attributes that may appear in them:
\begin{enumerate}
\item Main messages:
\begin{itemize}
\item \verb|procedure_call|
\item \verb|procedure_completed|
\item \verb|procedure_terminated|
\end{itemize}
\item Call and response identifiers:
\begin{itemize}
\item \verb|call_id|
\end{itemize}
\item Options in procedure calls:
\begin{itemize}
\item \verb|option_max_memory|
\item \verb|option_min_memory|
\item \verb|option_runtime|
\item \verb|option_debuglevel|
\item \verb|option_return_cookie|
\item \verb|option_return_object|
\item \verb|option_return_nothing|
\end{itemize}
\item Information attributes:
\begin{itemize}
\item \verb|info_memory|
\item \verb|info_runtime|
\item \verb|info_message|
\end{itemize}
\item Standard errors:
\begin{itemize}
\item \verb|error_memory|
\item \verb|error_runtime|
\item \verb|error_system_specific|
\end{itemize}
\end{enumerate}
\noindent See the {\tt scscp1} CD \cite{scscp1} for the appropriate descriptions.
\newpage
\centerline{ \bf {The list of OM symbols defined in the {\tt scscp2} CD}}
\vspace{10pt}
The {\tt scscp2} CD \cite{scscp2} defines OM symbols for special procedures, and also
some symbols that may appear in their arguments and results:
\begin{enumerate}
\item Procedures for work with remote objects:
\begin{itemize}
\item \verb|store_session|
\item \verb|store_persistent|
\item \verb|retrieve|
\item \verb|unbind|
\end{itemize}
\item Special procedures to obtain meta-information about SCSCP service:
\begin{itemize}
\item \verb|get_allowed_heads|
\item \verb|is_allowed_head|
\item \verb|get_transient_cd|
\item \verb|get_signature|
\item \verb|get_service_description|
\end{itemize}
\item Special symbols:
\begin{itemize}
\item \verb|signature|
\item \verb|service_description|
\item \verb|symbol_set|
\item \verb|symbol_set_all|
\item \verb|no_such_transient_cd|
\end{itemize}
\end{enumerate}
\noindent See the {\tt scscp2} CD \cite{scscp2} for the appropriate descriptions.
\newpage
\section{Examples of OM messages}
\subsection{The Procedure Call message}
The \verb|GroupIdentificationService| procedure accepts a permutation group $G$
given by its generators and returns the \verb|procedure_completed|
message with the number of this group in the GAP Small Groups Library.
If this fails, for example because groups of order $|G|$ are
not contained in that library or because identification for groups of such order
is not available in GAP, it sends a \verb|procedure_terminated| message.
\begin{verbatim}
<OMOBJ>
<OMATTR>
<OMATP>
<OMS cd="scscp1" name="call_id" />
<OMSTR>symcomp.org:26133:18668:s2sYf1pg</OMSTR>
<OMS cd="scscp1" name="option_runtime" />
<OMI>300000</OMI>
<OMS cd="scscp1" name="option_min_memory" />
<OMI>40964</OMI>
<OMS cd="scscp1" name="option_max_memory" />
<OMI>134217728</OMI>
<OMS cd="scscp1" name="option_debuglevel" />
<OMI>2</OMI>
<OMS cd="scscp1" name="option_return_object" />
<OMSTR></OMSTR>
</OMATP>
<OMA>
<OMS cd="scscp1" name="procedure_call" />
<OMA>
<OMS cd="scscp_transient_1"
name="GroupIdentificationService" />
<OMA>
<OMS cd="group1" name="group"/>
<OMA>
<OMS cd="permut1" name="permutation"/>
<OMI> 2</OMI> <OMI> 3</OMI>
<OMI> 1</OMI>
</OMA>
<OMA>
<OMS cd="permut1" name="permutation"/>
<OMI> 1</OMI> <OMI> 2</OMI>
<OMI> 4</OMI> <OMI> 3</OMI>
</OMA>
</OMA>
</OMA>
</OMA>
</OMATTR>
</OMOBJ>
\end{verbatim}
In the next example we retrieve the group [24,12] from GAP Small Groups Library,
creating it on the GAP side and requesting a cookie for it:
\begin{verbatim}
<OMOBJ>
<OMATTR>
<OMATP>
<OMS cd="scscp1" name="call_id" />
<OMSTR>symcomp.org:26133:18668:GvnaGRLN</OMSTR>
<OMS cd="scscp1" name="option_return_cookie" />
<OMSTR></OMSTR>
</OMATP>
<OMA>
<OMS cd="scscp1" name="procedure_call" />
<OMA>
<OMS cd="scscp_transient_1" name="GroupByIdNumber" />
<OMI>24</OMI><!-- Arg1 -->
<OMI>12</OMI><!-- Arg2 -->
</OMA>
</OMA>
</OMATTR>
</OMOBJ>
\end{verbatim}
In the next example we are sending an OM object containing a MathML object:
\begin{verbatim}
<OMOBJ>
<OMATTR>
<OMATP>
<OMS cd="scscp1" name="call_id"/>
<OMSTR>symcomp.org:26133:18668:mDkmEqh9</OMSTR>
<OMS cd="scscp1" name="option_return_cookie"/>
<OMSTR></OMSTR>
</OMATP>
<OMA><OMS cd="scscp1" name="procedure_call"/>
<OMA>
<OMS cd="scscp_transient_M25" name="Evaluate" />
<OMA>
<OMS cd="altenc" name="MathML_encoding"/>
<OMFOREIGN encoding="MathML-Presentation">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mi>sin</mi>
<mo>⁡</mo>
<mfenced><mi>x</mi></mfenced>
</mrow>
</math>
</OMFOREIGN>
</OMA>
</OMA>
</OMA>
</OMATTR>
</OMOBJ>
\end{verbatim}
\newpage
\subsection{The Procedure Completed message}
The {\tt GroupIdentificationService} procedure from the previous example
returns its successful output in the following form:
\begin{verbatim}
<OMOBJ>
<OMATTR>
<OMATP>
<OMS cd="scscp1" name="call_id" />
<OMSTR>symcomp.org:26133:18668:s2sYf1pg</OMSTR>
<OMS cd="scscp1" name="info_runtime" />
<!-- The runtime in milliseconds as OM integer -->
<OMI>1234</OMI>
<OMS cd="scscp1" name="info_memory" />
<!-- Memory occupied by CAS in bytes as OM integer -->
<OMI>134217728</OMI>
</OMATP>
<OMA>
<OMS cd="scscp1" name="procedure_completed" />
<OMA>
<OMS cd="linalg2" name="vector"/>
<OMI> 24</OMI>
<OMI> 12</OMI>
</OMA>
</OMA>
</OMATTR>
</OMOBJ>
\end{verbatim}
In case a cookie is requested, the
\verb|procedure_completed| message may look as follows
(we assume the minimal debugging level with no information
about the runtime and memory used):