22 | * A protocol relationship between endpoints
23 | *
24 | *
25 | * The implementation of this interface is actual wrapper over Socket that
26 | * know's how to communicate with peer. The user of Association shouldn't care
27 | * if the underlying Socket is client or server side
28 | *
29 | *
30 | *
31 | *
32 | *
33 | * @author amit bhayani
34 | *
35 | */
36 | public interface Association {
37 |
38 | /**
39 | * Return the Association channel type TCP or SCTP
40 | *
41 | * @return
42 | */
43 | public IpChannelType getIpChannelType();
44 |
45 | /**
46 | * Return the type of Association CLIENT or SERVER
47 | *
48 | * @return
49 | */
50 | public AssociationType getAssociationType();
51 |
52 | /**
53 | * Each association has unique name
54 | *
55 | * @return name of association
56 | */
57 | public String getName();
58 |
59 | /**
60 | * If this association is started by management
61 | *
62 | * @return
63 | */
64 | public boolean isStarted();
65 |
66 | /**
67 | * If this association up (connection is started and established)
68 | *
69 | * @return
70 | */
71 | public boolean isConnected();
72 |
73 | /**
74 | * If this association up (connection is established)
75 | *
76 | * @return
77 | */
78 | public boolean isUp();
79 |
80 | /**
81 | * The AssociationListener set for this Association
82 | *
83 | * @return
84 | */
85 | public AssociationListener getAssociationListener();
86 |
87 | /**
88 | * The {@link AssociationListener} to be registered for this Association
89 | *
90 | * @param associationListener
91 | */
92 | public void setAssociationListener(AssociationListener associationListener);
93 |
94 | /**
95 | * The host address that underlying socket is bound to
96 | *
97 | * @return
98 | */
99 | public String getHostAddress();
100 |
101 | /**
102 | * The host port that underlying socket is bound to
103 | *
104 | * @return
105 | */
106 | public int getHostPort();
107 |
108 | /**
109 | * The peer address that the underlying socket connects to
110 | *
111 | * @return
112 | */
113 | public String getPeerAddress();
114 |
115 | /**
116 | * The peer port that the underlying socket is connected to
117 | *
118 | * @return
119 | */
120 | public int getPeerPort();
121 |
122 | /**
123 | * Server name if the association is for {@link Server}
124 | *
125 | * @return
126 | */
127 | public String getServerName();
128 |
129 | /**
130 | * When SCTP multi-homing configuration extra IP addresses are here
131 | *
132 | * @return
133 | */
134 | public String[] getExtraHostAddresses();
135 |
136 | /**
137 | * Send the {@link PayloadData} to the peer
138 | *
139 | * @param payloadData
140 | * @throws Exception
141 | */
142 | public void send(PayloadData payloadData) throws Exception;
143 |
144 | /**
145 | * Return ByteBufAllocator if the underlying Channel is netty or null if not
146 | *
147 | * @return
148 | */
149 | public ByteBufAllocator getByteBufAllocator() throws Exception;
150 |
151 | /**
152 | * Return the last measured Congestion Level at the sending direction
153 | *
154 | * @return
155 | */
156 | public int getCongestionLevel();
157 |
158 | /**
159 | * Use this method only for accepting anonymous connections
160 | * from the ServerListener.onNewRemoteConnection() invoking
161 | *
162 | * @param associationListener
163 | * @throws Exception
164 | */
165 | public void acceptAnonymousAssociation(AssociationListener associationListener) throws Exception;
166 |
167 | /**
168 | * Use this method only for rejecting anonymous connections
169 | * from the ServerListener.onNewRemoteConnection() invoking
170 | */
171 | public void rejectAnonymousAssociation();
172 |
173 | /**
174 | * Stop the anonymous association. The connection will be closed and we will not reuse this association
175 | * This can be applied only for anonymous association, other associations must be stopped by
176 | * Management.stopAssociation(String assocName)
177 | *
178 | * @throws Exception
179 | */
180 | public void stopAnonymousAssociation() throws Exception;
181 |
182 | }
183 | ----
184 |
185 | Application interested in receiving payload from underlying socket registers the instance of class implementing AssociationListener with this Association.
186 |
187 | The `AssociationListener.java` API looks like
188 |
189 | [source,java]
190 | ----
191 |
192 | package org.mobicents.protocols.api;
193 |
194 | /**
195 | *
196 | * The listener interface for receiving the underlying socket status and
197 | * received payload from peer. The class that is interested in receiving data
198 | * must implement this interface, and the object created with that class is
199 | * registered with {@link Association}
200 | *
201 | *
202 | * @author amit bhayani
203 | *
204 | */
205 | public interface AssociationListener {
206 |
207 | /**
208 | * Invoked when underlying socket is open and connection is established with
209 | * peer. This is expected behavior when management start's the
210 | * {@link Association}
211 | *
212 | * @param association
213 | * @param maxInboundStreams
214 | * Returns the maximum number of inbound streams that this
215 | * association supports. Data received on this association will
216 | * be on stream number s, where 0 <= s < maxInboundStreams(). For
217 | * TCP socket this value is always 1
218 | * @param maxOutboundStreams
219 | * Returns the maximum number of outbound streams that this
220 | * association supports. Data sent on this association must be on
221 | * stream number s, where 0 <= s < maxOutboundStreams(). For TCP
222 | * socket this value is always 1
223 | */
224 | public void onCommunicationUp(Association association, int maxInboundStreams, int maxOutboundStreams);
225 |
226 | /**
227 | * Invoked when underlying socket is shutdown and connection is ended with
228 | * peer. This is expected behavior when management stop's the
229 | * {@link Association}
230 | *
231 | * @param association
232 | */
233 | public void onCommunicationShutdown(Association association);
234 |
235 | /**
236 | * Invoked when underlying socket lost the connection with peer due to any
237 | * reason like network between peer's died etc. This is unexpected behavior
238 | * and the underlying {@link Association} should try to re-establish the
239 | * connection
240 | *
241 | * @param association
242 | */
243 | public void onCommunicationLost(Association association);
244 |
245 | /**
246 | * Invoked when the connection with the peer re-started. This is specific to
247 | * SCTP protocol
248 | *
249 | * @param association
250 | */
251 | public void onCommunicationRestart(Association association);
252 |
253 | /**
254 | * Invoked when the {@link PayloadData} is received from peer
255 | *
256 | * @param association
257 | * @param payloadData
258 | */
259 | public void onPayload(Association association, PayloadData payloadData);
260 |
261 | /**
262 | *
263 | * The stream id set in outgoing {@link PayloadData} is invalid. This packe
264 | * will be dropped after calling the listener.
265 | *
266 | *
267 | * This callback is on same Thread as {@link SelectorThread}. Do not delay
268 | * the process here as it will hold all other IO.
269 | *
270 | *
271 | * @param payloadData
272 | */
273 | public void inValidStreamId(PayloadData payloadData);
274 |
275 | }
276 | ----
277 |
--------------------------------------------------------------------------------
/docs/sources-asciidoc/src/main/asciidoc/Chapter-Design_Overview.adoc:
--------------------------------------------------------------------------------
1 | = Design Overview
2 |
3 | The internal structure of {this-platform} {this-application} looks like
4 |
5 | .Architecture
6 | image::images/SCTPInternalArchitecture.jpg[]
7 |
8 | The prime responsibility of {this-platform} {this-application} is abstract Application from underlying SCTP sockets and expose same API (`Association.java`) irrespective if the underlying SCTP is acting as server side waiting for client to connect or client side initiating connection.
9 |
10 |
11 | The management (`Management.java`) controls the associations and servers.
12 | The Application can execute commands to create/delete associations/servers.
13 |
14 |
--------------------------------------------------------------------------------
/docs/sources-asciidoc/src/main/asciidoc/Chapter-Example.adoc:
--------------------------------------------------------------------------------
1 | = Example
2 |
3 | This chapter tours around the core constructs of {this-platform} {this-application} with simple examples to let you get started quickly.
4 | You will be able to write a client and a server on top of {this-platform} {this-application} right away when you are at the end of this chapter.
5 |
6 | == Before Getting Started
7 |
8 | The minimum requirements to run the examples which are introduced in this chapter are only two; the latest version of {this-platform} {this-application} and JDK 1.7 or above with SCTP support.
9 | At time of writing this guide linux kernel has native support for SCTP (lksctp) and also Solaris includes SCTP.
10 |
11 |
12 | == Initiating Management
13 |
14 | The primitive step in uisng {this-platform} {this-application} is to create instance of [class]`Management` class and set appropriate parameters.
15 |
16 | [source]
17 | ----
18 | private static final String SERVER_NAME = "testserver";
19 | private static final String SERVER_HOST = "127.0.0.1";
20 | private static final int SERVER_PORT = 2345;
21 |
22 | private static final String SERVER_ASSOCIATION_NAME = "serverAsscoiation";
23 | private static final String CLIENT_ASSOCIATION_NAME = "clientAsscoiation";
24 |
25 | private static final String CLIENT_HOST = "127.0.0.1";
26 | private static final int CLIENT_PORT = 2346;
27 | ...
28 | ....
29 | ....
30 |
31 | Management management = new NettySctpManagementImpl("SCTPTest"); //1. See NOTE below
32 | management.setConnectDelay(10000);// Try connecting every 10 secs //2. See NOTE below
33 | management.start();
34 | ----
35 |
36 | [NOTE]
37 | ====
38 | Footnotes from comments on the source code above below.
39 |
40 | . Create new instance of NettySctpManagementImpl and setting the management name. The management will search for SCTPTest_SCTP.xml file to load the previously configured Serever's or Association's. If file is not found it will create one.
41 |
42 | . connectDelay is only useful for Associations acting as client side trying to connect to peer. The value specified is time in milliseconds the unedrlying socket will try to connect to peer if the existing connection is broken or even if its fresh connection attempt.
43 | ====
44 |
45 | == Adding Server and server Association
46 |
47 | Once the Managment is setup, application can create [class]`Server` and add server [class]`Association`
48 |
49 | [source]
50 | ----
51 |
52 | Server server = this.management.addServer(SERVER_NAME, SERVER_HOST, SERVER_PORT);
53 | Association serverAssociation = this.management.addServerAssociation(CLIENT_HOST, CLIENT_PORT, SERVER_NAME, SERVER_ASSOCIATION_NAME); //1. See NOTE below
54 |
55 | serverAssociation.setAssociationListener(new ServerAssociationListener()); //2. See NOTE below
56 |
57 | this.management.startAssociation(SERVER_ASSOCIATION_NAME);
58 | this.management.startServer(SERVER_NAME);
59 | ----
60 |
61 | [NOTE]
62 | ====
63 | Footnotes from comments on the source code above.
64 |
65 | . Add the server and server association. Multiple server's can be added to each management and each server can have multiple server association's
66 |
67 | . The instance of AssociationListener should be registered with newly created Associaton before starting it. There is no dependency on order of starting server and server association.
68 | ====
69 |
70 | Below is example of class implementing [class]`AssociationListener`
71 |
72 | [source]
73 | ----
74 |
75 | class ServerAssociationListener implements AssociationListener {
76 |
77 | private final byte[] SERVER_MESSAGE = "Server says Hi".getBytes();
78 | private boolean serverAssocUp;
79 | private boolean serverAssocDown;
80 | private byte[] serverMessage;
81 |
82 | /*
83 | * (non-Javadoc)
84 | *
85 | * @see
86 | * org.mobicents.protocols.sctp.AssociationListener#onCommunicationUp
87 | * (org.mobicents.protocols.sctp.Association)
88 | */
89 | @Override
90 | public void onCommunicationUp(Association association, int maxInboundStreams, int maxOutboundStreams) {
91 | System.out.println(this + " onCommunicationUp");
92 |
93 | serverAssocUp = true;
94 |
95 | try {
96 | ByteBufAllocator byteBufAllocator = association.getByteBufAllocator();
97 | ByteBuf byteBuf;
98 | if (byteBufAllocator != null) {
99 | byteBuf = byteBufAllocator.buffer();
100 | } else {
101 | byteBuf = Unpooled.buffer();
102 | }
103 | byteBuf.writeBytes(SERVER_MESSAGE);
104 | PayloadData payloadData = new PayloadData(SERVER_MESSAGE.length, byteBuf, true, false, 3, 1);
105 | association.send(payloadData);
106 | } catch (Exception e) {
107 | }
108 | }
109 |
110 | /*
111 | * (non-Javadoc)
112 | *
113 | * @see
114 | * org.mobicents.protocols.sctp.AssociationListener#onCommunicationShutdown
115 | * (org.mobicents.protocols.sctp.Association)
116 | */
117 | @Override
118 | public void onCommunicationShutdown(Association association) {
119 | System.out.println(this + " onCommunicationShutdown");
120 | serverAssocDown = true;
121 | }
122 |
123 | /*
124 | * (non-Javadoc)
125 | *
126 | * @see
127 | * org.mobicents.protocols.sctp.AssociationListener#onCommunicationLost
128 | * (org.mobicents.protocols.sctp.Association)
129 | */
130 | @Override
131 | public void onCommunicationLost(Association association) {
132 | System.out.println(this + " onCommunicationLost");
133 | }
134 |
135 | /*
136 | * (non-Javadoc)
137 | *
138 | * @see
139 | * org.mobicents.protocols.sctp.AssociationListener#onCommunicationRestart
140 | * (org.mobicents.protocols.sctp.Association)
141 | */
142 | @Override
143 | public void onCommunicationRestart(Association association) {
144 | System.out.println(this + " onCommunicationRestart");
145 | }
146 |
147 | /*
148 | * (non-Javadoc)
149 | *
150 | * @see
151 | * org.mobicents.protocols.sctp.AssociationListener#onPayload(org.mobicents
152 | * .protocols.sctp.Association,
153 | * org.mobicents.protocols.sctp.PayloadData)
154 | */
155 | @Override
156 | public void onPayload(Association association, PayloadData payloadData) {
157 | System.out.println(this + " onPayload");
158 |
159 | ByteBuf byteBuf = payloadData.getByteBuf();
160 | serverMessage = new byte[byteBuf.readableBytes()];
161 | byteBuf.getBytes(0, serverMessage);
162 | ReferenceCountUtil.release(byteBuf);
163 |
164 | System.out.println(this + "received " + new String(serverMessage));
165 | }
166 |
167 | @Override
168 | public void inValidStreamId(PayloadData payloadData) {
169 | }
170 | }
171 | ----
172 |
173 | == Adding Association
174 |
175 | Once the Managment is setup, application can create client side [class]`Association`.
176 |
177 | [source]
178 | ----
179 |
180 | Association clientAssociation = this.management.addAssociation(CLIENT_HOST, CLIENT_PORT, SERVER_HOST, SERVER_PORT, CLIENT_ASSOCIATION_NAME);
181 | clientAssociation.setAssociationListener(new ClientAssociationListenerImpl());
182 | this.management.startAssociation(CLIENT_ASSOCIATION_NAME);
183 | ----
184 |
185 | == Uasge for anonymous Associations
186 |
187 | You may work not with a list of preconfigured associations but accept any incoming connections. For this you need:
188 |
189 | * configure Server and set its `acceptAnonymousConnections` option to true
190 | * configure no association
191 | * implement ServerListener interface and register it to SCTP Management
192 | * implement ServerListener.onNewRemoteConnection() method like:
193 | [source]
194 | ----
195 | public void onNewRemoteConnection(Server server, Association association) {
196 | if () {
197 | association.rejectAnonymousAssociation();
198 | } else {
199 | association.acceptAnonymousAssociation(new ServerAssociationListener(ad));
200 | }
201 | }
202 | ----
203 |
204 |
--------------------------------------------------------------------------------
/docs/sources-asciidoc/src/main/asciidoc/Chapter-Introduction.adoc:
--------------------------------------------------------------------------------
1 | [[_introduction]]
2 | = Introductionto {this-platform} {this-application}
3 |
4 | In computer networking, the Stream Control Transmission Protocol http://en.wikipedia.org/wiki/SCTP[(SCTP)] is a Transport Layer protocol, serving in a similar role to the popular protocols Transmission Control Protocol (TCP) and User Datagram Protocol (UDP). It provides some of the same service features of both: it is message-oriented like UDP and ensures reliable, in-sequence transport of messages with congestion control like TCP.
5 |
6 | The protocol was defined by the IETF Signaling Transport (SIGTRAN) working group in 2000 and is maintained by the IETF Transport Area (TSVWG) working group. http://tools.ietf.org/html/rfc4960[RFC 4960] defines the protocol. http://tools.ietf.org/html/rfc3286[RFC 3286] provides an introduction.
7 |
8 | {this-platform} {this-application} is providing the convenient API's over Java SCTP, hence can be used only with version JDK 1.7 or above.
9 |
10 | {this-platform} {this-application} can also create the TCP sockets exposing same high level API's hence application using {this-platform} {this-application} can work seamless with TCP or SCTP.
11 |
12 |
13 | NOTE: The TCP facility is only for test to support the OS which doesn't have SCTP available out-of-box.
14 | For example Windows OS.
15 |
16 | In addition to exposing the SCTP protocol, {this-platform} {this-application} contains number of features which other wise the application depending on SCTP will have to take care of.
17 | For example {this-platform} {this-application} provides
18 |
19 | * Management interface to manage the underlying SCTP Associations
20 | * Persistence mechanism capable of initiating the SCTP Association if the system is restarted after crash or gracefull shutdown
21 | * Tries re-initiate the connection if for some reason the connection is lost between the peers
22 | * Configuration to make the module behave as single thread or multi-threaded depending on requirement's of application
23 | * Support for anonymous SCTP/TCP associations
24 | * Starting from version 2.0 both netty 4 and nio library are supported. ManagementImpl management class is used for nio and NettySctpManagementImpl management class is used for netty. Usage of netty library is preferred.
25 | * You can disable of using persistent configuration via using NonPersistentManagementImpl or NonPersistentNettySctpManagementImpl class.
26 |
27 | Below diagram shows various layers involved
28 |
29 | .Layers involved
30 | image::images/SCTPGeneric.jpg[]
31 |
--------------------------------------------------------------------------------
/docs/sources-asciidoc/src/main/asciidoc/Chapter-Setup.adoc:
--------------------------------------------------------------------------------
1 | = Setup
2 |
3 | [[_source_code]]
4 | == {this-platform} {this-application} Source Code
5 |
6 |
7 |
8 | [[_release_source_building]]
9 | === Release Source Code Building
10 |
11 |
12 | . Downloading the source code
13 | +
14 | IMPORTANT: Subversion is used to manage its source code.
15 | Instructions for using Subversion, including install, can be found at http://git-scm.com/
16 | +
17 | Use Git to checkout a specific release source, the Git repository URL is {this-trunk-source-code-url}, then switch to the specific release version, lets consider {project-version}.
18 | +
19 | [source]
20 | ----
21 | [usr]$ git clone git@github.com:RestComm/sctp.git
22 | ----
23 |
24 | . Building the source code
25 | +
26 | IMPORTANT: Maven 3.0.0 (or higher) is used to build the release.
27 | Instructions for using Maven2, including install, can be found at http://maven.apache.org
28 | +
29 | Use Maven to build the binaries.
30 | +
31 | [source,subs="verbatim,attributes"]
32 | ----
33 |
34 | [usr]$ cd {project-version}
35 | [usr]$ mvn install
36 | ----
37 | +
38 | Once the process finishes you should have the `binary` jar files in the [path]_target_ directory of `module`.
39 |
40 |
41 | [[_trunk_source_building]]
42 | === Development Trunk Source Building
43 |
44 | Similar process as for <<_release_source_building>>, the only change is the GIT source code URL, which is {this-trunk-source-code-url}.
45 |
--------------------------------------------------------------------------------
/docs/sources-asciidoc/src/main/asciidoc/Common_Content/Conventions.adoc:
--------------------------------------------------------------------------------
1 |
2 | = Document Conventions
3 |
4 | This manual uses several conventions to highlight certain words and phrases and draw attention to specific pieces of information.
5 |
6 | In PDF and paper editions, this manual uses typefaces drawn from the https://fedorahosted.org/liberation-fonts/[Liberation Fonts] set.
7 | The Liberation Fonts set is also used in HTML editions if the set is installed on your system.
8 | If not, alternative but equivalent typefaces are displayed.
9 | Note: Red Hat Enterprise Linux 5 and later includes the Liberation Fonts set by default.
10 |
11 | == Typographic Conventions
12 |
13 | Four typographic conventions are used to call attention to specific words and phrases.
14 | These conventions, and the circumstances they apply to, are as follows.
15 |
16 | `Mono-spaced Bold`
17 |
18 | Used to highlight system input, including shell commands, file names and paths.
19 | Also used to highlight key caps and key-combinations.
20 | For example:
21 |
22 | [quote]
23 | To see the contents of the file [path]_my_next_bestselling_novel_ in your current working directory, enter the `cat my_next_bestselling_novel` command at the shell prompt and press kbd:[Enter] to execute the command.
24 |
25 | The above includes a file name, a shell command and a key cap, all presented in Mono-spaced Bold and all distinguishable thanks to context.
26 |
27 | Key-combinations can be distinguished from key caps by the hyphen connecting each part of a key-combination.
28 | For example:
29 |
30 | ____
31 | Press kbd:[Enter] to execute the command.
32 |
33 | Press to switch to the first virtual terminal.
34 | Press to return to your X-Windows session.
35 | ____
36 |
37 | The first sentence highlights the particular key cap to press.
38 | The second highlights two sets of three key caps, each set pressed simultaneously.
39 |
40 | If source code is discussed, class names, methods, functions, variable names and returned values mentioned within a paragraph will be presented as above, in `Mono-spaced Bold`.
41 | For example:
42 |
43 | [quote]
44 | File-related classes include [class]`filesystem` for file systems, [class]`file` for files, and [class]`dir` for directories.
45 | Each class has its own associated set of permissions.
46 |
47 | [app]`Proportional Bold`
48 |
49 | This denotes words or phrases encountered on a system, including application names; dialogue box text; labelled buttons; check-box and radio button labels; menu titles and sub-menu titles.
50 | For example:
51 |
52 | ____
53 | Choose menu:System > Preferences > Mouse[] from the main menu bar to launch [app]`Mouse Preferences`.
54 | In the [label]#Buttons# tab, click the [label]#Left-handed mouse# check box and click btn:[Close] to switch the primary mouse button from the left to the right (making the mouse suitable for use in the left hand).
55 |
56 | To insert a special character into a [app]`gedit` file, choose menu:Applications > Accessories > Character Map[] from the main menu bar.
57 | Next, choose menu:Search > Find[] from the [app]`Character Map` menu bar, type the name of the character in the [label]#Search# field and click btn:[Next].
58 | The character you sought will be highlighted in the [label]#Character Table#.
59 | Double-click this highlighted character to place it in the [label]#Text to copy# field and then click the btn:[Copy] button.
60 | Now switch back to your document and choose menu:Edit > Paste[] from the [app]`gedit` menu bar.
61 | ____
62 |
63 | The above text includes application names; system-wide menu names and items; application-specific menu names; and buttons and text found within a GUI interface, all presented in Proportional Bold and all distinguishable by context.
64 |
65 | Note the menu:>[] shorthand used to indicate traversal through a menu and its sub-menus.
66 | This is to avoid the difficult-to-follow 'Select from the menu:Preferences[] sub-menu in the menu:System[] menu of the main menu bar' approach.
67 |
68 | `Mono-spaced Bold Italic` or [app]`Proportional Bold Italic`
69 |
70 | Whether Mono-spaced Bold or Proportional Bold, the addition of Italics indicates replaceable or variable text.
71 | Italics denotes text you do not input literally or displayed text that changes depending on circumstance.
72 | For example:
73 |
74 | ____
75 | To connect to a remote machine using ssh, type `ssh username@domain.name` at a shell prompt.
76 | If the remote machine is [path]_example.com_ and your username on that machine is john, type `ssh john@example.com`.
77 |
78 | The `mount -o remount file-system` command remounts the named file system.
79 | For example, to remount the [path]_/home_ file system, the command is `mount -o remount /home`.
80 |
81 | To see the version of a currently installed package, use the `rpm -q package` command.
82 | It will return a result as follows: `package-version-release`.
83 | ____
84 |
85 | Note the words in bold italics above —username, domain.name, file-system, package, version and release.
86 | Each word is a placeholder, either for text you enter when issuing a command or for text displayed by the system.
87 |
88 | Aside from standard usage for presenting the title of a work, italics denotes the first use of a new and important term.
89 | For example:
90 |
91 | [quote]
92 | When the Apache HTTP Server accepts requests, it dispatches child processes or threads to handle them.
93 | This group of child processes or threads is known as a [term]_server-pool_.
94 | Under Apache HTTP Server 2.0, the responsibility for creating and maintaining these server-pools has been abstracted to a group of modules called [term]_Multi-Processing Modules_ ([term]_MPMs_). Unlike other modules, only one module from the MPM group can be loaded by the Apache HTTP Server.
95 |
96 | == Pull-quote Conventions
97 |
98 | Two, commonly multi-line, data types are set off visually from the surrounding text.
99 |
100 | Output sent to a terminal is set in `Mono-spaced Roman` and presented thus:
101 |
102 | ----
103 |
104 | books Desktop documentation drafts mss photos stuff svn
105 | books_tests Desktop1 downloads images notes scripts svgs
106 | ----
107 |
108 | Source-code listings are also set in `Mono-spaced Roman` but are presented and highlighted as follows:
109 |
110 | [source,java]
111 | ----
112 |
113 | package org.jboss.book.jca.ex1;
114 |
115 | import javax.naming.InitialContext;
116 |
117 | public class ExClient
118 | {
119 | public static void main(String args[])
120 | throws Exception
121 | {
122 | InitialContext iniCtx = new InitialContext();
123 | Object ref = iniCtx.lookup("EchoBean");
124 | EchoHome home = (EchoHome) ref;
125 | Echo echo = home.create();
126 |
127 | System.out.println("Created Echo");
128 |
129 | System.out.println("Echo.echo('Hello') = " + echo.echo("Hello"));
130 | }
131 |
132 | }
133 | ----
134 |
135 | == Notes and Warnings
136 |
137 | Finally, we use three visual styles to draw attention to information that might otherwise be overlooked.
138 |
139 | .Note
140 | [NOTE]
141 | ====
142 | A note is a tip or shortcut or alternative approach to the task at hand.
143 | Ignoring a note should have no negative consequences, but you might miss out on a trick that makes your life easier.
144 | ====
145 |
146 | .Important
147 | [IMPORTANT]
148 | ====
149 | Important boxes detail things that are easily missed: configuration changes that only apply to the current session, or services that need restarting before an update will apply.
150 | Ignoring Important boxes won't cause data loss but may cause irritation and frustration.
151 | ====
152 |
153 | .Warning
154 | [WARNING]
155 | ====
156 | A Warning should not be ignored.
157 | Ignoring warnings will most likely cause data loss.
158 | ====
--------------------------------------------------------------------------------
/docs/sources-asciidoc/src/main/asciidoc/Common_Content/Java_Development_Kit-Installing_Configuring_and_Running.adoc:
--------------------------------------------------------------------------------
1 |
2 | :sectnums!:
3 |
4 | [appendix]
5 | [[_jdk_installing_configuring_and_running]]
6 | = Java Development Kit (): Installing, Configuring and Running
7 |
8 | The [app]` Platform` is written in Java; therefore, before running any [app]`` server, you must have a working Java Runtime Environment () or Java Development Kit () installed on your system.
9 | In addition, the JRE or JDK you are using to run [app]`` must be version 5 or higherfootnote:[At this point in time, it is possible to run most servers, such as the JAIN SLEE, using a Java 6 JRE or JDK. Be aware, however, that presently the XML Document Management Server does not run on Java 6. We suggest checking the web site, forums or discussion pages if you need to inquire about the status of running the XML Document Management Server with Java 6.].
10 |
11 | .Should I Install the JRE or JDK?
12 | Although you can run [app]`` servers using the Java Runtime Environment, we assume that most users are developers interested in developing Java-based, [app]``-driven solutions.
13 | Therefore, in this guide we take the tact of showing how to install the full Java Development Kit.
14 |
15 | .Should I Install the 32-Bit or the 64-Bit JDK, and Does It Matter?
16 | Briefly stated: if you are running on a 64-Bit Linux or Windows platform, you should consider installing and running the 64-bit JDK over the 32-bit one.
17 | Here are some heuristics for determining whether you would rather run the 64-bit Java Virtual Machine (JVM) over its 32-bit cousin for your application:
18 |
19 | * Wider datapath: the pipe between RAM and CPU is doubled, which improves the performance of memory-bound applications when using a 64-bit JVM.
20 | * 64-bit memory addressing gives virtually unlimited (1 exabyte) heap allocation.
21 | However large heaps affect garbage collection.
22 | * Applications that run with more than 1.5 GB of RAM (including free space for garbage collection optimization) should utilize the 64-bit JVM.
23 | * Applications that run on a 32-bit JVM and do not require more than minimal heap sizes will gain nothing from a 64-bit JVM.
24 | Barring memory issues, 64-bit hardware with the same relative clock speed and architecture is not likely to run Java applications faster than their 32-bit cousin.
25 |
26 | Note that the following instructions detail how to download and install the 32-bit JDK, although the steps are nearly identical for installing the 64-bit version.
27 |
28 | .Downloading
29 | You can download the Sun JDK 5.0 (Java 2 Development Kit) from Sun's website: http://java.sun.com/javase/downloads/index_jdk5.jsp.
30 | Click on the [label]#Download# link next to "JDK 5.0 Update [replaceable]``" (where [replaceable]`` is the latest minor version release number). On the next page, select your language and platform (both architecture--whether 32- or 64-bit--and operating system), read and agree to the `Java Development Kit 5.0 License Agreement`, and proceed to the download page.
31 |
32 | The Sun website will present two download alternatives to you: one is an RPM inside a self-extracting file (for example, [path]_jdk-1_5_0_16-linux-i586-rpm.bin_), and the other is merely a self-extracting file (e.g. [path]_jdk-1_5_0_16-linux-i586.bin_). If you are installing the JDK on Red Hat Enterprise Linux, Fedora, or another RPM-based Linux system, we suggest that you download the self-extracting file containing the RPM package, which will set up and use the SysV service scripts in addition to installing the JDK.
33 | We also suggest installing the self-extracting RPM file if you will be running [app]`` in a production environment.
34 |
35 | .Installing
36 | The following procedures detail how to install the Java Development Kit on both Linux and Windows.
37 |
38 | .Procedure: Installing the JDK on Linux
39 | . Regardless of which file you downloaded, you can install it on Linux by simply making sure the file is executable and then running it:
40 | +
41 | ----
42 | ~]$ chmod +x "jdk-1_5_0_-linux--rpm.bin"
43 | ~]$ ./"jdk-1_5_0_-linux--rpm.bin"
44 | ----
45 |
46 |
47 | .You Installed Using the Non-RPM Installer, but Want the SysV Service Scripts
48 | [NOTE]
49 | ====
50 | If you download the non-RPM self-extracting file (and installed it), and you are running on an RPM-based system, you can still set up the SysV service scripts by downloading and installing one of the `-compat` packages from the JPackage project.
51 | Remember to download the `-compat` package which corresponds correctly to the minor release number of the JDK you installed.
52 | The compat packages are available from link:ftp://jpackage.hmdc.harvard.edu/JPackage/1.7/generic/RPMS.non-free/.
53 | ====
54 |
55 | IMPORTANT: You do not need to install a `-compat` package in addition to the JDK if you installed the self-extracting RPM file! The `-compat` package merely performs the same SysV service script set up that the RPM version of the JDK installer does.
56 |
57 | .Procedure: Installing the JDK on Windows
58 | . Using Explorer, simply double-click the downloaded self-extracting installer and follow the instructions to install the JDK.
59 |
60 | .Configuring
61 | Configuring your system for the JDK consists in two tasks: setting the [var]`JAVA_HOME` environment variable, and ensuring that the system is using the proper JDK (or JRE) using the `alternatives` command.
62 | Setting [var]`JAVA_HOME` usually overrides the values for `java`, `javac` and `java_sdk_1.5.0` in `alternatives`, but we will set them all just to be safe and consistent.
63 |
64 | Setting the [var]`JAVA_HOME` Environment Variable on Generic Linux::
65 | After installing the JDK, you must ensure that the [var]`JAVA_HOME` environment variable exists and points to the location of your JDK installation.
66 |
67 | Setting [var]`java`, [var]`javac` and [var]`java_sdk_1.5.0` Using the `alternatives` command ::
68 | _As the root user_, call `/usr/sbin/alternatives` with the [option]`--config java` option to select between JDKs and JREs installed on your system:
69 |
70 | Setting the [var]`JAVA_HOME` Environment Variable on Windows::
71 | For information on how to set environment variables in Windows, refer to http://support.microsoft.com/kb/931715.
72 |
73 | .Testing
74 | Finally, to make sure that you are using the correct JDK or Java version (5 or higher), and that the java executable is in your [var]`PATH`, run the `java -version
75 | ` command in the terminal from your home directory:
76 |
77 | ----
78 | ~]$ java -version
79 | java version "1.5.0_16"
80 | Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b03)
81 | Java HotSpot(TM) Client VM (build 1.5.0_16-b03, mixed mode, sharing)
82 | ----
83 |
84 | .Uninstalling
85 | There is usually no reason (other than space concerns) to remove a particular JDK from your system, given that you can switch between JDKs and JREs easily using `alternatives`, and/or by setting [var]`JAVA_HOME`.
86 |
87 | .Uninstalling the JDK on Linux
88 | On RPM-based systems, you can uninstall the JDK using the `yum remove
89 | ` command.
90 |
91 | .Uninstalling the JDK on Windows
92 | On Windows systems, check the JDK entry in the `Start` menu for an uninstall command, or use `Add/Remove Programs`.
93 |
94 | :sectnums:
--------------------------------------------------------------------------------
/docs/sources-asciidoc/src/main/asciidoc/Common_Content/Preface.adoc:
--------------------------------------------------------------------------------
1 |
2 | :sectnums!:
3 |
4 | [preface]
5 | = Preface
6 |
7 | :leveloffset: 1
8 | include::Section-Conventions.adoc[]
9 | :leveloffset: 0
10 |
11 | :leveloffset: 1
12 | include::Section-Feedback.adoc[]
13 | :leveloffset: 0
14 |
15 | :sectnums:
--------------------------------------------------------------------------------
/docs/sources-asciidoc/src/main/asciidoc/Common_Content/Section-Conventions.adoc:
--------------------------------------------------------------------------------
1 |
2 | = Document Conventions
3 |
4 | This manual uses several conventions to highlight certain words and phrases and draw attention to specific pieces of information.
5 |
6 | In PDF and paper editions, this manual uses typefaces drawn from the https://fedorahosted.org/liberation-fonts/[Liberation Fonts] set.
7 | The Liberation Fonts set is also used in HTML editions if the set is installed on your system.
8 | If not, alternative but equivalent typefaces are displayed.
9 | Note: Red Hat Enterprise Linux 5 and later includes the Liberation Fonts set by default.
10 |
11 | == Typographic Conventions
12 |
13 | Four typographic conventions are used to call attention to specific words and phrases.
14 | These conventions, and the circumstances they apply to, are as follows.
15 |
16 | `Mono-spaced Bold`
17 |
18 | Used to highlight system input, including shell commands, file names and paths.
19 | Also used to highlight key caps and key-combinations.
20 | For example:
21 |
22 | [quote]
23 | To see the contents of the file [path]_my_next_bestselling_novel_ in your current working directory, enter the `cat my_next_bestselling_novel` command at the shell prompt and press kbd:[Enter] to execute the command.
24 |
25 | The above includes a file name, a shell command and a key cap, all presented in Mono-spaced Bold and all distinguishable thanks to context.
26 |
27 | Key-combinations can be distinguished from key caps by the hyphen connecting each part of a key-combination.
28 | For example:
29 |
30 | ____
31 | Press kbd:[Enter] to execute the command.
32 |
33 | Press to switch to the first virtual terminal.
34 | Press to return to your X-Windows session.
35 | ____
36 |
37 | The first sentence highlights the particular key cap to press.
38 | The second highlights two sets of three key caps, each set pressed simultaneously.
39 |
40 | If source code is discussed, class names, methods, functions, variable names and returned values mentioned within a paragraph will be presented as above, in `Mono-spaced Bold`.
41 | For example:
42 |
43 | [quote]
44 | File-related classes include [class]`filesystem` for file systems, [class]`file` for files, and [class]`dir` for directories.
45 | Each class has its own associated set of permissions.
46 |
47 | [app]`Proportional Bold`
48 |
49 | This denotes words or phrases encountered on a system, including application names; dialogue box text; labelled buttons; check-box and radio button labels; menu titles and sub-menu titles.
50 | For example:
51 |
52 | ____
53 | Choose menu:System > Preferences > Mouse[] from the main menu bar to launch [app]`Mouse Preferences`.
54 | In the [label]#Buttons# tab, click the [label]#Left-handed mouse# check box and click btn:[Close] to switch the primary mouse button from the left to the right (making the mouse suitable for use in the left hand).
55 |
56 | To insert a special character into a [app]`gedit` file, choose menu:Applications > Accessories > Character Map[] from the main menu bar.
57 | Next, choose menu:Search > Find[] from the [app]`Character Map` menu bar, type the name of the character in the [label]#Search# field and click btn:[Next].
58 | The character you sought will be highlighted in the [label]#Character Table#.
59 | Double-click this highlighted character to place it in the [label]#Text to copy# field and then click the btn:[Copy] button.
60 | Now switch back to your document and choose menu:Edit > Paste[] from the [app]`gedit` menu bar.
61 | ____
62 |
63 | The above text includes application names; system-wide menu names and items; application-specific menu names; and buttons and text found within a GUI interface, all presented in Proportional Bold and all distinguishable by context.
64 |
65 | Note the menu:>[] shorthand used to indicate traversal through a menu and its sub-menus.
66 | This is to avoid the difficult-to-follow 'Select from the menu:Preferences[] sub-menu in the menu:System[] menu of the main menu bar' approach.
67 |
68 | `Mono-spaced Bold Italic` or [app]`Proportional Bold Italic`
69 |
70 | Whether Mono-spaced Bold or Proportional Bold, the addition of Italics indicates replaceable or variable text.
71 | Italics denotes text you do not input literally or displayed text that changes depending on circumstance.
72 | For example:
73 |
74 | ____
75 | To connect to a remote machine using ssh, type `ssh username@domain.name` at a shell prompt.
76 | If the remote machine is [path]_example.com_ and your username on that machine is john, type `ssh john@example.com`.
77 |
78 | The `mount -o remount file-system` command remounts the named file system.
79 | For example, to remount the [path]_/home_ file system, the command is `mount -o remount /home`.
80 |
81 | To see the version of a currently installed package, use the `rpm -q package` command.
82 | It will return a result as follows: `package-version-release`.
83 | ____
84 |
85 | Note the words in bold italics above —username, domain.name, file-system, package, version and release.
86 | Each word is a placeholder, either for text you enter when issuing a command or for text displayed by the system.
87 |
88 | Aside from standard usage for presenting the title of a work, italics denotes the first use of a new and important term.
89 | For example:
90 |
91 | [quote]
92 | When the Apache HTTP Server accepts requests, it dispatches child processes or threads to handle them.
93 | This group of child processes or threads is known as a [term]_server-pool_.
94 | Under Apache HTTP Server 2.0, the responsibility for creating and maintaining these server-pools has been abstracted to a group of modules called [term]_Multi-Processing Modules_ ([term]_MPMs_). Unlike other modules, only one module from the MPM group can be loaded by the Apache HTTP Server.
95 |
96 | == Pull-quote Conventions
97 |
98 | Two, commonly multi-line, data types are set off visually from the surrounding text.
99 |
100 | Output sent to a terminal is set in `Mono-spaced Roman` and presented thus:
101 |
102 | ----
103 |
104 | books Desktop documentation drafts mss photos stuff svn
105 | books_tests Desktop1 downloads images notes scripts svgs
106 | ----
107 |
108 | Source-code listings are also set in `Mono-spaced Roman` but are presented and highlighted as follows:
109 |
110 | [source,java]
111 | ----
112 |
113 | package org.jboss.book.jca.ex1;
114 |
115 | import javax.naming.InitialContext;
116 |
117 | public class ExClient
118 | {
119 | public static void main(String args[])
120 | throws Exception
121 | {
122 | InitialContext iniCtx = new InitialContext();
123 | Object ref = iniCtx.lookup("EchoBean");
124 | EchoHome home = (EchoHome) ref;
125 | Echo echo = home.create();
126 |
127 | System.out.println("Created Echo");
128 |
129 | System.out.println("Echo.echo('Hello') = " + echo.echo("Hello"));
130 | }
131 |
132 | }
133 | ----
134 |
135 | == Notes and Warnings
136 |
137 | Finally, we use three visual styles to draw attention to information that might otherwise be overlooked.
138 |
139 | .Note
140 | [NOTE]
141 | ====
142 | A note is a tip or shortcut or alternative approach to the task at hand.
143 | Ignoring a note should have no negative consequences, but you might miss out on a trick that makes your life easier.
144 | ====
145 |
146 | .Important
147 | [IMPORTANT]
148 | ====
149 | Important boxes detail things that are easily missed: configuration changes that only apply to the current session, or services that need restarting before an update will apply.
150 | Ignoring Important boxes won't cause data loss but may cause irritation and frustration.
151 | ====
152 |
153 | .Warning
154 | [WARNING]
155 | ====
156 | A Warning should not be ignored.
157 | Ignoring warnings will most likely cause data loss.
158 | ====
--------------------------------------------------------------------------------
/docs/sources-asciidoc/src/main/asciidoc/Common_Content/Section-Feedback.adoc:
--------------------------------------------------------------------------------
1 |
2 | = Provide feedback to the authors!
3 | (((feedback)))
4 |
5 | If you find a typographical error in this manual, or if you have thought of a way to make this manual better, we would love to hear from you! Please submit a report in the the {this-issue.tracker.ur}, against the product {this-platform} {this-application}` `, or contact the authors.
6 |
7 | When submitting a bug report, be sure to mention the manual's identifier: {this-platform} {this-application}
8 |
9 | If you have a suggestion for improving the documentation, try to be as specific as possible when describing it.
10 | If you have found an error, please include the section number and some of the surrounding text so we can find it easily.
11 |
12 | ifdef::backend-docbook[]
13 | [index]
14 | == Index
15 | // Generated automatically by the DocBook toolchain.
16 | endif::backend-docbook[]
17 |
--------------------------------------------------------------------------------
/docs/sources-asciidoc/src/main/asciidoc/Common_Content/Setting_the_JBOSS_HOME_Environment_Variable.adoc:
--------------------------------------------------------------------------------
1 |
2 | :sectnums!:
3 |
4 | [appendix]
5 | [[_jboss_home_setup]]
6 | = Setting the JBOSS_HOME Environment Variable
7 |
8 | The [app]` Platform` ([app]``) is built on top of the [app]``.
9 | You do not need to set the [var]`JBOSS_HOME` environment variable to run any of the [app]` Platform` servers _unless_ [var]`JBOSS_HOME` is _already_ set.
10 |
11 | The best way to know for sure whether [var]`JBOSS_HOME` was set previously or not is to perform a simple check which may save you time and frustration.
12 |
13 | .Checking to See If JBOSS_HOME is Set on Unix
14 | At the command line, `echo` `$JBOSS_HOME` to see if it is currently defined in your environment:
15 |
16 | ----
17 | ~]$ echo $JBOSS_HOME
18 | ----
19 |
20 | The [app]` Platform` and most &THIS.PLATFORM; servers are built on top of the [app]`` ([app]``). When the [app]` Platform` or &THIS.PLATFORM; servers are built _from source_, then [var]`JBOSS_HOME` _must_ be set, because the &THIS.PLATFORM; files are installed into (or "`over top of`" if you prefer) a clean [app]`` installation, and the build process assumes that the location pointed to by the [var]`JBOSS_HOME` environment variable at the time of building is the [app]`` installation into which you want it to install the &THIS.PLATFORM; files.
21 |
22 | This guide does not detail building the [app]` Platform` or any &THIS.PLATFORM; servers from source.
23 | It is nevertheless useful to understand the role played by [app]`JBoss AS` and [var]`JBOSS_HOME` in the &THIS.PLATFORM; ecosystem.
24 |
25 | The immediately-following section considers whether you need to set [var]`JBOSS_HOME` at all and, if so, when.
26 | The subsequent sections detail how to set [var]`JBOSS_HOME` on Unix and Windows
27 |
28 | IMPORTANT: Even if you fall into the category below of _not needing_ to set [var]`JBOSS_HOME`, you may want to for various reasons anyway.
29 | Also, even if you are instructed that you do _not need_ to set [var]`JBOSS_HOME`, it is good practice nonetheless to check and make sure that [var]`JBOSS_HOME` actually _isn't_ set or defined on your system for some reason.
30 | This can save you both time and frustration.
31 |
32 | You _DO NOT NEED_ to set [var]`JBOSS_HOME` if...
33 |
34 | * ...you have installed the [app]` Platform` binary distribution.
35 | * ...you have installed a &THIS.PLATFORM;server binary distribution _which bundles [app]``._
36 |
37 | You _MUST_ set [var]`JBOSS_HOME` if...
38 |
39 | * ...you are installing the [app]` Platform` or any of the &THIS.PLATFORM; servers _from source_.
40 | * ...you are installing the [app]` Platform` binary distribution, or one of the &THIS.PLATFORM; server binary distributions, which _do not_ bundle [app]``.
41 |
42 | Naturally, if you installed the [app]` Platform` or one of the &THIS.PLATFORM; server binary releases which _do not_ bundle [app]``, yet requires it to run, then you should install before setting [var]`JBOSS_HOME` or proceeding with anything else.
43 |
44 | .Setting the JBOSS_HOME Environment Variable on Unix
45 | The [var]`JBOSS_HOME` environment variable must point to the directory which contains all of the files for the [app]` Platform` or individual &THIS.PLATFORM; server that you installed.
46 | As another hint, this topmost directory contains a [path]_bin_ subdirectory.
47 |
48 | Setting [var]`JBOSS_HOME` in your personal [path]_~/.bashrc_ startup script carries the advantage of retaining effect over reboots.
49 | Each time you log in, the environment variable is sure to be set for you, as a user.
50 | On Unix, it is possible to set [var]`JBOSS_HOME` as a system-wide environment variable, by defining it in [path]_/etc/bashrc_, but this method is neither recommended nor detailed in these instructions.
51 |
52 | .Procedure: To Set JBOSS_HOME on Unix...
53 | . Open the [path]_~/.bashrc_ startup script, which is a hidden file in your home directory, in a text editor, and insert the following line on its own line while substituting for the actual install location on your system:
54 | +
55 | ----
56 | export JBOSS_HOME="/home////"
57 | ----
58 |
59 | . Save and close the [path]_.bashrc_ startup script.
60 | . You should `source` the [path]_.bashrc_ script to force your change to take effect, so that [var]`JBOSS_HOME` becomes set for the current sessionfootnote:[Note that any other terminals which were opened prior to your having altered .bashrc will need to source
61 | ~/.bashrc as well should they require access to JBOSS_HOME.].
62 | +
63 | ----
64 | ~]$ source ~/.bashrc
65 | ----
66 |
67 | . Finally, ensure that [var]`JBOSS_HOME` is set in the current session, and actually points to the correct location:
68 | +
69 | NOTE: The command line usage below is based upon a binary installation of the [app]` Platform`.
70 | In this sample output, [var]`JBOSS_HOME` has been set correctly to the [replaceable]`topmost_directory` of the [app]`` installation.
71 | Note that if you are installing one of the standalone [app]`` servers (with [app]`JBoss AS` bundled!), then [var]`JBOSS_HOME` would point to the [replaceable]`topmost_directory` of your server installation.
72 | +
73 | ----
74 | ~]$ echo $JBOSS_HOME
75 | /home/silas///
76 | ----
77 |
78 |
79 | .Setting the JBOSS_HOME Environment Variable on Windows
80 | The [var]`JBOSS_HOME` environment variable must point to the directory which contains all of the files for the &THIS.PLATFORM;Platform or individual &THIS.PLATFORM;server that you installed.
81 | As another hint, this topmost directory contains a [path]_bin_ subdirectory.
82 |
83 | For information on how to set environment variables in recent versions of Windows, refer to http://support.microsoft.com/kb/931715.
84 |
85 | :sectnums:
--------------------------------------------------------------------------------
/docs/sources-asciidoc/src/main/asciidoc/Revision_History.adoc:
--------------------------------------------------------------------------------
1 |
2 | :sectnums!:
3 |
4 | [appendix]
5 | = Revision History
6 |
7 |
8 |
9 | :sectnums:
--------------------------------------------------------------------------------
/docs/sources-asciidoc/src/main/asciidoc/SCTP_Stack_User_Guide.adoc:
--------------------------------------------------------------------------------
1 | = User Guide to {this-platform} {this-application} {project-version}
2 | :doctype: book
3 | :sectnums:
4 | :toc: left
5 | :icons: font
6 | :experimental:
7 | :sourcedir: .
8 | :toclevels: 3
9 | :sectnumlevels: 4
10 |
11 | :leveloffset: 1
12 |
13 | include::Book_Info.adoc[]
14 |
15 | :leveloffset: 0
16 |
17 | :leveloffset: 1
18 |
19 | include::Common_Content/Preface.adoc[]
20 |
21 | :leveloffset: 0
22 |
23 | :leveloffset: 1
24 |
25 | include::Chapter-Introduction.adoc[]
26 |
27 | :leveloffset: 0
28 |
29 | :leveloffset: 1
30 |
31 | include::Chapter-Setup.adoc[]
32 |
33 | :leveloffset: 0
34 |
35 | :leveloffset: 1
36 |
37 | include::Chapter-Design_Overview.adoc[]
38 |
39 | :leveloffset: 0
40 |
41 | :leveloffset: 1
42 |
43 | include::Chapter-Management.adoc[]
44 |
45 | :leveloffset: 0
46 |
47 | :leveloffset: 1
48 |
49 | include::Chapter-Association.adoc[]
50 |
51 | :leveloffset: 0
52 |
53 | :leveloffset: 1
54 |
55 | include::Chapter-Example.adoc[]
56 |
57 | :leveloffset: 0
58 |
59 | :leveloffset: 1
60 |
61 | include::Revision_History.adoc[]
62 |
63 | :leveloffset: 0
64 |
--------------------------------------------------------------------------------
/docs/sources-asciidoc/src/main/asciidoc/docinfo-footer.html:
--------------------------------------------------------------------------------
1 |
70 |
71 |
72 |
73 |
79 |
80 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/docs/sources-asciidoc/src/main/asciidoc/images/SCTPGeneric.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RestComm/sctp/ed2cd7458c48cebd63e9aa126f441c8f4393639f/docs/sources-asciidoc/src/main/asciidoc/images/SCTPGeneric.jpg
--------------------------------------------------------------------------------
/docs/sources-asciidoc/src/main/asciidoc/images/SCTPGeneric.odg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RestComm/sctp/ed2cd7458c48cebd63e9aa126f441c8f4393639f/docs/sources-asciidoc/src/main/asciidoc/images/SCTPGeneric.odg
--------------------------------------------------------------------------------
/docs/sources-asciidoc/src/main/asciidoc/images/SCTPInternalArchitecture.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RestComm/sctp/ed2cd7458c48cebd63e9aa126f441c8f4393639f/docs/sources-asciidoc/src/main/asciidoc/images/SCTPInternalArchitecture.jpg
--------------------------------------------------------------------------------
/docs/sources-asciidoc/src/main/asciidoc/images/SCTPInternalArchitecture.odg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RestComm/sctp/ed2cd7458c48cebd63e9aa126f441c8f4393639f/docs/sources-asciidoc/src/main/asciidoc/images/SCTPInternalArchitecture.odg
--------------------------------------------------------------------------------
/docs/sources-asciidoc/src/main/asciidoc/images/asn-general-encoding.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RestComm/sctp/ed2cd7458c48cebd63e9aa126f441c8f4393639f/docs/sources-asciidoc/src/main/asciidoc/images/asn-general-encoding.png
--------------------------------------------------------------------------------
/docs/sources-restcomm/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 4.0.0
5 |
6 |
7 | restcomm-sctp-docs
8 | org.mobicents.protocols.sctp.docs
9 | 2.0.0-SNAPSHOT
10 |
11 |
12 | restcomm-sctp-docs-sources-restcomm
13 | Restcomm :: SCTP :: Docs :: Sources :: ${pom.artifactId}
14 |
15 | Restcomm
16 | JBoss Application Server
17 | http://github.com/Restcomm/stcp/issues
18 | https://github.com/RestComm/sctp/
19 | https://github.com/RestComm/sctp/
20 | amit.bhayani (at) gmail.com
21 | baranowb (at) gmail.com
22 | serg.vetyutnev (at) gmail.com
23 |
24 |
25 |
26 |
27 |
28 | ${basedir}/src/main/resources
29 | true
30 |
31 |
32 |
33 |
34 | org.apache.maven.plugins
35 | maven-dependency-plugin
36 |
37 |
38 | unpack
39 | generate-resources
40 |
41 | unpack
42 |
43 |
44 |
45 |
46 | ${pom.groupId}
47 | restcomm-sctp-docs-sources
48 | ${pom.version}
49 | jar
50 | true
51 | ${basedir}/src/main/resources
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | maven-antrun-plugin
60 |
61 |
62 | clean-resources
63 | clean
64 |
65 | run
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/docs/sources-restcomm/src/main/resources/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Archiver-Version: Plexus Archiver
3 | Created-By: Apache Maven Bundle Plugin
4 | Built-By: jean
5 | Build-Jdk: 1.7.0_80
6 | Implementation-Title: org.mobicents.protocols.sctp.docs:restcomm-sctp-
7 | docs-sources
8 | Implementation-Version: 1.7.0-SNAPSHOT
9 | Tool: Bnd-1.15.0
10 | Bundle-Name: Restcomm :: SCTP :: Docs :: Sources :: restcomm-sctp-docs
11 | -sources
12 | Implementation-URL: http://www.restcomm.org
13 | Implementation-Vendor-Id: TeleStax, Inc.
14 | Bundle-Version: 1.7.0.SNAPSHOT
15 | Bnd-LastModified: 1463400827136
16 | Bundle-ManifestVersion: 2
17 | Bundle-License: http://www.gnu.org/licenses/lgpl.html
18 | Bundle-Description: Restcomm :: Parent pom for 2.x releases
19 | Bundle-SymbolicName: org.mobicents.protocols.sctp.docs.restcomm-sctp-d
20 | ocs-sources
21 |
22 |
--------------------------------------------------------------------------------
/docs/sources-restcomm/src/main/resources/META-INF/maven/org.mobicents.protocols.sctp.docs/restcomm-sctp-docs-sources/pom.properties:
--------------------------------------------------------------------------------
1 | #Generated by Maven
2 | #Mon May 16 14:13:47 CEST 2016
3 | version=1.7.0-SNAPSHOT
4 | groupId=org.mobicents.protocols.sctp.docs
5 | artifactId=restcomm-sctp-docs-sources
6 |
--------------------------------------------------------------------------------
/docs/sources-restcomm/src/main/resources/META-INF/maven/org.mobicents.protocols.sctp.docs/restcomm-sctp-docs-sources/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 4.0.0
5 |
6 |
7 | restcomm-sctp-docs
8 | org.mobicents.protocols.sctp.docs
9 | 1.7.0-SNAPSHOT
10 |
11 |
12 | restcomm-sctp-docs-sources
13 | Restcomm :: SCTP :: Docs :: Sources :: ${pom.artifactId}
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | ${basedir}/src/main/resources
22 | true
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/docs/sources-restcomm/src/main/resources/en-US/Author_Group.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | %BOOK_ENTITIES;
5 | ]>
6 |
8 |
9 | Amit
10 | Bhayani
11 | &AUTHOR.EMAIL.AMIT;
12 |
13 |
14 | Sergey
15 | Vetyutnev
16 | &AUTHOR.EMAIL.SERGEY;
17 |
18 |
19 |
--------------------------------------------------------------------------------
/docs/sources-restcomm/src/main/resources/en-US/Book_Info.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | %BOOK_ENTITIES;
5 | ]>
6 |
8 | &THIS.PLATFORM; &THIS.APPLICATION; User Guide
9 |
10 | &THIS.PLATFORM; &THIS.APPLICATION;
11 | &THIS.VERSION;
12 | 3.0
13 | 1
14 |
15 |
16 | This User Guide introduces &THIS.PLATFORM; &THIS.APPLICATION;
17 |
18 |
19 |
38 |
39 | &YEAR;
40 | &HOLDER;
41 |
42 |
47 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/docs/sources-restcomm/src/main/resources/en-US/Chapter-Association.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | %BOOK_ENTITIES;
5 | ]>
6 |
7 |
8 |
9 | Association
10 |
11 | Association is a protocol relationship between endpoints. Its
12 | wrapper over actual socket exposing the same API's irrespective
13 | if its client side socket initiating connection or server side socket
14 | accepting connection. Also the underlying scoket can be of type TCP or SCTP.
15 |
16 |
17 | The Application using &THIS.PLATFORM; &THIS.APPLICATION;
18 | calls management interface to create new instance of association and
19 | keeps reference to this instance for lifetime of association for
20 | seding the PayloadData.
21 |
22 |
23 | The
24 | Association.java
25 | API looks like
26 |
27 |
28 |
35 | * A protocol relationship between endpoints
36 | *
37 | *
38 | * The implementation of this interface is actual wrapper over Socket that
39 | * know's how to communicate with peer. The user of Association shouldn't care
40 | * if the underlying Socket is client or server side
41 | *
42 | *
43 | *
44 | *
45 | *
46 | * @author amit bhayani
47 | *
48 | */
49 | public interface Association {
50 |
51 | /**
52 | * Return the Association channel type TCP or SCTP
53 | *
54 | * @return
55 | */
56 | public IpChannelType getIpChannelType();
57 |
58 | /**
59 | * Return the type of Association CLIENT or SERVER
60 | *
61 | * @return
62 | */
63 | public AssociationType getAssociationType();
64 |
65 | /**
66 | * Each association has unique name
67 | *
68 | * @return name of association
69 | */
70 | public String getName();
71 |
72 | /**
73 | * If this association is started by management
74 | *
75 | * @return
76 | */
77 | public boolean isStarted();
78 |
79 | /**
80 | * The AssociationListener set for this Association
81 | *
82 | * @return
83 | */
84 | public AssociationListener getAssociationListener();
85 |
86 | /**
87 | * The {@link AssociationListener} to be registered for this Association
88 | *
89 | * @param associationListener
90 | */
91 | public void setAssociationListener(AssociationListener associationListener);
92 |
93 | /**
94 | * The host address that underlying socket is bound to
95 | *
96 | * @return
97 | */
98 | public String getHostAddress();
99 |
100 | /**
101 | * The host port that underlying socket is bound to
102 | *
103 | * @return
104 | */
105 | public int getHostPort();
106 |
107 | /**
108 | * The peer address that the underlying socket connects to
109 | *
110 | * @return
111 | */
112 | public String getPeerAddress();
113 |
114 | /**
115 | * The peer port that the underlying socket is connected to
116 | *
117 | * @return
118 | */
119 | public int getPeerPort();
120 |
121 | /**
122 | * Server name if the association is for {@link Server}
123 | *
124 | * @return
125 | */
126 | public String getServerName();
127 |
128 | /**
129 | * When SCTP multi-homing configuration extra IP addresses are here
130 | *
131 | * @return
132 | */
133 | public String[] getExtraHostAddresses();
134 |
135 | /**
136 | * Send the {@link PayloadData} to the peer
137 | *
138 | * @param payloadData
139 | * @throws Exception
140 | */
141 | public void send(PayloadData payloadData) throws Exception;
142 |
143 | }
144 |
145 | ]]>
146 |
147 |
148 | Application interested in receiving payload from underlying
149 | socket registers the instance of class implementing
150 | AssociationListener with this Association.
151 |
152 |
153 | The
154 | AssociationListener.java
155 | API looks like
156 |
157 |
158 |
163 | * The listener interface for receiving the underlying socket status and
164 | * received payload from peer. The class that is interested in receiving data
165 | * must implement this interface, and the object created with that class is
166 | * registered with {@link Association}
167 | *
168 | *
169 | * @author amit bhayani
170 | *
171 | */
172 | public interface AssociationListener {
173 |
174 | /**
175 | * Invoked when underlying socket is open and connection is established with
176 | * peer. This is expected behavior when management start's the
177 | * {@link Association}
178 | *
179 | * @param association
180 | */
181 | public void onCommunicationUp(Association association);
182 |
183 | /**
184 | * Invoked when underlying socket is shutdown and connection is ended with
185 | * peer. This is expected behavior when management stop's the
186 | * {@link Association}
187 | *
188 | * @param association
189 | */
190 | public void onCommunicationShutdown(Association association);
191 |
192 | /**
193 | * Invoked when underlying socket lost the connection with peer due to any
194 | * reason like network between peer's died etc. This is unexpected behavior
195 | * and the underlying {@link Association} should try to re-establish the
196 | * connection
197 | *
198 | * @param association
199 | */
200 | public void onCommunicationLost(Association association);
201 |
202 | /**
203 | * Invoked when the connection with the peer re-started. This is specific to
204 | * SCTP protocol
205 | *
206 | * @param association
207 | */
208 | public void onCommunicationRestart(Association association);
209 |
210 | /**
211 | * Invoked when the {@link PayloadData} is received from peer
212 | *
213 | * @param association
214 | * @param payloadData
215 | */
216 | public void onPayload(Association association, PayloadData payloadData);
217 |
218 | }
219 | ]]>
220 |
221 |
--------------------------------------------------------------------------------
/docs/sources-restcomm/src/main/resources/en-US/Chapter-Design_Overview.xml:
--------------------------------------------------------------------------------
1 |
2 |
%BOOK_ENTITIES;
]>
3 |
4 |
5 |
6 | Design Overview
7 |
8 | The internal structure of &THIS.PLATFORM; &THIS.APPLICATION; looks like
9 |
10 |
11 |
12 | Architecture
13 |
14 |
15 |
17 |
18 |
19 |
20 |
21 |
22 | The prime responsibility of &THIS.PLATFORM; &THIS.APPLICATION; is abstract Application from underlying SCTP sockets and expose same API (Association.java) irrespective if the underlying SCTP is acting as
23 | server side waiting for client to connect or client side initiating connection.
24 |
25 |
26 |
27 | The management (Management.java) controls the associations and servers. The Application can execute commands to create/delete associations/servers.
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/docs/sources-restcomm/src/main/resources/en-US/Chapter-Example.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | %BOOK_ENTITIES;
5 | ]>
6 |
7 |
8 |
9 | Example
10 |
11 | This chapter tours around the core constructs of &THIS.PLATFORM; &THIS.APPLICATION; with simple examples to let you get started quickly.
12 | You will be able to write a client and a server on top of &THIS.PLATFORM; &THIS.APPLICATION; right away when you are at the end of this chapter.
13 |
14 |
15 |
16 | Before Getting Started
17 |
18 | The minimum requirements to run the examples which are introduced in
19 | this chapter are only two; the latest version of &THIS.PLATFORM; &THIS.APPLICATION; and JDK 1.7 or
20 | above with SCTP support. At time of writing this guide linux kernel has native support for SCTP (lksctp) and also Solaris includes SCTP.
21 |
22 |
23 |
24 | Initiating Management
25 |
26 | The primitive step in uisng &THIS.PLATFORM; &THIS.APPLICATION; is to create instance of Management class and set appropriate parameters.
27 |
28 |
29 |
30 |
31 | private static final String SERVER_NAME = "testserver";
32 | private static final String SERVER_HOST = "127.0.0.1";
33 | private static final int SERVER_PORT = 2345;
34 |
35 | private static final String SERVER_ASSOCIATION_NAME = "serverAsscoiation";
36 | private static final String CLIENT_ASSOCIATION_NAME = "clientAsscoiation";
37 |
38 | private static final String CLIENT_HOST = "127.0.0.1";
39 | private static final int CLIENT_PORT = 2346;
40 | ...
41 | ....
42 | ....
43 |
44 | Management management = new ManagementImpl("SCTPTest");
45 | management.setConnectDelay(10000);// Try connecting every 10 secs
46 | management.setSingleThread(true);
47 | management.start();
48 |
49 |
50 |
51 |
52 |
53 | Crate new instance of ManagementImpl and setting the management name. The management will search for SCTPTest_SCTP.xml file to load the previously
54 | configured Serever's or Association's. If file is not found it will create one.
55 |
56 |
57 |
58 |
59 | connectDelay is only useful for Associations acting as client side trying to connect to peer. The value specified is time in milliseconds
60 | the unedrlying socket will try to connect to peer if the existing connection is broken or even if its fresh connection attempt.
61 |
62 |
63 |
64 |
65 | Setting management to single thread. All the callback's (irrespective of streamNumber of packet) to the listener will be via single thread. However there is one dedicated thread
66 | only for I/O.
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | Adding Server and server Association
75 |
76 | Once the Managment is setup, application can create Server and add server Association
77 |
78 |
79 |
80 | Server server = this.management.addServer(SERVER_NAME, SERVER_HOST, SERVER_PORT);
81 | Association serverAssociation = this.management.addServerAssociation(CLIENT_HOST, CLIENT_PORT, SERVER_NAME, SERVER_ASSOCIATION_NAME);
82 |
83 | serverAssociation.setAssociationListener(new ServerAssociationListener());
84 |
85 | this.management.startAssociation(SERVER_ASSOCIATION_NAME);
86 | this.management.startServer(SERVER_NAME);
87 |
88 |
89 |
90 |
91 |
92 | Add the server and server association. Multiple server's can be added to each management and each server can have multiple server association's
93 |
94 |
95 |
96 |
97 | The instance of AssociationListener should be registered with newly created Associaton before starting it.
98 | There is no dependency on order of starting server and server association.
99 |
100 |
101 |
102 |
103 |
104 |
105 | Below is example of class implementing AssociationListener
106 |
107 |
108 |
109 | class ServerAssociationListener implements AssociationListener {
110 |
111 | private final byte[] SERVER_MESSAGE = "Server says Hi".getBytes();
112 |
113 | /*
114 | * (non-Javadoc)
115 | *
116 | * @see
117 | * org.mobicents.protocols.sctp.AssociationListener#onCommunicationUp
118 | * (org.mobicents.protocols.sctp.Association)
119 | */
120 | @Override
121 | public void onCommunicationUp(Association association) {
122 | System.out.println(this + " onCommunicationUp");
123 |
124 | serverAssocUp = true;
125 |
126 | PayloadData payloadData = new PayloadData(SERVER_MESSAGE.length, SERVER_MESSAGE, true, false, 3, 1);
127 |
128 | try {
129 | association.send(payloadData);
130 | } catch (Exception e) {
131 | e.printStackTrace();
132 | }
133 | }
134 |
135 | /*
136 | * (non-Javadoc)
137 | *
138 | * @see
139 | * org.mobicents.protocols.sctp.AssociationListener#onCommunicationShutdown
140 | * (org.mobicents.protocols.sctp.Association)
141 | */
142 | @Override
143 | public void onCommunicationShutdown(Association association) {
144 | System.out.println(this + " onCommunicationShutdown");
145 | serverAssocDown = true;
146 | }
147 |
148 | /*
149 | * (non-Javadoc)
150 | *
151 | * @see
152 | * org.mobicents.protocols.sctp.AssociationListener#onCommunicationLost
153 | * (org.mobicents.protocols.sctp.Association)
154 | */
155 | @Override
156 | public void onCommunicationLost(Association association) {
157 | System.out.println(this + " onCommunicationLost");
158 | }
159 |
160 | /*
161 | * (non-Javadoc)
162 | *
163 | * @see
164 | * org.mobicents.protocols.sctp.AssociationListener#onCommunicationRestart
165 | * (org.mobicents.protocols.sctp.Association)
166 | */
167 | @Override
168 | public void onCommunicationRestart(Association association) {
169 | System.out.println(this + " onCommunicationRestart");
170 | }
171 |
172 | /*
173 | * (non-Javadoc)
174 | *
175 | * @see
176 | * org.mobicents.protocols.sctp.AssociationListener#onPayload(org.mobicents
177 | * .protocols.sctp.Association,
178 | * org.mobicents.protocols.sctp.PayloadData)
179 | */
180 | @Override
181 | public void onPayload(Association association, PayloadData payloadData) {
182 | System.out.println(this + " onPayload");
183 |
184 | serverMessage = new byte[payloadData.getDataLength()];
185 | System.arraycopy(payloadData.getData(), 0, serverMessage, 0, payloadData.getDataLength());
186 |
187 | System.out.println(this + "received " + new String(serverMessage));
188 | }
189 |
190 | }
191 |
192 |
193 |
194 | Adding Association
195 |
196 | Once the Managment is setup, application can create client side Association.
197 |
198 |
199 | Association clientAssociation = this.management.addAssociation(CLIENT_HOST, CLIENT_PORT, SERVER_HOST, SERVER_PORT, CLIENT_ASSOCIATION_NAME);
200 | clientAssociation.setAssociationListener(new ClientAssociationListenerImpl());
201 | this.management.startAssociation(CLIENT_ASSOCIATION_NAME);
202 |
203 |
204 |
205 |
206 |
207 |
--------------------------------------------------------------------------------
/docs/sources-restcomm/src/main/resources/en-US/Chapter-Introduction.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | %BOOK_ENTITIES;
6 | ]>
7 |
8 |
9 |
10 | Introduction
11 | to &THIS.PLATFORM; &THIS.APPLICATION;
12 |
13 |
14 | In computer networking, the Stream Control Transmission Protocol
15 | (SCTP)
16 | is a Transport Layer protocol, serving in a similar role to the
17 | popular protocols Transmission Control Protocol (TCP) and User
18 | Datagram Protocol (UDP). It provides some of the same service features
19 | of both: it is message-oriented like UDP and ensures reliable,
20 | in-sequence transport of messages with congestion control like TCP.
21 |
22 |
23 | The protocol was defined by the IETF Signaling Transport (SIGTRAN)
24 | working group in 2000 and is maintained by the IETF Transport Area
25 | (TSVWG) working group.
26 | RFC 4960
27 | defines the protocol.
28 | RFC 3286
29 | provides an introduction.
30 |
31 |
32 |
33 | &THIS.PLATFORM; &THIS.APPLICATION;
34 | is providing the convenient API's over Java SCTP, hence can be used
35 | only with version JDK 1.7 or above.
36 |
37 |
38 | &THIS.PLATFORM; &THIS.APPLICATION; can also create the TCP sockets exposing same high level API's hence application using &THIS.PLATFORM; &THIS.APPLICATION;
39 | can work seamless with TCP or SCTP.
40 |
41 |
42 |
43 | The TCP facility is only for test to support the OS which doesn't have SCTP available out-of-box. For example Windows OS.
44 |
45 |
46 |
47 | In addition to exposing the SCTP protocol, &THIS.PLATFORM; &THIS.APPLICATION;
48 | contains number of features which other wise the application depending on
49 | SCTP will have to take care of. For example &THIS.PLATFORM; &THIS.APPLICATION;
50 | provides
51 |
52 |
53 |
54 |
55 | Management interface to manage the underlying SCTP Associations
56 |
57 |
58 | Persistence mechanism capable of initiating the SCTP
59 | Association if the system is restarted after crash or gracefull
60 | shutdown
61 |
62 |
63 | Tries re-initiate the connection if for some reason the connection is lost between the peers
64 |
65 |
66 | Configuration to make the module behave as single thread or multi-threaded depending on requirement's of application
67 |
68 |
69 |
70 |
71 |
72 | Below diagram shows various layers involved
73 |
74 |
75 | Layers involved
76 |
77 |
78 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/docs/sources-restcomm/src/main/resources/en-US/Chapter-Setup.xml:
--------------------------------------------------------------------------------
1 |
2 |
%BOOK_ENTITIES;
]>
3 |
4 |
5 |
6 | Setup
7 |
8 |
21 |
22 |
23 | &THIS.PLATFORM; &THIS.APPLICATION; Source Code
24 |
25 |
26 |
27 | Release Source Code Building
28 |
29 |
30 | Downloading the source code
31 |
32 | Subversion is used to manage its source code. Instructions for using Subversion, including install, can be found at
33 |
34 | Use SVN to checkout a specific release source, the base URL is &THIS.RELEASE_SOURCE_CODE_URL;, then add the specific release version, lets consider &THIS.VERSION;.
35 | [usr]$ svn co &THIS.RELEASE_SOURCE_CODE_URL;/&THIS.VERSION; &THIS.APPLICATION.DIRNAME;-&THIS.VERSION;
36 |
37 |
38 | Building the source code
39 |
40 | Maven 2.0.9 (or higher) is used to build the release. Instructions for using Maven2, including install, can be found at
41 |
42 | Use Maven to build the binaries.
43 |
44 | [usr]$ cd &THIS.APPLICATION.DIRNAME;-&THIS.VERSION;
45 | [usr]$ mvn install
46 |
47 | Once the process finishes you should have the binary jar files in the target directory of module.
48 |
49 |
50 |
51 |
52 |
53 | Development Trunk Source Building
54 | Similar process as for , the only change is the SVN source code URL, which is &THIS.TRUNK_SOURCE_CODE_URL;.
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/docs/sources-restcomm/src/main/resources/en-US/Revision_History.xml:
--------------------------------------------------------------------------------
1 |
2 |
%BOOK_ENTITIES;
]>
3 |
5 | Revision History
6 |
7 |
8 |
9 | 1.0
10 | Fri Nov 25 2011
11 |
12 | Amit
13 | Bhayani
14 |
15 |
16 |
17 | Creation of the &THIS.PLATFORM; &THIS.APPLICATION; User Guide.
18 |
19 |
20 |
21 |
22 |
23 | 1.1
24 | Thu Jul 05 2012
25 |
26 | Serg
27 | Vetyutnev
28 |
29 |
30 |
31 | Adding ManagementEventListener.
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/docs/sources-restcomm/src/main/resources/en-US/SCTP_Stack_User_Guide.ent:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/docs/sources-restcomm/src/main/resources/en-US/SCTP_Stack_User_Guide.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
31 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/docs/sources-restcomm/src/main/resources/en-US/common/Preface.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 | Preface
6 |
9 |
10 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/sources-restcomm/src/main/resources/en-US/common/Section-Feedback.xml:
--------------------------------------------------------------------------------
1 |
2 |
%BOOK_ENTITIES;
]>
3 |
4 |
5 |
6 | Provide feedback to the authors!
7 |
8 |
9 | feedback
10 |
11 |
12 | If you find a typographical error in this manual, or if you have thought of a way to make this manual better, we would love to hear from you! Please submit a report in the the Issue Tracker, against the product &THIS.PLATFORM; &THIS.APPLICATION; , or contact the authors.
13 | When submitting a bug report, be sure to mention the manual's identifier: &BOOK_ID;
14 | If you have a suggestion for improving the documentation, try to be as specific as possible when describing it. If you have found an error, please include the section number and some of the surrounding text so we can find it easily.
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/docs/sources-restcomm/src/main/resources/en-US/images/SCTPGeneric.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RestComm/sctp/ed2cd7458c48cebd63e9aa126f441c8f4393639f/docs/sources-restcomm/src/main/resources/en-US/images/SCTPGeneric.jpg
--------------------------------------------------------------------------------
/docs/sources-restcomm/src/main/resources/en-US/images/SCTPInternalArchitecture.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RestComm/sctp/ed2cd7458c48cebd63e9aa126f441c8f4393639f/docs/sources-restcomm/src/main/resources/en-US/images/SCTPInternalArchitecture.jpg
--------------------------------------------------------------------------------
/docs/sources-restcomm/src/main/resources/en-US/images/asn-general-encoding.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RestComm/sctp/ed2cd7458c48cebd63e9aa126f441c8f4393639f/docs/sources-restcomm/src/main/resources/en-US/images/asn-general-encoding.png
--------------------------------------------------------------------------------
/docs/sources/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 4.0.0
5 |
6 |
7 | restcomm-sctp-docs
8 | org.mobicents.protocols.sctp.docs
9 | 2.0.0-SNAPSHOT
10 |
11 |
12 | restcomm-sctp-docs-sources
13 | Restcomm :: SCTP :: Docs :: Sources :: ${pom.artifactId}
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | ${basedir}/src/main/resources
22 | true
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/docs/sources/src/main/resources/en-US/Author_Group.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | %BOOK_ENTITIES;
5 | ]>
6 |
8 |
9 | Amit
10 | Bhayani
11 | &AUTHOR.EMAIL.AMIT;
12 |
13 |
14 | Sergey
15 | Vetyutnev
16 | &AUTHOR.EMAIL.SERGEY;
17 |
18 |
19 |
--------------------------------------------------------------------------------
/docs/sources/src/main/resources/en-US/Book_Info.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | %BOOK_ENTITIES;
5 | ]>
6 |
8 | &THIS.PLATFORM; &THIS.APPLICATION; User Guide
9 |
10 | &THIS.PLATFORM; &THIS.APPLICATION;
11 | &THIS.VERSION;
12 | 3.0
13 | 1
14 |
15 |
16 | This User Guide introduces &THIS.PLATFORM; &THIS.APPLICATION;
17 |
18 |
19 |
38 |
39 | &YEAR;
40 | &HOLDER;
41 |
42 |
47 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/docs/sources/src/main/resources/en-US/Chapter-Association.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | %BOOK_ENTITIES;
5 | ]>
6 |
7 |
8 |
9 | Association
10 |
11 | Association is a protocol relationship between endpoints. Its
12 | wrapper over actual socket exposing the same API's irrespective
13 | if its client side socket initiating connection or server side socket
14 | accepting connection. Also the underlying scoket can be of type TCP or SCTP.
15 |
16 |
17 | The Application using &THIS.PLATFORM; &THIS.APPLICATION;
18 | calls management interface to create new instance of association and
19 | keeps reference to this instance for lifetime of association for
20 | seding the PayloadData.
21 |
22 |
23 | The
24 | Association.java
25 | API looks like
26 |
27 |
28 |
35 | * A protocol relationship between endpoints
36 | *
37 | *
38 | * The implementation of this interface is actual wrapper over Socket that
39 | * know's how to communicate with peer. The user of Association shouldn't care
40 | * if the underlying Socket is client or server side
41 | *
42 | *
43 | *
44 | *
45 | *
46 | * @author amit bhayani
47 | *
48 | */
49 | public interface Association {
50 |
51 | /**
52 | * Return the Association channel type TCP or SCTP
53 | *
54 | * @return
55 | */
56 | public IpChannelType getIpChannelType();
57 |
58 | /**
59 | * Return the type of Association CLIENT or SERVER
60 | *
61 | * @return
62 | */
63 | public AssociationType getAssociationType();
64 |
65 | /**
66 | * Each association has unique name
67 | *
68 | * @return name of association
69 | */
70 | public String getName();
71 |
72 | /**
73 | * If this association is started by management
74 | *
75 | * @return
76 | */
77 | public boolean isStarted();
78 |
79 | /**
80 | * The AssociationListener set for this Association
81 | *
82 | * @return
83 | */
84 | public AssociationListener getAssociationListener();
85 |
86 | /**
87 | * The {@link AssociationListener} to be registered for this Association
88 | *
89 | * @param associationListener
90 | */
91 | public void setAssociationListener(AssociationListener associationListener);
92 |
93 | /**
94 | * The host address that underlying socket is bound to
95 | *
96 | * @return
97 | */
98 | public String getHostAddress();
99 |
100 | /**
101 | * The host port that underlying socket is bound to
102 | *
103 | * @return
104 | */
105 | public int getHostPort();
106 |
107 | /**
108 | * The peer address that the underlying socket connects to
109 | *
110 | * @return
111 | */
112 | public String getPeerAddress();
113 |
114 | /**
115 | * The peer port that the underlying socket is connected to
116 | *
117 | * @return
118 | */
119 | public int getPeerPort();
120 |
121 | /**
122 | * Server name if the association is for {@link Server}
123 | *
124 | * @return
125 | */
126 | public String getServerName();
127 |
128 | /**
129 | * When SCTP multi-homing configuration extra IP addresses are here
130 | *
131 | * @return
132 | */
133 | public String[] getExtraHostAddresses();
134 |
135 | /**
136 | * Send the {@link PayloadData} to the peer
137 | *
138 | * @param payloadData
139 | * @throws Exception
140 | */
141 | public void send(PayloadData payloadData) throws Exception;
142 |
143 | }
144 |
145 | ]]>
146 |
147 |
148 | Application interested in receiving payload from underlying
149 | socket registers the instance of class implementing
150 | AssociationListener with this Association.
151 |
152 |
153 | The
154 | AssociationListener.java
155 | API looks like
156 |
157 |
158 |
163 | * The listener interface for receiving the underlying socket status and
164 | * received payload from peer. The class that is interested in receiving data
165 | * must implement this interface, and the object created with that class is
166 | * registered with {@link Association}
167 | *
168 | *
169 | * @author amit bhayani
170 | *
171 | */
172 | public interface AssociationListener {
173 |
174 | /**
175 | * Invoked when underlying socket is open and connection is established with
176 | * peer. This is expected behavior when management start's the
177 | * {@link Association}
178 | *
179 | * @param association
180 | */
181 | public void onCommunicationUp(Association association);
182 |
183 | /**
184 | * Invoked when underlying socket is shutdown and connection is ended with
185 | * peer. This is expected behavior when management stop's the
186 | * {@link Association}
187 | *
188 | * @param association
189 | */
190 | public void onCommunicationShutdown(Association association);
191 |
192 | /**
193 | * Invoked when underlying socket lost the connection with peer due to any
194 | * reason like network between peer's died etc. This is unexpected behavior
195 | * and the underlying {@link Association} should try to re-establish the
196 | * connection
197 | *
198 | * @param association
199 | */
200 | public void onCommunicationLost(Association association);
201 |
202 | /**
203 | * Invoked when the connection with the peer re-started. This is specific to
204 | * SCTP protocol
205 | *
206 | * @param association
207 | */
208 | public void onCommunicationRestart(Association association);
209 |
210 | /**
211 | * Invoked when the {@link PayloadData} is received from peer
212 | *
213 | * @param association
214 | * @param payloadData
215 | */
216 | public void onPayload(Association association, PayloadData payloadData);
217 |
218 | }
219 | ]]>
220 |
221 |
--------------------------------------------------------------------------------
/docs/sources/src/main/resources/en-US/Chapter-Design_Overview.xml:
--------------------------------------------------------------------------------
1 |
2 |
%BOOK_ENTITIES;
]>
3 |
4 |
5 |
6 | Design Overview
7 |
8 | The internal structure of &THIS.PLATFORM; &THIS.APPLICATION; looks like
9 |
10 |
11 |
12 | Architecture
13 |
14 |
15 |
17 |
18 |
19 |
20 |
21 |
22 | The prime responsibility of &THIS.PLATFORM; &THIS.APPLICATION; is abstract Application from underlying SCTP sockets and expose same API (Association.java) irrespective if the underlying SCTP is acting as
23 | server side waiting for client to connect or client side initiating connection.
24 |
25 |
26 |
27 | The management (Management.java) controls the associations and servers. The Application can execute commands to create/delete associations/servers.
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/docs/sources/src/main/resources/en-US/Chapter-Example.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | %BOOK_ENTITIES;
5 | ]>
6 |
7 |
8 |
9 | Example
10 |
11 | This chapter tours around the core constructs of &THIS.PLATFORM; &THIS.APPLICATION; with simple examples to let you get started quickly.
12 | You will be able to write a client and a server on top of &THIS.PLATFORM; &THIS.APPLICATION; right away when you are at the end of this chapter.
13 |
14 |
15 |
16 | Before Getting Started
17 |
18 | The minimum requirements to run the examples which are introduced in
19 | this chapter are only two; the latest version of &THIS.PLATFORM; &THIS.APPLICATION; and JDK 1.7 or
20 | above with SCTP support. At time of writing this guide linux kernel has native support for SCTP (lksctp) and also Solaris includes SCTP.
21 |
22 |
23 |
24 | Initiating Management
25 |
26 | The primitive step in uisng &THIS.PLATFORM; &THIS.APPLICATION; is to create instance of Management class and set appropriate parameters.
27 |
28 |
29 |
30 |
31 | private static final String SERVER_NAME = "testserver";
32 | private static final String SERVER_HOST = "127.0.0.1";
33 | private static final int SERVER_PORT = 2345;
34 |
35 | private static final String SERVER_ASSOCIATION_NAME = "serverAsscoiation";
36 | private static final String CLIENT_ASSOCIATION_NAME = "clientAsscoiation";
37 |
38 | private static final String CLIENT_HOST = "127.0.0.1";
39 | private static final int CLIENT_PORT = 2346;
40 | ...
41 | ....
42 | ....
43 |
44 | Management management = new ManagementImpl("SCTPTest");
45 | management.setConnectDelay(10000);// Try connecting every 10 secs
46 | management.setSingleThread(true);
47 | management.start();
48 |
49 |
50 |
51 |
52 |
53 | Crate new instance of ManagementImpl and setting the management name. The management will search for SCTPTest_SCTP.xml file to load the previously
54 | configured Serever's or Association's. If file is not found it will create one.
55 |
56 |
57 |
58 |
59 | connectDelay is only useful for Associations acting as client side trying to connect to peer. The value specified is time in milliseconds
60 | the unedrlying socket will try to connect to peer if the existing connection is broken or even if its fresh connection attempt.
61 |
62 |
63 |
64 |
65 | Setting management to single thread. All the callback's (irrespective of streamNumber of packet) to the listener will be via single thread. However there is one dedicated thread
66 | only for I/O.
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | Adding Server and server Association
75 |
76 | Once the Managment is setup, application can create Server and add server Association
77 |
78 |
79 |
80 | Server server = this.management.addServer(SERVER_NAME, SERVER_HOST, SERVER_PORT);
81 | Association serverAssociation = this.management.addServerAssociation(CLIENT_HOST, CLIENT_PORT, SERVER_NAME, SERVER_ASSOCIATION_NAME);
82 |
83 | serverAssociation.setAssociationListener(new ServerAssociationListener());
84 |
85 | this.management.startAssociation(SERVER_ASSOCIATION_NAME);
86 | this.management.startServer(SERVER_NAME);
87 |
88 |
89 |
90 |
91 |
92 | Add the server and server association. Multiple server's can be added to each management and each server can have multiple server association's
93 |
94 |
95 |
96 |
97 | The instance of AssociationListener should be registered with newly created Associaton before starting it.
98 | There is no dependency on order of starting server and server association.
99 |
100 |
101 |
102 |
103 |
104 |
105 | Below is example of class implementing AssociationListener
106 |
107 |
108 |
109 | class ServerAssociationListener implements AssociationListener {
110 |
111 | private final byte[] SERVER_MESSAGE = "Server says Hi".getBytes();
112 |
113 | /*
114 | * (non-Javadoc)
115 | *
116 | * @see
117 | * org.mobicents.protocols.sctp.AssociationListener#onCommunicationUp
118 | * (org.mobicents.protocols.sctp.Association)
119 | */
120 | @Override
121 | public void onCommunicationUp(Association association) {
122 | System.out.println(this + " onCommunicationUp");
123 |
124 | serverAssocUp = true;
125 |
126 | PayloadData payloadData = new PayloadData(SERVER_MESSAGE.length, SERVER_MESSAGE, true, false, 3, 1);
127 |
128 | try {
129 | association.send(payloadData);
130 | } catch (Exception e) {
131 | e.printStackTrace();
132 | }
133 | }
134 |
135 | /*
136 | * (non-Javadoc)
137 | *
138 | * @see
139 | * org.mobicents.protocols.sctp.AssociationListener#onCommunicationShutdown
140 | * (org.mobicents.protocols.sctp.Association)
141 | */
142 | @Override
143 | public void onCommunicationShutdown(Association association) {
144 | System.out.println(this + " onCommunicationShutdown");
145 | serverAssocDown = true;
146 | }
147 |
148 | /*
149 | * (non-Javadoc)
150 | *
151 | * @see
152 | * org.mobicents.protocols.sctp.AssociationListener#onCommunicationLost
153 | * (org.mobicents.protocols.sctp.Association)
154 | */
155 | @Override
156 | public void onCommunicationLost(Association association) {
157 | System.out.println(this + " onCommunicationLost");
158 | }
159 |
160 | /*
161 | * (non-Javadoc)
162 | *
163 | * @see
164 | * org.mobicents.protocols.sctp.AssociationListener#onCommunicationRestart
165 | * (org.mobicents.protocols.sctp.Association)
166 | */
167 | @Override
168 | public void onCommunicationRestart(Association association) {
169 | System.out.println(this + " onCommunicationRestart");
170 | }
171 |
172 | /*
173 | * (non-Javadoc)
174 | *
175 | * @see
176 | * org.mobicents.protocols.sctp.AssociationListener#onPayload(org.mobicents
177 | * .protocols.sctp.Association,
178 | * org.mobicents.protocols.sctp.PayloadData)
179 | */
180 | @Override
181 | public void onPayload(Association association, PayloadData payloadData) {
182 | System.out.println(this + " onPayload");
183 |
184 | serverMessage = new byte[payloadData.getDataLength()];
185 | System.arraycopy(payloadData.getData(), 0, serverMessage, 0, payloadData.getDataLength());
186 |
187 | System.out.println(this + "received " + new String(serverMessage));
188 | }
189 |
190 | }
191 |
192 |
193 |
194 | Adding Association
195 |
196 | Once the Managment is setup, application can create client side Association.
197 |
198 |
199 | Association clientAssociation = this.management.addAssociation(CLIENT_HOST, CLIENT_PORT, SERVER_HOST, SERVER_PORT, CLIENT_ASSOCIATION_NAME);
200 | clientAssociation.setAssociationListener(new ClientAssociationListenerImpl());
201 | this.management.startAssociation(CLIENT_ASSOCIATION_NAME);
202 |
203 |
204 |
205 |
206 |
207 |
--------------------------------------------------------------------------------
/docs/sources/src/main/resources/en-US/Chapter-Introduction.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | %BOOK_ENTITIES;
6 | ]>
7 |
8 |
9 |
10 | Introduction
11 | to &THIS.PLATFORM; &THIS.APPLICATION;
12 |
13 |
14 | In computer networking, the Stream Control Transmission Protocol
15 | (SCTP)
16 | is a Transport Layer protocol, serving in a similar role to the
17 | popular protocols Transmission Control Protocol (TCP) and User
18 | Datagram Protocol (UDP). It provides some of the same service features
19 | of both: it is message-oriented like UDP and ensures reliable,
20 | in-sequence transport of messages with congestion control like TCP.
21 |
22 |
23 | The protocol was defined by the IETF Signaling Transport (SIGTRAN)
24 | working group in 2000 and is maintained by the IETF Transport Area
25 | (TSVWG) working group.
26 | RFC 4960
27 | defines the protocol.
28 | RFC 3286
29 | provides an introduction.
30 |
31 |
32 |
33 | &THIS.PLATFORM; &THIS.APPLICATION;
34 | is providing the convenient API's over Java SCTP, hence can be used
35 | only with version JDK 1.7 or above.
36 |
37 |
38 | &THIS.PLATFORM; &THIS.APPLICATION; can also create the TCP sockets exposing same high level API's hence application using &THIS.PLATFORM; &THIS.APPLICATION;
39 | can work seamless with TCP or SCTP.
40 |
41 |
42 |
43 | The TCP facility is only for test to support the OS which doesn't have SCTP available out-of-box. For example Windows OS.
44 |
45 |
46 |
47 | In addition to exposing the SCTP protocol, &THIS.PLATFORM; &THIS.APPLICATION;
48 | contains number of features which other wise the application depending on
49 | SCTP will have to take care of. For example &THIS.PLATFORM; &THIS.APPLICATION;
50 | provides
51 |
52 |
53 |
54 |
55 | Management interface to manage the underlying SCTP Associations
56 |
57 |
58 | Persistence mechanism capable of initiating the SCTP
59 | Association if the system is restarted after crash or gracefull
60 | shutdown
61 |
62 |
63 | Tries re-initiate the connection if for some reason the connection is lost between the peers
64 |
65 |
66 | Configuration to make the module behave as single thread or multi-threaded depending on requirement's of application
67 |
68 |
69 |
70 |
71 |
72 | Below diagram shows various layers involved
73 |
74 |
75 | Layers involved
76 |
77 |
78 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/docs/sources/src/main/resources/en-US/Chapter-Setup.xml:
--------------------------------------------------------------------------------
1 |
2 |
%BOOK_ENTITIES;
]>
3 |
4 |
5 |
6 | Setup
7 |
8 |
21 |
22 |
23 | &THIS.PLATFORM; &THIS.APPLICATION; Source Code
24 |
25 |
26 |
27 | Release Source Code Building
28 |
29 |
30 | Downloading the source code
31 |
32 | Subversion is used to manage its source code. Instructions for using Subversion, including install, can be found at
33 |
34 | Use SVN to checkout a specific release source, the base URL is &THIS.RELEASE_SOURCE_CODE_URL;, then add the specific release version, lets consider &THIS.VERSION;.
35 | [usr]$ svn co &THIS.RELEASE_SOURCE_CODE_URL;/&THIS.VERSION; &THIS.APPLICATION.DIRNAME;-&THIS.VERSION;
36 |
37 |
38 | Building the source code
39 |
40 | Maven 2.0.9 (or higher) is used to build the release. Instructions for using Maven2, including install, can be found at
41 |
42 | Use Maven to build the binaries.
43 |
44 | [usr]$ cd &THIS.APPLICATION.DIRNAME;-&THIS.VERSION;
45 | [usr]$ mvn install
46 |
47 | Once the process finishes you should have the binary jar files in the target directory of module.
48 |
49 |
50 |
51 |
52 |
53 | Development Trunk Source Building
54 | Similar process as for , the only change is the SVN source code URL, which is &THIS.TRUNK_SOURCE_CODE_URL;.
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/docs/sources/src/main/resources/en-US/Revision_History.xml:
--------------------------------------------------------------------------------
1 |
2 |
%BOOK_ENTITIES;
]>
3 |
5 | Revision History
6 |
7 |
8 |
9 | 1.0
10 | Fri Nov 25 2011
11 |
12 | Amit
13 | Bhayani
14 |
15 |
16 |
17 | Creation of the &THIS.PLATFORM; &THIS.APPLICATION; User Guide.
18 |
19 |
20 |
21 |
22 |
23 | 1.1
24 | Thu Jul 05 2012
25 |
26 | Serg
27 | Vetyutnev
28 |
29 |
30 |
31 | Adding ManagementEventListener.
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/docs/sources/src/main/resources/en-US/SCTP_Stack_User_Guide.ent:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/docs/sources/src/main/resources/en-US/SCTP_Stack_User_Guide.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
31 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/docs/sources/src/main/resources/en-US/common/Preface.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 | Preface
6 |
9 |
10 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/sources/src/main/resources/en-US/common/Section-Feedback.xml:
--------------------------------------------------------------------------------
1 |
2 |
%BOOK_ENTITIES;
]>
3 |
4 |
5 |
6 | Provide feedback to the authors!
7 |
8 |
9 | feedback
10 |
11 |
12 | If you find a typographical error in this manual, or if you have thought of a way to make this manual better, we would love to hear from you! Please submit a report in the the Issue Tracker, against the product &THIS.PLATFORM; &THIS.APPLICATION; , or contact the authors.
13 | When submitting a bug report, be sure to mention the manual's identifier: &BOOK_ID;
14 | If you have a suggestion for improving the documentation, try to be as specific as possible when describing it. If you have found an error, please include the section number and some of the surrounding text so we can find it easily.
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/docs/sources/src/main/resources/en-US/images/SCTPGeneric.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RestComm/sctp/ed2cd7458c48cebd63e9aa126f441c8f4393639f/docs/sources/src/main/resources/en-US/images/SCTPGeneric.jpg
--------------------------------------------------------------------------------
/docs/sources/src/main/resources/en-US/images/SCTPGeneric.odg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RestComm/sctp/ed2cd7458c48cebd63e9aa126f441c8f4393639f/docs/sources/src/main/resources/en-US/images/SCTPGeneric.odg
--------------------------------------------------------------------------------
/docs/sources/src/main/resources/en-US/images/SCTPInternalArchitecture.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RestComm/sctp/ed2cd7458c48cebd63e9aa126f441c8f4393639f/docs/sources/src/main/resources/en-US/images/SCTPInternalArchitecture.jpg
--------------------------------------------------------------------------------
/docs/sources/src/main/resources/en-US/images/SCTPInternalArchitecture.odg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RestComm/sctp/ed2cd7458c48cebd63e9aa126f441c8f4393639f/docs/sources/src/main/resources/en-US/images/SCTPInternalArchitecture.odg
--------------------------------------------------------------------------------
/docs/sources/src/main/resources/en-US/images/asn-general-encoding.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RestComm/sctp/ed2cd7458c48cebd63e9aa126f441c8f4393639f/docs/sources/src/main/resources/en-US/images/asn-general-encoding.png
--------------------------------------------------------------------------------
/release/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | pom
5 |
6 |
7 | org.mobicents
8 | restcomm-parent
9 | 2.27.32
10 |
11 |
12 | sctp-release
13 |
14 | 2.22
15 |
16 | Restcomm :: Release :: ${pom.artifactId}
17 |
18 |
19 | release
20 |
21 |
22 |
23 | maven-antrun-plugin
24 | false
25 |
26 |
27 | copy.binary.rel
28 | install
29 |
30 | run
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | clean.rel
48 | clean
49 |
50 | run
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | jboss-snapshots
69 | JBoss Snapshot Repository
70 | http://snapshots.jboss.org/maven2
71 |
72 | false
73 |
74 |
75 | true
76 |
77 |
78 |
79 |
80 | jboss-public-repository-group
81 | JBoss Public Maven Repository Group
82 | https://repository.jboss.org/nexus/content/groups/public/
83 | default
84 |
85 | true
86 | never
87 |
88 |
89 | true
90 | never
91 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/sctp-api/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 |
5 | org.mobicents.protocols.sctp
6 | sctp-parent
7 | 2.0.0-SNAPSHOT
8 |
9 |
10 | sctp-api
11 | Restcomm :: SCTP :: API :: ${pom.artifactId}
12 |
13 |
14 |
15 |
16 | log4j
17 | log4j
18 |
19 |
20 | org.mobicents.commons
21 | commons
22 |
23 |
24 | junit
25 | junit
26 | provided
27 |
28 |
29 |
30 | javolution
31 | javolution
32 | ${javolution.version}
33 |
34 |
35 | io.netty
36 | netty-all
37 | ${netty.version}
38 |
39 |
40 |
41 |
42 |
43 | org.apache.maven.plugins
44 | maven-surefire-plugin
45 | 2.9
46 |
47 | always
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/sctp-api/src/main/java/org/mobicents/protocols/api/Association.java:
--------------------------------------------------------------------------------
1 | /*
2 | * TeleStax, Open Source Cloud Communications Copyright 2012.
3 | * and individual contributors
4 | * by the @authors tag. See the copyright.txt in the distribution for a
5 | * full listing of individual contributors.
6 | *
7 | * This is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU Lesser General Public License as
9 | * published by the Free Software Foundation; either version 2.1 of
10 | * the License, or (at your option) any later version.
11 | *
12 | * This software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public
18 | * License along with this software; if not, write to the Free
19 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 | */
22 |
23 | package org.mobicents.protocols.api;
24 |
25 | import io.netty.buffer.ByteBufAllocator;
26 |
27 |
28 |
29 | /**
30 | *
31 | * A protocol relationship between endpoints
32 | *
33 | *
34 | * The implementation of this interface is actual wrapper over Socket that
35 | * know's how to communicate with peer. The user of Association shouldn't care
36 | * if the underlying Socket is client or server side
37 | *
38 | *
39 | *
40 | *
41 | *
42 | * @author amit bhayani
43 | *
44 | */
45 | public interface Association {
46 |
47 | /**
48 | * Return the Association channel type TCP or SCTP
49 | *
50 | * @return
51 | */
52 | public IpChannelType getIpChannelType();
53 |
54 | /**
55 | * Return the type of Association CLIENT or SERVER
56 | *
57 | * @return
58 | */
59 | public AssociationType getAssociationType();
60 |
61 | /**
62 | * Each association has unique name
63 | *
64 | * @return name of association
65 | */
66 | public String getName();
67 |
68 | /**
69 | * If this association is started by management
70 | *
71 | * @return
72 | */
73 | public boolean isStarted();
74 |
75 | /**
76 | * If this association up (connection is started and established)
77 | *
78 | * @return
79 | */
80 | public boolean isConnected();
81 |
82 | /**
83 | * If this association up (connection is established)
84 | *
85 | * @return
86 | */
87 | public boolean isUp();
88 |
89 | /**
90 | * The AssociationListener set for this Association
91 | *
92 | * @return
93 | */
94 | public AssociationListener getAssociationListener();
95 |
96 | /**
97 | * The {@link AssociationListener} to be registered for this Association
98 | *
99 | * @param associationListener
100 | */
101 | public void setAssociationListener(AssociationListener associationListener);
102 |
103 | /**
104 | * The host address that underlying socket is bound to
105 | *
106 | * @return
107 | */
108 | public String getHostAddress();
109 |
110 | /**
111 | * The host port that underlying socket is bound to
112 | *
113 | * @return
114 | */
115 | public int getHostPort();
116 |
117 | /**
118 | * The peer address that the underlying socket connects to
119 | *
120 | * @return
121 | */
122 | public String getPeerAddress();
123 |
124 | /**
125 | * The peer port that the underlying socket is connected to
126 | *
127 | * @return
128 | */
129 | public int getPeerPort();
130 |
131 | /**
132 | * Server name if the association is for {@link Server}
133 | *
134 | * @return
135 | */
136 | public String getServerName();
137 |
138 | /**
139 | * When SCTP multi-homing configuration extra IP addresses are here
140 | *
141 | * @return
142 | */
143 | public String[] getExtraHostAddresses();
144 |
145 | /**
146 | * Send the {@link PayloadData} to the peer
147 | *
148 | * @param payloadData
149 | * @throws Exception
150 | */
151 | public void send(PayloadData payloadData) throws Exception;
152 |
153 | /**
154 | * Return ByteBufAllocator if the underlying Channel is netty or null if not
155 | *
156 | * @return
157 | */
158 | public ByteBufAllocator getByteBufAllocator() throws Exception;
159 |
160 | /**
161 | * Return the last measured Congestion Level at the sending direction
162 | *
163 | * @return
164 | */
165 | public int getCongestionLevel();
166 |
167 | /**
168 | * Use this method only for accepting anonymous connections
169 | * from the ServerListener.onNewRemoteConnection() invoking
170 | *
171 | * @param associationListener
172 | * @throws Exception
173 | */
174 | public void acceptAnonymousAssociation(AssociationListener associationListener) throws Exception;
175 |
176 | /**
177 | * Use this method only for rejecting anonymous connections
178 | * from the ServerListener.onNewRemoteConnection() invoking
179 | */
180 | public void rejectAnonymousAssociation();
181 |
182 | /**
183 | * Stop the anonymous association. The connection will be closed and we will not reuse this association
184 | * This can be applied only for anonymous association, other associations must be stopped by
185 | * Management.stopAssociation(String assocName)
186 | *
187 | * @throws Exception
188 | */
189 | public void stopAnonymousAssociation() throws Exception;
190 |
191 | }
192 |
--------------------------------------------------------------------------------
/sctp-api/src/main/java/org/mobicents/protocols/api/AssociationListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors as indicated by the @authors tag. All rights reserved.
5 | * See the copyright.txt in the distribution for a full listing
6 | * of individual contributors.
7 | *
8 | * This copyrighted material is made available to anyone wishing to use,
9 | * modify, copy, or redistribute it subject to the terms and conditions
10 | * of the GNU General Public License, v. 2.0.
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License,
18 | * v. 2.0 along with this distribution; if not, write to the Free
19 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 | * MA 02110-1301, USA.
21 | */
22 | package org.mobicents.protocols.api;
23 |
24 | /**
25 | *
26 | * The listener interface for receiving the underlying socket status and
27 | * received payload from peer. The class that is interested in receiving data
28 | * must implement this interface, and the object created with that class is
29 | * registered with {@link Association}
30 | *
31 | *
32 | * @author amit bhayani
33 | *
34 | */
35 | public interface AssociationListener {
36 |
37 | /**
38 | * Invoked when underlying socket is open and connection is established with
39 | * peer. This is expected behavior when management start's the
40 | * {@link Association}
41 | *
42 | * @param association
43 | * @param maxInboundStreams
44 | * Returns the maximum number of inbound streams that this
45 | * association supports. Data received on this association will
46 | * be on stream number s, where 0 <= s < maxInboundStreams(). For
47 | * TCP socket this value is always 1
48 | * @param maxOutboundStreams
49 | * Returns the maximum number of outbound streams that this
50 | * association supports. Data sent on this association must be on
51 | * stream number s, where 0 <= s < maxOutboundStreams(). For TCP
52 | * socket this value is always 1
53 | */
54 | public void onCommunicationUp(Association association, int maxInboundStreams, int maxOutboundStreams);
55 |
56 | /**
57 | * Invoked when underlying socket is shutdown and connection is ended with
58 | * peer. This is expected behavior when management stop's the
59 | * {@link Association}
60 | *
61 | * @param association
62 | */
63 | public void onCommunicationShutdown(Association association);
64 |
65 | /**
66 | * Invoked when underlying socket lost the connection with peer due to any
67 | * reason like network between peer's died etc. This is unexpected behavior
68 | * and the underlying {@link Association} should try to re-establish the
69 | * connection
70 | *
71 | * @param association
72 | */
73 | public void onCommunicationLost(Association association);
74 |
75 | /**
76 | * Invoked when the connection with the peer re-started. This is specific to
77 | * SCTP protocol
78 | *
79 | * @param association
80 | */
81 | public void onCommunicationRestart(Association association);
82 |
83 | /**
84 | * Invoked when the {@link PayloadData} is received from peer
85 | *
86 | * @param association
87 | * @param payloadData
88 | */
89 | public void onPayload(Association association, PayloadData payloadData);
90 |
91 | /**
92 | *
93 | * The stream id set in outgoing {@link PayloadData} is invalid. This packe
94 | * will be dropped after calling the listener.
95 | *
96 | *
97 | * This callback is on same Thread as {@link SelectorThread}. Do not delay
98 | * the process here as it will hold all other IO.
99 | *
100 | *
101 | * @param payloadData
102 | */
103 | public void inValidStreamId(PayloadData payloadData);
104 |
105 | }
106 |
--------------------------------------------------------------------------------
/sctp-api/src/main/java/org/mobicents/protocols/api/AssociationType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors as indicated by the @authors tag. All rights reserved.
5 | * See the copyright.txt in the distribution for a full listing
6 | * of individual contributors.
7 | *
8 | * This copyrighted material is made available to anyone wishing to use,
9 | * modify, copy, or redistribute it subject to the terms and conditions
10 | * of the GNU General Public License, v. 2.0.
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License,
18 | * v. 2.0 along with this distribution; if not, write to the Free
19 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 | * MA 02110-1301, USA.
21 | */
22 | package org.mobicents.protocols.api;
23 |
24 | /**
25 | * @author amit bhayani
26 | *
27 | */
28 | public enum AssociationType {
29 | CLIENT("CLIENT"), SERVER("SERVER"), ANONYMOUS_SERVER("ANONYMOUS_SERVER");
30 |
31 | private final String type;
32 |
33 | private AssociationType(String type) {
34 | this.type = type;
35 | }
36 |
37 | /**
38 | * @return the type
39 | */
40 | public String getType() {
41 | return type;
42 | }
43 |
44 | public static AssociationType getAssociationType(String type) {
45 | if (type == null) {
46 | return null;
47 | } else if (type.equalsIgnoreCase(CLIENT.getType())) {
48 | return CLIENT;
49 | } else if (type.equalsIgnoreCase(SERVER.getType())) {
50 | return SERVER;
51 | } else if (type.equalsIgnoreCase(ANONYMOUS_SERVER.getType())) {
52 | return ANONYMOUS_SERVER;
53 | } else {
54 | return null;
55 | }
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/sctp-api/src/main/java/org/mobicents/protocols/api/CongestionListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * TeleStax, Open Source Cloud Communications Copyright 2012.
3 | * and individual contributors
4 | * by the @authors tag. See the copyright.txt in the distribution for a
5 | * full listing of individual contributors.
6 | *
7 | * This is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU Lesser General Public License as
9 | * published by the Free Software Foundation; either version 2.1 of
10 | * the License, or (at your option) any later version.
11 | *
12 | * This software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public
18 | * License along with this software; if not, write to the Free
19 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 | */
22 |
23 | package org.mobicents.protocols.api;
24 |
25 | /**
26 | *
27 | * @author sergey vetyutnev
28 | *
29 | */
30 | public interface CongestionListener {
31 |
32 | public void onCongLevelChanged(Association association, int oldCongLevel, int newCongLevel);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/sctp-api/src/main/java/org/mobicents/protocols/api/IpChannelType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors as indicated by the @authors tag. All rights reserved.
5 | * See the copyright.txt in the distribution for a full listing
6 | * of individual contributors.
7 | *
8 | * This copyrighted material is made available to anyone wishing to use,
9 | * modify, copy, or redistribute it subject to the terms and conditions
10 | * of the GNU General Public License, v. 2.0.
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License,
18 | * v. 2.0 along with this distribution; if not, write to the Free
19 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 | * MA 02110-1301, USA.
21 | */
22 |
23 | package org.mobicents.protocols.api;
24 |
25 | /**
26 | * @author amit bhayani
27 | * @author sergey vetyutnev
28 | *
29 | */
30 | public enum IpChannelType {
31 | SCTP(0, "SCTP"), TCP(1, "TCP");
32 |
33 | int code;
34 | String type;
35 |
36 | private IpChannelType(int code, String type) {
37 | this.code = code;
38 | this.type = type;
39 |
40 | }
41 |
42 | public int getCode() {
43 | return this.code;
44 | }
45 |
46 | public String getType() {
47 | return type;
48 | }
49 |
50 | public static IpChannelType getInstance(int code) {
51 | switch (code) {
52 | case 0:
53 | return IpChannelType.SCTP;
54 | case 1:
55 | return IpChannelType.TCP;
56 | }
57 |
58 | return null;
59 | }
60 |
61 | public static IpChannelType getInstance(String type) {
62 | if (type.equalsIgnoreCase("SCTP")) {
63 | return SCTP;
64 | } else if (type.equalsIgnoreCase("TCP")) {
65 | return TCP;
66 | }
67 |
68 | return null;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/sctp-api/src/main/java/org/mobicents/protocols/api/ManagementEventListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * TeleStax, Open Source Cloud Communications Copyright 2012.
3 | * and individual contributors
4 | * by the @authors tag. See the copyright.txt in the distribution for a
5 | * full listing of individual contributors.
6 | *
7 | * This is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU Lesser General Public License as
9 | * published by the Free Software Foundation; either version 2.1 of
10 | * the License, or (at your option) any later version.
11 | *
12 | * This software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public
18 | * License along with this software; if not, write to the Free
19 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 | */
22 |
23 | package org.mobicents.protocols.api;
24 |
25 | /**
26 | *
27 | * @author sergey vetyutnev
28 | *
29 | */
30 | public interface ManagementEventListener {
31 |
32 | public void onServiceStarted();
33 |
34 | public void onServiceStopped();
35 |
36 | public void onRemoveAllResources();
37 |
38 | public void onServerAdded(Server server);
39 |
40 | public void onServerRemoved(Server serverName);
41 |
42 | public void onAssociationAdded(Association association);
43 |
44 | public void onAssociationRemoved(Association association);
45 |
46 | public void onAssociationStarted(Association association);
47 |
48 | public void onAssociationStopped(Association association);
49 |
50 | public void onAssociationUp(Association association);
51 |
52 | public void onAssociationDown(Association association);
53 |
54 | public void onServerModified(Server removeServer);
55 |
56 | public void onAssociationModified(Association association);
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/sctp-api/src/main/java/org/mobicents/protocols/api/PayloadData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * TeleStax, Open Source Cloud Communications
3 | * Copyright 2011-2014, Telestax Inc and individual contributors
4 | * by the @authors tag.
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * under the terms of the GNU Affero General Public License as
8 | * published by the Free Software Foundation; either version 3 of
9 | * the License, or (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Affero General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Affero General Public License
17 | * along with this program. If not, see
18 | *
19 | */
20 |
21 | package org.mobicents.protocols.api;
22 |
23 | import io.netty.buffer.ByteBuf;
24 | import io.netty.buffer.Unpooled;
25 | import io.netty.util.ReferenceCountUtil;
26 |
27 | import org.mobicents.commons.HexTools;
28 |
29 | /**
30 | * The actual pay load data received or to be sent from/to underlying socket
31 | *
32 | * @author amit bhayani
33 | *
34 | */
35 | public class PayloadData {
36 | private final int dataLength;
37 | private final ByteBuf byteBuf;
38 | private final boolean complete;
39 | private final boolean unordered;
40 | private final int payloadProtocolId;
41 | private final int streamNumber;
42 |
43 | /**
44 | * @param dataLength
45 | * Length of byte[] data
46 | * @param byteBuf
47 | * the payload data
48 | * @param complete
49 | * if this data represents complete protocol data
50 | * @param unordered
51 | * set to true if we don't care for oder
52 | * @param payloadProtocolId
53 | * protocol ID of the data carried
54 | * @param streamNumber
55 | * the SCTP stream number
56 | */
57 | public PayloadData(int dataLength, ByteBuf byteBuf, boolean complete, boolean unordered, int payloadProtocolId, int streamNumber) {
58 | super();
59 | this.dataLength = dataLength;
60 | this.byteBuf = byteBuf;
61 | this.complete = complete;
62 | this.unordered = unordered;
63 | this.payloadProtocolId = payloadProtocolId;
64 | this.streamNumber = streamNumber;
65 | }
66 |
67 | /**
68 | * @param dataLength
69 | * Length of byte[] data
70 | * @param data
71 | * the payload data
72 | * @param complete
73 | * if this data represents complete protocol data
74 | * @param unordered
75 | * set to true if we don't care for oder
76 | * @param payloadProtocolId
77 | * protocol ID of the data carried
78 | * @param streamNumber
79 | * the SCTP stream number
80 | */
81 | public PayloadData(int dataLength, byte[] data, boolean complete, boolean unordered, int payloadProtocolId, int streamNumber) {
82 | super();
83 | this.dataLength = dataLength;
84 | this.byteBuf = Unpooled.wrappedBuffer(data);
85 | this.complete = complete;
86 | this.unordered = unordered;
87 | this.payloadProtocolId = payloadProtocolId;
88 | this.streamNumber = streamNumber;
89 | }
90 |
91 | /**
92 | * @return the dataLength
93 | */
94 | public int getDataLength() {
95 | return dataLength;
96 | }
97 |
98 | /**
99 | * @return the byteBuf
100 | */
101 | public ByteBuf getByteBuf() {
102 | return byteBuf;
103 | }
104 |
105 | /**
106 | * @return the data
107 | */
108 | public byte[] getData() {
109 | byte[] array = new byte[byteBuf.readableBytes()];
110 | byteBuf.getBytes(0, array);
111 | ReferenceCountUtil.release(byteBuf);
112 | return array;
113 | }
114 |
115 | public void releaseBuffer() {
116 | ReferenceCountUtil.release(byteBuf);
117 | }
118 |
119 | /**
120 | * @return the complete
121 | */
122 | public boolean isComplete() {
123 | return complete;
124 | }
125 |
126 | /**
127 | * @return the unordered
128 | */
129 | public boolean isUnordered() {
130 | return unordered;
131 | }
132 |
133 | /**
134 | * @return the payloadProtocolId
135 | */
136 | public int getPayloadProtocolId() {
137 | return payloadProtocolId;
138 | }
139 |
140 | /**
141 | *
142 | * This is SCTP Stream sequence identifier.
143 | *
144 | *
145 | * While sending PayloadData to SCTP Association, this value should be set
146 | * by SCTP user. If value greater than or equal to maxOutboundStreams or
147 | * lesser than 0 is used, packet will be dropped and error message will be
148 | * logged
149 | *
150 | * While PayloadData is received from underlying SCTP socket, this
151 | * value indicates stream identifier on which data was received. Its
152 | * guaranteed that this value will be greater than 0 and less than
153 | * maxInboundStreams
154 | *
155 | *
156 | * @return the streamNumber
157 | */
158 | public int getStreamNumber() {
159 | return streamNumber;
160 | }
161 |
162 | /*
163 | * (non-Javadoc)
164 | *
165 | * @see java.lang.Object#toString()
166 | */
167 | @Override
168 | public String toString() {
169 | byte[] array = new byte[byteBuf.readableBytes()];
170 | byteBuf.getBytes(0, array);
171 |
172 | StringBuffer sb = new StringBuffer();
173 | sb.append("PayloadData [dataLength=").append(dataLength).append(", complete=").append(complete).append(", unordered=")
174 | .append(unordered).append(", payloadProtocolId=").append(payloadProtocolId).append(", streamNumber=")
175 | .append(streamNumber).append(", data=\n").append(HexTools.dump(array, 0)).append("]");
176 | return sb.toString();
177 | }
178 |
179 | }
180 |
--------------------------------------------------------------------------------
/sctp-api/src/main/java/org/mobicents/protocols/api/Server.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors as indicated by the @authors tag. All rights reserved.
5 | * See the copyright.txt in the distribution for a full listing
6 | * of individual contributors.
7 | *
8 | * This copyrighted material is made available to anyone wishing to use,
9 | * modify, copy, or redistribute it subject to the terms and conditions
10 | * of the GNU General Public License, v. 2.0.
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License,
18 | * v. 2.0 along with this distribution; if not, write to the Free
19 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 | * MA 02110-1301, USA.
21 | */
22 | package org.mobicents.protocols.api;
23 |
24 | import java.util.List;
25 |
26 | /**
27 | * A wrapper over actual server side Socket
28 | *
29 | * @author amit bhayani
30 | *
31 | */
32 | public interface Server {
33 |
34 | /**
35 | * Get the Server channel type - TCP or SCTP
36 | *
37 | * @return
38 | */
39 | public IpChannelType getIpChannelType();
40 |
41 | /**
42 | * Return if this Server accepts Anonymous connections
43 | *
44 | * @return
45 | */
46 | public boolean isAcceptAnonymousConnections();
47 |
48 | /**
49 | * Return the count of concurrent connections that can accept a Server. 0 means an unlimited count.
50 | *
51 | * @return
52 | */
53 | public int getMaxConcurrentConnectionsCount();
54 |
55 | /**
56 | * Set the count of concurrent connections that can accept a Server. 0 means an unlimited count.
57 | *
58 | * @return
59 | */
60 | public void setMaxConcurrentConnectionsCount(int val);
61 |
62 | /**
63 | * Get name of this Server. Should be unique in a management instance
64 | *
65 | * @return
66 | */
67 | public String getName();
68 |
69 | /**
70 | * The host address that this server socket is bound to
71 | *
72 | * @return
73 | */
74 | public String getHostAddress();
75 |
76 | /**
77 | * The host port that this server socket is bound to
78 | *
79 | * @return
80 | */
81 | public int getHostport();
82 |
83 | /**
84 | * When SCTP multi-homing configuration extra IP addresses are here
85 | *
86 | * @return
87 | */
88 | public String[] getExtraHostAddresses();
89 |
90 | /**
91 | * If the server is started
92 | *
93 | * @return
94 | */
95 | public boolean isStarted();
96 |
97 | /**
98 | * {@link Association} configured for this Server
99 | * Anonymous associations are not present in this list
100 | *
101 | * @return
102 | */
103 | public List getAssociations();
104 |
105 | /**
106 | * Returns an unmodifiable list of anonymous associations that are connected at the moment
107 | * @return
108 | */
109 | public List getAnonymAssociations();
110 |
111 | }
112 |
--------------------------------------------------------------------------------
/sctp-api/src/main/java/org/mobicents/protocols/api/ServerListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * TeleStax, Open Source Cloud Communications Copyright 2012.
3 | * and individual contributors
4 | * by the @authors tag. See the copyright.txt in the distribution for a
5 | * full listing of individual contributors.
6 | *
7 | * This is free software; you can redistribute it and/or modify it
8 | * under the terms of the GNU Lesser General Public License as
9 | * published by the Free Software Foundation; either version 2.1 of
10 | * the License, or (at your option) any later version.
11 | *
12 | * This software is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * Lesser General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU Lesser General Public
18 | * License along with this software; if not, write to the Free
19 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 | */
22 |
23 | package org.mobicents.protocols.api;
24 |
25 | /**
26 | *
27 | * @author sergey vetyutnev
28 | *
29 | */
30 | public interface ServerListener {
31 |
32 | public void onNewRemoteConnection(Server server, Association association);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/sctp-impl/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 |
5 | org.mobicents.protocols.sctp
6 | sctp-parent
7 | 2.0.0-SNAPSHOT
8 |
9 |
10 | sctp-impl
11 | Restcomm :: SCTP :: Impl :: ${pom.artifactId}
12 |
13 |
14 |
15 |
16 | log4j
17 | log4j
18 |
19 |
20 |
21 | javolution
22 | javolution
23 | ${javolution.version}
24 |
25 |
26 | ${pom.groupId}
27 | sctp-api
28 | ${pom.version}
29 |
30 |
31 | org.testng
32 | testng
33 | ${testng.version}
34 |
35 |
36 | junit
37 | junit
38 | ${junit.version}
39 | provided
40 |
41 |
42 | io.netty
43 | netty-all
44 | ${netty.version}
45 |
46 |
47 |
48 |
49 |
50 | org.apache.maven.plugins
51 | maven-surefire-plugin
52 | 2.9
53 |
54 |
55 | testng-methods.xml
56 | testng-classes.xml
57 |
58 |
59 |
60 |
61 | maven-clean-plugin
62 |
63 |
64 |
65 | .
66 |
67 | *_sctp.xml
68 | sctptest.log
69 |
70 |
72 | false
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/AssociationHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors as indicated by the @authors tag. All rights reserved.
5 | * See the copyright.txt in the distribution for a full listing
6 | * of individual contributors.
7 | *
8 | * This copyrighted material is made available to anyone wishing to use,
9 | * modify, copy, or redistribute it subject to the terms and conditions
10 | * of the GNU General Public License, v. 2.0.
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License,
18 | * v. 2.0 along with this distribution; if not, write to the Free
19 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 | * MA 02110-1301, USA.
21 | */
22 | package org.mobicents.protocols.sctp;
23 |
24 | import org.apache.log4j.Logger;
25 | import org.apache.log4j.Priority;
26 |
27 | import com.sun.nio.sctp.AbstractNotificationHandler;
28 | import com.sun.nio.sctp.AssociationChangeNotification;
29 | import com.sun.nio.sctp.HandlerResult;
30 | import com.sun.nio.sctp.PeerAddressChangeNotification;
31 | import com.sun.nio.sctp.SendFailedNotification;
32 | import com.sun.nio.sctp.ShutdownNotification;
33 |
34 | /**
35 | * // TODO Override all methods? // TODO Add Association name for logging
36 | *
37 | * @author amit bhayani
38 | *
39 | */
40 | class AssociationHandler extends AbstractNotificationHandler {
41 |
42 | private static final Logger logger = Logger.getLogger(AssociationHandler.class);
43 |
44 | //Default value is 1 for TCP
45 | private volatile int maxInboundStreams = 1;
46 | private volatile int maxOutboundStreams = 1;
47 |
48 | /**
49 | * @param asscoitaion
50 | */
51 | public AssociationHandler() {
52 |
53 | }
54 |
55 | /**
56 | * @return the maxInboundStreams
57 | */
58 | public int getMaxInboundStreams() {
59 | return maxInboundStreams;
60 | }
61 |
62 | /**
63 | * @return the maxOutboundStreams
64 | */
65 | public int getMaxOutboundStreams() {
66 | return maxOutboundStreams;
67 | }
68 |
69 | @Override
70 | public HandlerResult handleNotification(AssociationChangeNotification not, AssociationImpl associtaion) {
71 | switch (not.event()) {
72 | case COMM_UP:
73 | if (not.association() != null) {
74 | this.maxOutboundStreams = not.association().maxOutboundStreams();
75 | this.maxInboundStreams = not.association().maxInboundStreams();
76 | }
77 |
78 | if (logger.isInfoEnabled()) {
79 | logger.info(String.format("New association setup for Association=%s with %d outbound streams, and %d inbound streams.\n",
80 | associtaion.getName(), this.maxOutboundStreams, this.maxInboundStreams));
81 | }
82 |
83 | associtaion.createworkerThreadTable(Math.max(this.maxInboundStreams, this.maxOutboundStreams));
84 |
85 | // TODO assign Thread's ?
86 | try {
87 | associtaion.markAssociationUp();
88 | associtaion.getAssociationListener().onCommunicationUp(associtaion, this.maxInboundStreams, this.maxOutboundStreams);
89 | } catch (Exception e) {
90 | logger.error(String.format("Exception while calling onCommunicationUp on AssociationListener for Association=%s", associtaion.getName()), e);
91 | }
92 | return HandlerResult.CONTINUE;
93 |
94 | case CANT_START:
95 | logger.error(String.format("Can't start for Association=%s", associtaion.getName()));
96 | return HandlerResult.CONTINUE;
97 | case COMM_LOST:
98 | logger.warn(String.format("Communication lost for Association=%s", associtaion.getName()));
99 |
100 | // Close the Socket
101 | associtaion.close();
102 |
103 | associtaion.scheduleConnect();
104 | try {
105 | associtaion.markAssociationDown();
106 | associtaion.getAssociationListener().onCommunicationLost(associtaion);
107 | } catch (Exception e) {
108 | logger.error(String.format("Exception while calling onCommunicationLost on AssociationListener for Association=%s", associtaion.getName()), e);
109 | }
110 | return HandlerResult.RETURN;
111 | case RESTART:
112 | logger.warn(String.format("Restart for Association=%s", associtaion.getName()));
113 | try {
114 | associtaion.getAssociationListener().onCommunicationRestart(associtaion);
115 | } catch (Exception e) {
116 | logger.error(String.format("Exception while calling onCommunicationRestart on AssociationListener for Association=%s", associtaion.getName()),
117 | e);
118 | }
119 | return HandlerResult.CONTINUE;
120 | case SHUTDOWN:
121 | if (logger.isInfoEnabled()) {
122 | logger.info(String.format("Shutdown for Association=%s", associtaion.getName()));
123 | }
124 | try {
125 | associtaion.markAssociationDown();
126 | associtaion.getAssociationListener().onCommunicationShutdown(associtaion);
127 | } catch (Exception e) {
128 | logger.error(String.format("Exception while calling onCommunicationShutdown on AssociationListener for Association=%s", associtaion.getName()),
129 | e);
130 | }
131 | return HandlerResult.RETURN;
132 | default:
133 | logger.warn(String.format("Received unkown Event=%s for Association=%s", not.event(), associtaion.getName()));
134 | break;
135 | }
136 |
137 | return HandlerResult.CONTINUE;
138 | }
139 |
140 | @Override
141 | public HandlerResult handleNotification(ShutdownNotification not, AssociationImpl associtaion) {
142 | if (logger.isInfoEnabled()) {
143 | logger.info(String.format("Association=%s SHUTDOWN", associtaion.getName()));
144 | }
145 |
146 | // TODO assign Thread's ?
147 |
148 | try {
149 | associtaion.markAssociationDown();
150 | associtaion.getAssociationListener().onCommunicationShutdown(associtaion);
151 | } catch (Exception e) {
152 | logger.error(String.format("Exception while calling onCommunicationShutdown on AssociationListener for Association=%s", associtaion.getName()), e);
153 | }
154 |
155 | return HandlerResult.RETURN;
156 | }
157 |
158 | @Override
159 | public HandlerResult handleNotification(SendFailedNotification notification, AssociationImpl associtaion) {
160 | // logger.error(String.format("Association=%s SendFailedNotification", associtaion.getName()));
161 | logger.error(String.format("Association=" + associtaion.getName() + " SendFailedNotification, errorCode=" + notification.errorCode()));
162 | return HandlerResult.RETURN;
163 | }
164 |
165 | @Override
166 | public HandlerResult handleNotification(PeerAddressChangeNotification notification, AssociationImpl associtaion) {
167 | //associtaion.peerSocketAddress = notification.address();
168 | if(logger.isEnabledFor(Priority.WARN)){
169 | logger.warn(String.format("Peer Address changed to=%s for Association=%s", notification.address(), associtaion.getName()));
170 | }
171 | return HandlerResult.CONTINUE;
172 | }
173 | }
174 |
--------------------------------------------------------------------------------
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/AssociationMap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors as indicated by the @authors tag. All rights reserved.
5 | * See the copyright.txt in the distribution for a full listing
6 | * of individual contributors.
7 | *
8 | * This copyrighted material is made available to anyone wishing to use,
9 | * modify, copy, or redistribute it subject to the terms and conditions
10 | * of the GNU General Public License, v. 2.0.
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License,
18 | * v. 2.0 along with this distribution; if not, write to the Free
19 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 | * MA 02110-1301, USA.
21 | */
22 | package org.mobicents.protocols.sctp;
23 |
24 | import javolution.util.FastMap;
25 |
26 | /**
27 | * @author amit bhayani
28 | *
29 | */
30 | public class AssociationMap extends FastMap {
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/ChangeRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors as indicated by the @authors tag. All rights reserved.
5 | * See the copyright.txt in the distribution for a full listing
6 | * of individual contributors.
7 | *
8 | * This copyrighted material is made available to anyone wishing to use,
9 | * modify, copy, or redistribute it subject to the terms and conditions
10 | * of the GNU General Public License, v. 2.0.
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License,
18 | * v. 2.0 along with this distribution; if not, write to the Free
19 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 | * MA 02110-1301, USA.
21 | */
22 | package org.mobicents.protocols.sctp;
23 |
24 | import java.nio.channels.spi.AbstractSelectableChannel;
25 |
26 | /**
27 | * @author amit bhayani
28 | *
29 | */
30 | public final class ChangeRequest {
31 | public static final int REGISTER = 1;
32 | public static final int CHANGEOPS = 2;
33 | public static final int CONNECT = 3;
34 | public static final int CLOSE = 4;
35 |
36 | private int type;
37 | private int ops;
38 | private AbstractSelectableChannel socketChannel;
39 | private AssociationImpl association;
40 |
41 | private long executionTime;
42 |
43 | protected ChangeRequest(AbstractSelectableChannel socketChannel, AssociationImpl association, int type, int ops) {
44 | this.type = type;
45 | this.ops = ops;
46 | this.socketChannel = socketChannel;
47 | this.association = association;
48 | }
49 |
50 | protected ChangeRequest(AssociationImpl association, int type, long executionTime) {
51 | this(null, association, type, -1);
52 | this.executionTime = executionTime;
53 | }
54 |
55 | /**
56 | * @return the type
57 | */
58 | protected int getType() {
59 | return type;
60 | }
61 |
62 | /**
63 | * @return the ops
64 | */
65 | protected int getOps() {
66 | return ops;
67 | }
68 |
69 | /**
70 | * @return the socketChannel
71 | */
72 | protected AbstractSelectableChannel getSocketChannel() {
73 | return socketChannel;
74 | }
75 |
76 | /**
77 | * @return the association
78 | */
79 | protected AssociationImpl getAssociation() {
80 | return association;
81 | }
82 |
83 | /**
84 | * @return the executionTime
85 | */
86 | protected long getExecutionTime() {
87 | return executionTime;
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/NonPersistentManagementImpl.java:
--------------------------------------------------------------------------------
1 | package org.mobicents.protocols.sctp;
2 |
3 | import java.io.IOException;
4 |
5 | public class NonPersistentManagementImpl extends ManagementImpl {
6 |
7 | public NonPersistentManagementImpl(String name) throws IOException {
8 | super(name);
9 | }
10 |
11 | @Override
12 | public void load() {
13 |
14 | }
15 |
16 | @Override
17 | public void store() {
18 |
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/SctpXMLBinding.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors as indicated by the @authors tag. All rights reserved.
5 | * See the copyright.txt in the distribution for a full listing
6 | * of individual contributors.
7 | *
8 | * This copyrighted material is made available to anyone wishing to use,
9 | * modify, copy, or redistribute it subject to the terms and conditions
10 | * of the GNU General Public License, v. 2.0.
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License,
18 | * v. 2.0 along with this distribution; if not, write to the Free
19 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 | * MA 02110-1301, USA.
21 | */
22 | package org.mobicents.protocols.sctp;
23 |
24 | import java.util.Iterator;
25 | import java.util.Map;
26 |
27 | import javolution.xml.XMLBinding;
28 | import javolution.xml.XMLFormat;
29 | import javolution.xml.stream.XMLStreamException;
30 |
31 | /**
32 | * @author amit bhayani
33 | *
34 | */
35 | public class SctpXMLBinding extends XMLBinding {
36 |
37 | protected static final XMLFormat ASSOCIATION_MAP = new XMLFormat(AssociationMap.class) {
38 |
39 | @Override
40 | public void write(AssociationMap obj, javolution.xml.XMLFormat.OutputElement xml) throws XMLStreamException {
41 | final Map map = (Map) obj;
42 |
43 | for (Iterator it = map.entrySet().iterator(); it.hasNext();) {
44 | Map.Entry entry = (Map.Entry) it.next();
45 |
46 | xml.add((String) entry.getKey(), "name", String.class);
47 | xml.add((AssociationImpl) entry.getValue(), "association", AssociationImpl.class);
48 | }
49 | }
50 |
51 | @Override
52 | public void read(javolution.xml.XMLFormat.InputElement xml, AssociationMap obj) throws XMLStreamException {
53 | while (xml.hasNext()) {
54 | String key = xml.get("name", String.class);
55 | AssociationImpl association = xml.get("association", AssociationImpl.class);
56 | obj.put(key, association);
57 | }
58 | }
59 |
60 | };
61 |
62 | protected XMLFormat getFormat(Class forClass) throws XMLStreamException {
63 | if (AssociationMap.class.equals(forClass)) {
64 | return ASSOCIATION_MAP;
65 | }
66 | return super.getFormat(forClass);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/Worker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors as indicated by the @authors tag. All rights reserved.
5 | * See the copyright.txt in the distribution for a full listing
6 | * of individual contributors.
7 | *
8 | * This copyrighted material is made available to anyone wishing to use,
9 | * modify, copy, or redistribute it subject to the terms and conditions
10 | * of the GNU General Public License, v. 2.0.
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License,
18 | * v. 2.0 along with this distribution; if not, write to the Free
19 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 | * MA 02110-1301, USA.
21 | */
22 | package org.mobicents.protocols.sctp;
23 |
24 | import org.mobicents.protocols.api.AssociationListener;
25 | import org.mobicents.protocols.api.PayloadData;
26 |
27 | /**
28 | * @author amit bhayani
29 | *
30 | */
31 | public class Worker implements Runnable {
32 |
33 | private AssociationImpl association;
34 | private AssociationListener associationListener = null;
35 | private PayloadData payloadData = null;
36 |
37 | /**
38 | * @param association
39 | * @param associationListener
40 | * @param payloadData
41 | */
42 | protected Worker(AssociationImpl association, AssociationListener associationListener, PayloadData payloadData) {
43 | super();
44 | this.association = association;
45 | this.associationListener = associationListener;
46 | this.payloadData = payloadData;
47 | }
48 |
49 | /*
50 | * (non-Javadoc)
51 | *
52 | * @see java.lang.Runnable#run()
53 | */
54 | @Override
55 | public void run() {
56 | try {
57 | this.associationListener.onPayload(this.association, this.payloadData);
58 | } catch (Exception e) {
59 | e.printStackTrace();
60 | }
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/netty/NettyAssociationMap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * JBoss, Home of Professional Open Source
3 | * Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual
4 | * contributors as indicated by the @authors tag. All rights reserved.
5 | * See the copyright.txt in the distribution for a full listing
6 | * of individual contributors.
7 | *
8 | * This copyrighted material is made available to anyone wishing to use,
9 | * modify, copy, or redistribute it subject to the terms and conditions
10 | * of the GNU General Public License, v. 2.0.
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | * General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License,
18 | * v. 2.0 along with this distribution; if not, write to the Free
19 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 | * MA 02110-1301, USA.
21 | */
22 |
23 | package org.mobicents.protocols.sctp.netty;
24 |
25 | import javolution.util.FastMap;
26 |
27 | /**
28 | * @author amit bhayani
29 | *
30 | */
31 | public class NettyAssociationMap extends FastMap {
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/netty/NettySctpClientChannelInitializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * TeleStax, Open Source Cloud Communications
3 | * Copyright 2011-2014, Telestax Inc and individual contributors
4 | * by the @authors tag.
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * under the terms of the GNU Affero General Public License as
8 | * published by the Free Software Foundation; either version 3 of
9 | * the License, or (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Affero General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Affero General Public License
17 | * along with this program. If not, see
18 | *
19 | */
20 |
21 | package org.mobicents.protocols.sctp.netty;
22 |
23 | import io.netty.channel.ChannelInitializer;
24 | import io.netty.channel.sctp.SctpChannel;
25 | import io.netty.handler.codec.sctp.SctpMessageCompletionHandler;
26 |
27 | /**
28 | * @author Amit Bhayani
29 | *
30 | */
31 | public class NettySctpClientChannelInitializer extends ChannelInitializer {
32 |
33 | private final NettyAssociationImpl nettyAssociationImpl;
34 |
35 | /**
36 | * @param nettyAssociationImpl
37 | */
38 | public NettySctpClientChannelInitializer(NettyAssociationImpl nettyAssociationImpl) {
39 | super();
40 | this.nettyAssociationImpl = nettyAssociationImpl;
41 | }
42 |
43 | @Override
44 | protected void initChannel(SctpChannel ch) throws Exception {
45 | ch.pipeline().addLast(new SctpMessageCompletionHandler(), new NettySctpClientHandler(this.nettyAssociationImpl));
46 |
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/netty/NettySctpClientHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * TeleStax, Open Source Cloud Communications
3 | * Copyright 2011-2014, Telestax Inc and individual contributors
4 | * by the @authors tag.
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * under the terms of the GNU Affero General Public License as
8 | * published by the Free Software Foundation; either version 3 of
9 | * the License, or (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Affero General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Affero General Public License
17 | * along with this program. If not, see
18 | *
19 | */
20 |
21 | package org.mobicents.protocols.sctp.netty;
22 |
23 | import io.netty.channel.ChannelHandlerContext;
24 |
25 | import java.net.InetSocketAddress;
26 |
27 | import org.apache.log4j.Logger;
28 | import org.mobicents.protocols.api.IpChannelType;
29 |
30 | /**
31 | * Handler implementation for the SCTP echo client. It initiates the ping-pong traffic between the echo client and server by
32 | * sending the first message to the server.
33 | *
34 | * @author Amit Bhayani
35 | *
36 | */
37 | public class NettySctpClientHandler extends NettySctpChannelInboundHandlerAdapter {
38 |
39 | private final Logger logger = Logger.getLogger(NettySctpClientHandler.class);
40 |
41 | /**
42 | * Creates a client-side handler.
43 | */
44 | public NettySctpClientHandler(NettyAssociationImpl nettyAssociationImpl) {
45 | this.association = nettyAssociationImpl;
46 | }
47 |
48 | @Override
49 | public void channelUnregistered(final ChannelHandlerContext ctx) throws Exception {
50 | logger.warn(String.format("ChannelUnregistered event: association=%s", association));
51 | this.association.setChannelHandler(null);
52 |
53 | this.association.scheduleConnect();
54 | }
55 |
56 | @Override
57 | public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
58 | if (logger.isDebugEnabled()) {
59 | logger.debug(String.format("channelRegistered event: association=%s", this.association));
60 | }
61 | }
62 |
63 | @Override
64 | public void channelActive(ChannelHandlerContext ctx) {
65 | if (logger.isDebugEnabled()) {
66 | logger.debug(String.format("channelActive event: association=%s", this.association));
67 | }
68 |
69 | this.ctx = ctx;
70 | this.channel = ctx.channel();
71 | this.association.setChannelHandler(this);
72 |
73 | String host = null;
74 | int port = 0;
75 | InetSocketAddress sockAdd = ((InetSocketAddress) channel.remoteAddress());
76 | if (sockAdd != null) {
77 | host = sockAdd.getAddress().getHostAddress();
78 | port = sockAdd.getPort();
79 | }
80 |
81 | if (logger.isInfoEnabled()) {
82 | logger.info(String.format("Association=%s connected to host=%s port=%d", association.getName(), host, port));
83 | }
84 |
85 | if (association.getIpChannelType() == IpChannelType.TCP) {
86 | this.association.markAssociationUp(1, 1);
87 | }
88 | }
89 |
90 | @Override
91 | public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
92 | // Close the connection when an exception is raised.
93 | logger.error("ExceptionCaught for Associtaion: " + this.association.getName() + "\n", cause);
94 | ctx.close();
95 |
96 | // this.association.scheduleConnect();
97 | }
98 |
99 | // byte [] m3uaMessage = new byte
100 | // []{1,0,3,1,0,0,0,24,0,17,0,8,0,0,0,1,0,4,0,8,84,101,115,116};
101 | // byte[] m3uaMessage = new byte[] { 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, (byte) 0x9c, 0x02, 0x00, 0x00, 0x08, 0x00,
102 | // 0x00, 0x00, 0x66, 0x00, 0x06, 0x00, 0x08, 0x00, 0x00, 0x00, 0x65, 0x02, 0x10, 0x00, (byte) 0x81, 0x00, 0x00, 0x00,
103 | // 0x02, 0x00, 0x00, 0x00, 0x01, 0x03, 0x02, 0x00, 0x01, 0x09, 0x01, 0x03, 0x07, 0x0b, 0x04, 0x43, 0x01, 0x00, 0x08,
104 | // 0x04, 0x43, 0x02, 0x00, 0x08, 0x61, 0x62, 0x5f, 0x48, 0x04, 0x00, 0x00, 0x00, 0x01, 0x6b, 0x39, 0x28, 0x37, 0x06,
105 | // 0x07, 0x00, 0x11, (byte) 0x86, 0x05, 0x01, 0x01, 0x01, (byte) 0xa0, 0x2c, 0x60, 0x2a, (byte) 0x80, 0x02, 0x07,
106 | // (byte) 0x80, (byte) 0xa1, 0x09, 0x06, 0x07, 0x04, 0x00, 0x00, 0x01, 0x00, 0x13, 0x02, (byte) 0xbe, 0x19, 0x28,
107 | // 0x17, 0x06, 0x07, 0x04, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, (byte) 0xa0, 0x0c, (byte) 0xa0, 0x0a, (byte) 0x80,
108 | // 0x03, (byte) 0x91, 0x22, (byte) 0xf2, (byte) 0x81, 0x03, (byte) 0x91, 0x11, (byte) 0xf1, 0x6c, 0x1c, (byte) 0xa1,
109 | // 0x1a, 0x02, 0x01, 0x01, 0x02, 0x01, 0x3b, 0x30, 0x12, 0x04, 0x01, 0x0f, 0x04, 0x05, (byte) 0xaa, 0x5a, 0x2c, 0x37,
110 | // 0x02, (byte) 0x80, 0x06, (byte) 0x91, (byte) 0x99, 0x06, 0x36, (byte) 0x99, 0x10, 0x00, 0x00, 0x00 };
111 | // ByteBuf firstMessage = Unpooled.buffer(m3uaMessage.length).writeBytes(m3uaMessage);
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/netty/NettySctpServerChannelInitializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * TeleStax, Open Source Cloud Communications
3 | * Copyright 2011-2014, Telestax Inc and individual contributors
4 | * by the @authors tag.
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * under the terms of the GNU Affero General Public License as
8 | * published by the Free Software Foundation; either version 3 of
9 | * the License, or (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Affero General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Affero General Public License
17 | * along with this program. If not, see
18 | *
19 | */
20 |
21 | package org.mobicents.protocols.sctp.netty;
22 |
23 | import io.netty.channel.ChannelInitializer;
24 | import io.netty.channel.sctp.SctpChannel;
25 | import io.netty.handler.codec.sctp.SctpMessageCompletionHandler;
26 |
27 | /**
28 | * @author Amit Bhayani
29 | *
30 | */
31 | public class NettySctpServerChannelInitializer extends ChannelInitializer {
32 | private final NettyServerImpl nettyServerImpl;
33 | private final NettySctpManagementImpl sctpManagementImpl;
34 |
35 | protected NettySctpServerChannelInitializer(NettyServerImpl nettyServerImpl, NettySctpManagementImpl sctpManagementImpl) {
36 | super();
37 | this.nettyServerImpl = nettyServerImpl;
38 | this.sctpManagementImpl = sctpManagementImpl;
39 | }
40 |
41 | @Override
42 | protected void initChannel(SctpChannel ch) throws Exception {
43 | ch.pipeline().addLast(new SctpMessageCompletionHandler(),
44 | new NettySctpServerHandler(this.nettyServerImpl, this.sctpManagementImpl));
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/netty/NettySctpServerHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * TeleStax, Open Source Cloud Communications
3 | * Copyright 2011-2014, Telestax Inc and individual contributors
4 | * by the @authors tag.
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * under the terms of the GNU Affero General Public License as
8 | * published by the Free Software Foundation; either version 3 of
9 | * the License, or (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Affero General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Affero General Public License
17 | * along with this program. If not, see
18 | *
19 | */
20 |
21 | package org.mobicents.protocols.sctp.netty;
22 |
23 | import io.netty.channel.Channel;
24 | import io.netty.channel.ChannelHandlerContext;
25 |
26 | import java.net.InetSocketAddress;
27 |
28 | import javolution.util.FastMap;
29 |
30 | import org.apache.log4j.Logger;
31 | import org.mobicents.protocols.api.Association;
32 | import org.mobicents.protocols.api.AssociationType;
33 | import org.mobicents.protocols.api.IpChannelType;
34 |
35 | /**
36 | * @author Amit Bhayani
37 | *
38 | */
39 | public class NettySctpServerHandler extends NettySctpChannelInboundHandlerAdapter {
40 |
41 | Logger logger = Logger.getLogger(NettySctpServerHandler.class);
42 |
43 | private final NettyServerImpl serverImpl;
44 | private final NettySctpManagementImpl managementImpl;
45 |
46 | /**
47 | *
48 | */
49 | public NettySctpServerHandler(NettyServerImpl serverImpl, NettySctpManagementImpl managementImpl) {
50 | this.serverImpl = serverImpl;
51 | this.managementImpl = managementImpl;
52 | }
53 |
54 | @Override
55 | public void channelUnregistered(final ChannelHandlerContext ctx) throws Exception {
56 | logger.warn(String.format("ChannelUnregistered event: association=%s", association));
57 | if (association != null) {
58 | this.association.setChannelHandler(null);
59 | }
60 | }
61 |
62 | @Override
63 | public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
64 | if (logger.isDebugEnabled()) {
65 | logger.debug(String.format("channelRegistered event: association=%s", this.association));
66 | }
67 |
68 | Channel channel = ctx.channel();
69 | InetSocketAddress sockAdd = ((InetSocketAddress) channel.remoteAddress());
70 | String host = sockAdd.getAddress().getHostAddress();
71 | int port = sockAdd.getPort();
72 |
73 | boolean provisioned = false;
74 |
75 | if (logger.isDebugEnabled()) {
76 | logger.debug(String.format("Received connect request from peer host=%s port=%d", host, port));
77 | }
78 |
79 | // Iterate through all corresponding associate to
80 | // check if incoming connection request matches with any provisioned
81 | // ip:port
82 | FastMap associations = this.managementImpl.associations;
83 | for (FastMap.Entry n = associations.head(), end = associations.tail(); (n = n.getNext()) != end
84 | && !provisioned;) {
85 | NettyAssociationImpl association = (NettyAssociationImpl) n.getValue();
86 |
87 | // check if an association binds to the found server
88 | if (serverImpl.getName().equals(association.getServerName())
89 | && association.getAssociationType() == AssociationType.SERVER) {
90 | // compare port and ip of remote with provisioned
91 | if ((port == association.getPeerPort() || association.getPeerPort()==0) && (host.equals(association.getPeerAddress()))) {
92 | provisioned = true;
93 |
94 | if (!association.isStarted()) {
95 | logger.error(String.format(
96 | "Received connect request for Association=%s but not started yet. Droping the connection!",
97 | association.getName()));
98 | channel.close();
99 | return;
100 | }
101 |
102 | this.association = association;
103 | this.channel = channel;
104 | this.ctx = ctx;
105 | this.association.setChannelHandler(this);
106 |
107 | if (logger.isInfoEnabled()) {
108 | logger.info(String.format("Connected %s", association));
109 | }
110 |
111 | if (association.getIpChannelType() == IpChannelType.TCP) {
112 | this.association.markAssociationUp(1, 1);
113 | }
114 |
115 | break;
116 | }
117 | }
118 | }// for loop
119 |
120 | if (!provisioned && serverImpl.isAcceptAnonymousConnections() && this.managementImpl.getServerListener() != null) {
121 | // the server accepts anonymous connections
122 |
123 | // checking for limit of concurrent connections
124 | if (serverImpl.getMaxConcurrentConnectionsCount() > 0
125 | && serverImpl.anonymAssociations.size() >= serverImpl.getMaxConcurrentConnectionsCount()) {
126 | logger.warn(String.format(
127 | "Incoming anonymous connection is rejected because of too many active connections to Server=%s",
128 | serverImpl));
129 | channel.close();
130 | return;
131 | }
132 |
133 | provisioned = true;
134 |
135 | NettyAssociationImpl anonymAssociation = new NettyAssociationImpl(host, port, serverImpl.getName(),
136 | serverImpl.getIpChannelType(), serverImpl);
137 | anonymAssociation.setManagement(this.managementImpl);
138 |
139 | try {
140 | this.managementImpl.getServerListener().onNewRemoteConnection(serverImpl, anonymAssociation);
141 | } catch (Throwable e) {
142 | logger.warn(String.format("Exception when invoking ServerListener.onNewRemoteConnection() Ass=%s",
143 | anonymAssociation), e);
144 | channel.close();
145 | return;
146 | }
147 |
148 | if (!anonymAssociation.isStarted()) {
149 | // connection is rejected
150 | logger.info(String.format("Rejected anonymous %s", anonymAssociation));
151 | channel.close();
152 | return;
153 | }
154 |
155 | this.association = anonymAssociation;
156 | this.channel = channel;
157 | this.ctx = ctx;
158 | this.association.setChannelHandler(this);
159 |
160 | if (logger.isInfoEnabled()) {
161 | logger.info(String.format("Accepted anonymous %s", anonymAssociation));
162 | }
163 |
164 | if (association.getIpChannelType() == IpChannelType.TCP) {
165 | this.association.markAssociationUp(1, 1);
166 | }
167 | }
168 |
169 | if (!provisioned) {
170 | // There is no corresponding Associate provisioned. Lets close the
171 | // channel here
172 | logger.warn(String.format("Received connect request from non provisioned %s:%d address. Closing Channel", host,
173 | port));
174 | ctx.close();
175 | }
176 | }
177 |
178 | @Override
179 | public void channelActive(ChannelHandlerContext ctx) {
180 | if (logger.isDebugEnabled()) {
181 | logger.debug("channelActive event: association=" + this.association);
182 | }
183 | }
184 |
185 | @Override
186 | public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
187 | // Close the connection when an exception is raised.
188 | logger.error("ExceptionCaught for Associtaion: " + this.association.getName() + "\n", cause);
189 | ctx.close();
190 | }
191 |
192 | }
193 |
--------------------------------------------------------------------------------
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/netty/NettySctpXMLBinding.java:
--------------------------------------------------------------------------------
1 | /*
2 | * TeleStax, Open Source Cloud Communications
3 | * Copyright 2011-2014, Telestax Inc and individual contributors
4 | * by the @authors tag.
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * under the terms of the GNU Affero General Public License as
8 | * published by the Free Software Foundation; either version 3 of
9 | * the License, or (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Affero General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Affero General Public License
17 | * along with this program. If not, see
18 | *
19 | */
20 | package org.mobicents.protocols.sctp.netty;
21 |
22 | import java.util.Iterator;
23 | import java.util.Map;
24 |
25 | import javolution.xml.XMLBinding;
26 | import javolution.xml.XMLFormat;
27 | import javolution.xml.stream.XMLStreamException;
28 |
29 | /**
30 | * @author Amit Bhayani
31 | *
32 | */
33 | public class NettySctpXMLBinding extends XMLBinding {
34 |
35 | protected static final XMLFormat ASSOCIATION_MAP = new XMLFormat(NettyAssociationMap.class) {
36 |
37 | @Override
38 | public void write(NettyAssociationMap obj, javolution.xml.XMLFormat.OutputElement xml) throws XMLStreamException {
39 | final Map map = (Map) obj;
40 |
41 | for (Iterator it = map.entrySet().iterator(); it.hasNext();) {
42 | Map.Entry entry = (Map.Entry) it.next();
43 |
44 | xml.add((String) entry.getKey(), "name", String.class);
45 | xml.add((NettyAssociationImpl) entry.getValue(), "association", NettyAssociationImpl.class);
46 | }
47 | }
48 |
49 | @Override
50 | public void read(javolution.xml.XMLFormat.InputElement xml, NettyAssociationMap obj) throws XMLStreamException {
51 | while (xml.hasNext()) {
52 | String key = xml.get("name", String.class);
53 | NettyAssociationImpl association = xml.get("association", NettyAssociationImpl.class);
54 | obj.put(key, association);
55 | }
56 | }
57 |
58 | };
59 |
60 | protected XMLFormat getFormat(Class forClass) throws XMLStreamException {
61 | if (NettyAssociationMap.class.equals(forClass)) {
62 | return ASSOCIATION_MAP;
63 | }
64 | return super.getFormat(forClass);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/netty/NettyTcpClientChannelInitializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * TeleStax, Open Source Cloud Communications
3 | * Copyright 2011-2014, Telestax Inc and individual contributors
4 | * by the @authors tag.
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * under the terms of the GNU Affero General Public License as
8 | * published by the Free Software Foundation; either version 3 of
9 | * the License, or (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Affero General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Affero General Public License
17 | * along with this program. If not, see
18 | *
19 | */
20 |
21 | package org.mobicents.protocols.sctp.netty;
22 |
23 | import io.netty.channel.ChannelInitializer;
24 | import io.netty.channel.socket.SocketChannel;
25 |
26 | /**
27 | * @author Amit Bhayani
28 | * @author Sergey Vetyutnev
29 | *
30 | */
31 | public class NettyTcpClientChannelInitializer extends ChannelInitializer {
32 |
33 | private final NettyAssociationImpl nettyAssociationImpl;
34 |
35 | /**
36 | * @param nettyAssociationImpl
37 | */
38 | public NettyTcpClientChannelInitializer(NettyAssociationImpl nettyAssociationImpl) {
39 | super();
40 | this.nettyAssociationImpl = nettyAssociationImpl;
41 | }
42 |
43 | @Override
44 | protected void initChannel(SocketChannel ch) throws Exception {
45 | ch.pipeline().addLast(new NettySctpClientHandler(this.nettyAssociationImpl));
46 |
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/netty/NettyTcpServerChannelInitializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * TeleStax, Open Source Cloud Communications
3 | * Copyright 2011-2014, Telestax Inc and individual contributors
4 | * by the @authors tag.
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * under the terms of the GNU Affero General Public License as
8 | * published by the Free Software Foundation; either version 3 of
9 | * the License, or (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU Affero General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Affero General Public License
17 | * along with this program. If not, see
18 | *
19 | */
20 |
21 | package org.mobicents.protocols.sctp.netty;
22 |
23 | import io.netty.channel.ChannelInitializer;
24 | import io.netty.channel.socket.SocketChannel;
25 |
26 | /**
27 | * @author Amit Bhayani
28 | * @author Sergey Vetyutnev
29 | *
30 | */
31 | public class NettyTcpServerChannelInitializer extends ChannelInitializer {
32 | private final NettyServerImpl nettyServerImpl;
33 | private final NettySctpManagementImpl sctpManagementImpl;
34 |
35 | protected NettyTcpServerChannelInitializer(NettyServerImpl nettyServerImpl, NettySctpManagementImpl sctpManagementImpl) {
36 | super();
37 | this.nettyServerImpl = nettyServerImpl;
38 | this.sctpManagementImpl = sctpManagementImpl;
39 | }
40 |
41 | @Override
42 | protected void initChannel(SocketChannel ch) throws Exception {
43 | ch.pipeline().addLast(new NettySctpServerHandler(this.nettyServerImpl, this.sctpManagementImpl));
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/sctp-impl/src/main/java/org/mobicents/protocols/sctp/netty/NonPersistentNettySctpManagementImpl.java:
--------------------------------------------------------------------------------
1 | package org.mobicents.protocols.sctp.netty;
2 |
3 | import java.io.IOException;
4 |
5 | public class NonPersistentNettySctpManagementImpl extends NettySctpManagementImpl {
6 |
7 | public NonPersistentNettySctpManagementImpl(String name) throws IOException {
8 | super(name);
9 |
10 | }
11 |
12 | @Override
13 | protected void load() {
14 |
15 | }
16 |
17 | @Override
18 | public void store() {
19 |
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/sctp-impl/src/test/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | # Set root logger level to DEBUG and its only appender to A1.
2 | log4j.rootLogger=DEBUG, A1, R
3 |
4 | # A1 is set to be a ConsoleAppender.
5 | log4j.appender.A1=org.apache.log4j.ConsoleAppender
6 |
7 | # File
8 | log4j.appender.R=org.apache.log4j.RollingFileAppender
9 | log4j.appender.R.File=sctptest.log
10 | #log4j.appender.R.File=/home/abhayani/workarea/mobicents/svn/trunk/servers/media/test-suite/target/mylogfile.log
11 |
12 | # Archive log files (one backup file here)
13 | log4j.appender.R.MaxBackupIndex=1
14 |
15 | log4j.appender.R.layout=org.apache.log4j.PatternLayout
16 | log4j.appender.R.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r[%t]%x - %C.%M(%F:%L) - %m%n
17 |
18 | # A1 uses PatternLayout.
19 | log4j.appender.A1.layout=org.apache.log4j.PatternLayout
20 | log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
21 |
22 | log4j.logger.org.mobicents.protocols.sctp=DEBUG
23 |
--------------------------------------------------------------------------------
/sctp-impl/testng-classes.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
22 |
--------------------------------------------------------------------------------
/sctp-impl/testng-methods.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------