hellocore

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
hellocore [2013/09/09 20:19]
mroriz
hellocore [2016/04/26 14:35]
mroriz
Line 1: Line 1:
 ====== HelloCore ====== ====== HelloCore ======
 {{ :hellocoreext.png?nolink&400|}} {{ :hellocoreext.png?nolink&400|}}
-This tutorial will guide you through the basic concepts and programming involved in the communication between a mobile node (MN) and a stationary node within the SDDL core network [[architecture|]]. This stationary node of the SDDL core will play the role of a server processing node, capable of processing application messages from the mobile node (MN)  according to some application specific logic, and sending messages back to the MN. Hence, this tutorial will cover both paths of the communication, //i.e.//, from the MN to the server processing node, and from the stationary node to the MN.+This tutorial will guide you through the basic concepts and programming involved in the communication between a mobile node (MN) and a stationary node within the ContextNet SDDL core network [[architecture|]]. This stationary node of the SDDL core will play the role of a server processing node, capable of processing application messages from the mobile node (MN)  according to some application specific logic, and sending messages back to the MN. Hence, this tutorial will cover both paths of the communication, //i.e.//, from the MN to the server processing node, and from the stationary node to the MN.
  
 Our sample application is composed of two components: a mobile client node and a stationary node, as illustrated in the figure on the right. The MN creates a ''Hello World'' message which is sent to the SDDL core. Our processing node receives this message and execute a simple logic, keeps track on the number of messages received and prints them on the screen. To exemplify the other path of communication, the processing node sends a reply message to the MN containing the number of message that it received so far.  Our sample application is composed of two components: a mobile client node and a stationary node, as illustrated in the figure on the right. The MN creates a ''Hello World'' message which is sent to the SDDL core. Our processing node receives this message and execute a simple logic, keeps track on the number of messages received and prints them on the screen. To exemplify the other path of communication, the processing node sends a reply message to the MN containing the number of message that it received so far. 
Line 8: Line 8:
  
 <WRAP tip> <WRAP tip>
-You do not need to copy the source code snippets shown in this tutorial. At the end of each section there is a link to download the entire node source code. Moreover, all examples are included in the virtual machine made available.+You do not need to copy the source code snippets shown in this tutorial. At the end of each section there is a link to download the entire node source code. 
 </WRAP> </WRAP>
 +
 ===== MobileClient ===== ===== MobileClient =====
-To create our mobile client application, create a Java Project in Eclipse called ''HelloCore''. Be cautious and certify if you imported correctly the required libraries, which in this case is the ''contextnet.jar'' library. If you have any question on how to import these library, check the [[Eclipse|creating a SDDL project]] page. After these steps, create an empty Java ''HelloCoreClient'' Class using the ''br.pucrio.inf.lac.helloworld'' package in the ''HelloCore'' project.+To create our mobile client application, create a Java Project in Eclipse called ''HelloCore''. Be cautious and certify if you imported correctly the required libraries, which in this case is the ''contextnet.jar'' library. Alternatively, you can declare the ContextNet middleware as a Maven dependency . If you have any question on how to import this library, check the [[Eclipse|creating a SDDL project]] page. After these steps, create an empty Java ''HelloCoreClient'' Class using the ''br.pucrio.inf.lac.helloworld'' package in the ''HelloCore'' project.
  
 In SDDL, nodes that are outside the core (either mobile or stationary) interact directly with the Gateway rather than the processing nodes, since it uses a different protocol ([[ClientLib]] and [[MRUDP]]) than the core ([[wp>Data_Distribution_Service|Data Distribution Service (DDS)]]). The Gateway translate the node message to the core protocol and vice-versa. Thus, the primary interaction of the client is with the gateway. Therefore, we first declare two variables to locate our gateway, its IP address and port number. Since in this tutorial we are running our entire application (mobile client node, gateway, and processing node) locally, we can specify the gateway IP to the loopback ''127.0.0.1'' and choose its default port ''5500''. In a real distributed scenario, the client would need to know at least one of the gateways IP and ports pair.  In SDDL, nodes that are outside the core (either mobile or stationary) interact directly with the Gateway rather than the processing nodes, since it uses a different protocol ([[ClientLib]] and [[MRUDP]]) than the core ([[wp>Data_Distribution_Service|Data Distribution Service (DDS)]]). The Gateway translate the node message to the core protocol and vice-versa. Thus, the primary interaction of the client is with the gateway. Therefore, we first declare two variables to locate our gateway, its IP address and port number. Since in this tutorial we are running our entire application (mobile client node, gateway, and processing node) locally, we can specify the gateway IP to the loopback ''127.0.0.1'' and choose its default port ''5500''. In a real distributed scenario, the client would need to know at least one of the gateways IP and ports pair. 
Line 17: Line 18:
 <code java> <code java>
 public class HelloCoreClient { public class HelloCoreClient {
-  private static String gatewayIP   = "127.0.0.1"; +  private static String  gatewayIP   = "127.0.0.1"; 
-  private static int gatewayPort = 5500;+  private static int     gatewayPort = 5500;
 } }
 </code> </code>
Line 26: Line 27:
 <code java> <code java>
 public class HelloCoreClient { public class HelloCoreClient {
- +  private static String       gatewayIP   = "127.0.0.1"; 
-  private static String gatewayIP   = "127.0.0.1"; +  private static int          gatewayPort = 5500; 
-  private static int gatewayPort = 5500; +  private MrUdpNodeConnection connection;
-  private MrUdpNodeConnection connection;+
  
   public static void main(String[] args) {   public static void main(String[] args) {
Line 48: Line 48:
       try {       try {
           connection = new MrUdpNodeConnection();           connection = new MrUdpNodeConnection();
-          connection.connect(address); 
           connection.addNodeConnectionListener(this);           connection.addNodeConnectionListener(this);
 +          connection.connect(address);
       } catch (IOException e) {       } catch (IOException e) {
           e.printStackTrace();           e.printStackTrace();
Line 272: Line 272:
 To execute our application, we need to first create the gateway, which will instantiate the core infrastructure if none exists. The gateway receives two parameters, its public IP and a given port number. Since we are this sample locally, we can choose the loopback IP ''127.0.0.1'' and the default middleware port ''5500''. To do that, open a shell, and run the following command: To execute our application, we need to first create the gateway, which will instantiate the core infrastructure if none exists. The gateway receives two parameters, its public IP and a given port number. Since we are this sample locally, we can choose the loopback IP ''127.0.0.1'' and the default middleware port ''5500''. To do that, open a shell, and run the following command:
  
-  $ gateway 127.0.0.1 5500+  $ gateway 127.0.0.1 5500 OpenSplice
  
 After that, we instantiate our processing node. To do that, run the ''HelloCoreServer'' class in Eclipse as a Java application. Finally, execute the ''HelloCoreClient'' class in Eclipse to start the mobile node application. You will see the printed messages in your console. After that, we instantiate our processing node. To do that, run the ''HelloCoreServer'' class in Eclipse as a Java application. Finally, execute the ''HelloCoreClient'' class in Eclipse to start the mobile node application. You will see the printed messages in your console.
  • hellocore.txt
  • Last modified: 2017/07/21 03:08
  • (external edit)