Difference between revisions of "The Hello GPE World Tutorial"

From ARL Wiki
Jump to navigationJump to search
Line 87: Line 87:
  
 
<pre>
 
<pre>
     ssh YOUR_SLICE@IP_ADDRESS
+
     ssh YOUR_SLICE@SPP_ADDRESS
 
</pre>
 
</pre>
  
where ''YOUR_SLICE'' is the slice you were assigned during account registration, and ''IP_ADDRESS'' is the IP address of an SPP external interface.
+
where ''YOUR_SLICE'' is the slice you were assigned during account registration, and ''SPP_ADDRESS'' is the IP address of an SPP external interface.
  
 
During the login process, you will be asked to enter your RSA passphrase unless ''ssh-agent'' or an equivalent utility (e.g., ''keychain'', ''gnome-keyring-daemon'') is holding your private RSA key.
 
During the login process, you will be asked to enter your RSA passphrase unless ''ssh-agent'' or an equivalent utility (e.g., ''keychain'', ''gnome-keyring-daemon'') is holding your private RSA key.
 +
 +
    host> ssh pl_washu_sppDemo@SPP_ADDRESS
 +
    Enter passphrase for key '/home/.../LOGIN_NAME/.ssh/id_rsa':
 +
        '''... Respond with your passphrase ...'''
 +
    Last login:  ... Previous login information ...
 +
    [YOUR_SLICE@SPP_ADDRESS ~]$
 +
 +
If the SSH daemon asks you for your password, you will have to call ''ssh'' using the ''-i KEY_FILE'' argument like this:
 +
 +
<pre>
 +
    ssh -i ~/.ssh/id_rsa YOUR_SLICE@SPP_ADDRESS
 +
        ... The SSH daemon will ask for your passphrase ...
 +
</pre>
  
 
== Using ''ssh-agent'' ==
 
== Using ''ssh-agent'' ==
Line 109: Line 122:
  
 
<pre>
 
<pre>
     eval `ssh-agent`
+
     eval `ssh-agent`       # Notice the backquotes
 
     ssh-add
 
     ssh-add
 
     ... Enter your passphrase when it prompts for it ...
 
     ... Enter your passphrase when it prompts for it ...
Line 213: Line 226:
 
The ''type inet'' interfaces are physically connected to the Internet.
 
The ''type inet'' interfaces are physically connected to the Internet.
 
The ''type p2p'' interfaces are physically connected to other SPPs through point-to-point links.
 
The ''type p2p'' interfaces are physically connected to other SPPs through point-to-point links.
That's why you can only ''ping'' interfaces with type ''inet''.
+
That's why you can only ''ping'' interfaces with type ''inet'' from your host.
  
 
You can use the ''get_peer'' command to show the IP address of the interface at the other end of a point-to-point link.
 
You can use the ''get_peer'' command to show the IP address of the interface at the other end of a point-to-point link.
Line 294: Line 307:
 
When it receives a packet, it displays the content of the read buffer in both ASCII and hexadecimal formats and sends the "hello" string back to the client.
 
When it receives a packet, it displays the content of the read buffer in both ASCII and hexadecimal formats and sends the "hello" string back to the client.
  
Going through this example should demonstrate that using a GPE is just like using any other general-purpose host except that you need to setup and teardown the SPP.
+
Going through this example should demonstrate to you that using a GPE is just like using any other general-purpose host except that you need to setup and teardown the SPP.
But the setup and teardown procedure is straightforward.
 
  
 
Here are the steps involved in this example:
 
Here are the steps involved in this example:
Line 308: Line 320:
  
 
>>>>> How to get the tar file ??? <<<<<
 
>>>>> How to get the tar file ??? <<<<<
 +
 +
In the command block below, we assume that you will extract the tar file into the directory ''~/hello-gpe'' in your home directory:
  
 
<pre>
 
<pre>
     host> cd SOME_DIRECTORY
+
     host> cd                                 # change directory to your home directory
     host> tar xf ~/Download/hello-gpe.tar    # extracts into hello-gpe/ directory
+
    host> tar tf ~/Download/hello-gpe.tar    # see what is in the tar file
 +
     host> tar xf ~/Download/hello-gpe.tar    # extract contents into ~/hello-gpe/ directory
 
     host> cat README                        # read about the example
 
     host> cat README                        # read about the example
 
     host> make                              # make the two executables
 
     host> make                              # make the two executables
 
     ... Follow the insructions for doing a test using localhost ...
 
     ... Follow the insructions for doing a test using localhost ...
 
</pre>
 
</pre>
 +
 +
You now have the two executables:  ''hello-client'' and ''hello-server''.
  
 
== Copy the Server Executable and Scripts to a GPE ==
 
== Copy the Server Executable and Scripts to a GPE ==
 +
 +
Now, create a tar file that contains the two above executables and SPP scripts:
  
 
<pre>
 
<pre>
 
     host> make spp-hello.tar
 
     host> make spp-hello.tar
     GPE> scp spp-hello.tar YOUR_SLICE@SPP_ADDRESS:
+
     host> scp spp-hello.tar YOUR_SLICE@SPP_ADDRESS:
     GPE> ssh YOUR_SLICE@SPP_ADDRESS
+
     host> ssh YOUR_SLICE@SPP_ADDRESS
     GPE>  tar xf spp-hello.tar
+
    GPE>  tar tf spp-hello.tar        # look at what is in the tar file
 +
     GPE>  tar xf spp-hello.tar       # creates and populates ~/hello-gpe/
 
</pre>
 
</pre>
  
For example,
+
The ''spp-hello.tar'' file contains the scripts from the ''hello-gpe.tar'' file and the two executables ''hello-server'' and ''hello-client'' that you just created.
 +
We will first lead you through the process of setting up the SPP, running the executables and then tearing down the SPP in a step-by-step manner.
 +
Afterwards, we will discuss how to script the setup and teardown procedures.
  
<pre>
+
== Setup the SPP ==
    host> make spp-hello.tar
 
    GPE>  scp spp-hello.tar pl_washu_sppDemo@64.57.23.210:
 
    GPE>  ssh pl_washu_sppDemo@64.57.23.210
 
    GPE>  tar xf spp-hello.tar
 
</pre>
 
  
 +
Setting up the SPP so that packets from ''hello-client'' can get to your ''hello-server'' process running on a GPE involves these steps:
  
== Setup the SPP ==
+
* Make a PlanetLab reservation for the endpoint XXXXX
  
 
<pre>
 
<pre>

Revision as of 22:38, 4 March 2010

Template:Under Construction

Introduction

XXXXX

The SPP Components

XXXXX

Pinging SPP External Interfaces

Unlike most PlanetLab nodes, an SPP has multiple external interfaces. In the GENI deployment, some of those interfaces have Internet2 IP addresses and some are interfaces attached to point-to-point links going directly to an external interfaces of other SPPs. This section introduces you to sone of the Internet2 interfaces.

Let's try to ping some of those Internet2 interfaces. Enter one of the following ping commands (omit the comments):

    ping -c 3 64.57.23.210         # Salt Lake City interface 0
    ping -c 3 64.57.23.214         # Salt Lake City interface 1
    ping -c 3 64.57.23.218         # Salt Lake City interface 2
    ping -c 3 64.57.23.194         # Washington DC interface 0
    ping -c 3 64.57.23.198         # Washington DC interface 1
    ping -c 3 64.57.23.202         # Washington DC interface 2
    ping -c 3 64.57.23.178         # Kansas City interface 0
    ping -c 3 64.57.23.182         # Kansas City interface 1
    ping -c 3 64.57.23.186         # Kansas City interface 2

For example, my output from the first ping command looks like this:

    > ping -c 3 64.57.23.210
    PING 64.57.23.210 (64.57.23.210) 56(84) bytes of data.
    64 bytes from 64.57.23.210: icmp_seq=1 ttl=56 time=67.5 ms
    64 bytes from 64.57.23.210: icmp_seq=2 ttl=56 time=55.9 ms
    64 bytes from 64.57.23.210: icmp_seq=3 ttl=56 time=59.0 ms

    --- 64.57.23.210 ping statistics ---
    3 packets transmitted, 3 received, 0% packet loss, time 2002ms
    rtt min/avg/max/mdev = 55.949/60.823/67.511/4.895 ms

Note that you may not be able to ping an SPP external interface. Some reasons why it might fail are:

  1. Your host doesn't have ping installed. This is not typical.
  2. The SPP interface is down.
  3. Your network blocks ping traffic.
  4. Your network provider doesn't route Internet2 addresses.

In the first case, you will get a command not found error message. The ping command is usually located at /bin/ping. See your system administrator if you can't find ping. In the other cases, your ping command will eventually return with a 100% packet loss message. In the last case, running the command traceroute 64.57.23.210 will give a Network unreachable indication (the last router is marked !N).

If you are unsuccessful with one interface, try to ping the interface of a different SPP.

However, you can always get around these problems (except for an SPP being down) by issuing the ping command from a PlanetLab node. We discuss how to log into a PlanetLab node in The IPv4 Metanet Tutorial.

Logging Into an SPP's GPE

Now, let's try to log into the SPP interface that you were able to ping. The example below assumes that interface was 64.57.23.210; that is, interface 0 of the Salt Lake City SPP. Note the following:

  • You must use ssh to log into an SPP.
  • When you ssh to an SPP's external interface, you will actually get logged into a GPE of the SPP.
  • Furthermore, you will be logging into your slice in a GPE.
  • Even if your network blocks your ping packets, you should be able to log into a GPE as long as there is a route to the SPP's external interface address.
  • You can 'ssh' to any of the SPP's external interfaces.

To log into a GPE at the Salt Lake City SPP, I would enter:

    ssh pl_washu_sppDemo@64.57.23.210

where my slice name is pl_washu_sppDemo. Thus, the general format is:

    ssh YOUR_SLICE@SPP_ADDRESS

where YOUR_SLICE is the slice you were assigned during account registration, and SPP_ADDRESS is the IP address of an SPP external interface.

During the login process, you will be asked to enter your RSA passphrase unless ssh-agent or an equivalent utility (e.g., keychain, gnome-keyring-daemon) is holding your private RSA key.

   host> ssh pl_washu_sppDemo@SPP_ADDRESS
   Enter passphrase for key '/home/.../LOGIN_NAME/.ssh/id_rsa':
       ... Respond with your passphrase ...
   Last login:  ... Previous login information ...
   [YOUR_SLICE@SPP_ADDRESS ~]$

If the SSH daemon asks you for your password, you will have to call ssh using the -i KEY_FILE argument like this:

    ssh -i ~/.ssh/id_rsa YOUR_SLICE@SPP_ADDRESS
        ... The SSH daemon will ask for your passphrase ...

Using ssh-agent

This section is a very brief explanation of how to use ssh-agent. You can skip this section if you are already using such an agent. If you have never used such an agent, note that there are several alternatives to the procedure described below and our description is meant to be a simple cookbook procedure. See the ssh-agent and ssh-add man pages or the web for more details.

The basic idea is to run ssh-agent which is a daemon process that caches private keys and listens for requests from SSH clients needing a private key related computation. Then, run the ssh-add command to add your private key to your agent's cache. This is only done once after you start the SSH agent. The process will ask you for your passphrase which is used to decrypt the private key which is then held in main memory by the agent.

For example,

    eval `ssh-agent`        # Notice the backquotes
    ssh-add
    ... Enter your passphrase when it prompts for it ...

Notice that we are using backquotes (which denotes command substitution) in the first line, NOT the normal forward quote characters.

In the first line, ssh-agent outputs two commands to stdout which is then evaluated by the eval command. These two commands set the two environment variables SSH_AUTH_SOCK and SSH_AGENT_PID. Enter the command "printenv | grep SSH_A", and you will get output that looks like:

    SSH_AUTH_SOCK=/tmp/ssh-sTNf2142/agent.2142
    SSH_AGENT_PID=2143

which says that process 2143 is your ssh-agent and it is listening for requests on the Unix Domain socket /tmp/ssh-sTNf2142/agent.2142. The ssh-add command adds your private key to the list of private keys held by ssh-agent.

You can now verify that you can ssh to an SPP without entering a password or passphrase. In fact, any subshell of the current shell will not need to enter a password when logging into an SPP as long as the agent is running because the SSH environment variables are passed to all children of the current shell allowing them to communicate with the same agent.

The SPP Configuration Command scfg

After you have logged into a GPE, you can use the scfg command to:

  • Get information about the SPP
  • Configure the SPP
  • Make resource reservations

You can get help information from scfg by entering one of these forms of the command:

    scfg --help all         # show help for all commands
    scfg --help info        # show help for information commands
    scfg --help queues      # show help for queue commands
    scfg --help reserv      # show help for reservation commands
    scfg --help alloc       # show help for resource alloc/free commands

Try getting help on the information commands by entering:

    scfg --help info

Your output should look like this:

    USAGE:
    INFORMATION CMDS:
      scfg --cmd get_ifaces
            Display all interfaces
      scfg --cmd get_ifpeer --ifn N
            Display the peer of interface num N
      ... other output not shown ...

If you get a command not found message, try entering:

    /usr/local/bin/scfg --help info

If the command now runs, you need to add /usr/local/bin to your PATH environment variable. The rest of this tutorial assumes that your PATH environment variable has been set to include the directory containing the scfg command.

Getting Information About External Interfaces

SPPs have multiple external interfaces. To show the attributes of all external interfaces, enter:

    scfg --cmd get_ifaces

For example, running this command on the Salt Lake City SPP produces:

    Interface list:
      [ifn 0, type  "inet", linkBW 1000000Kbps, availBW 899232Kbps, ipAddr 64.57.23.210]
      [ifn 1, type  "inet", linkBW 1000000Kbps, availBW 899232Kbps, ipAddr 64.57.23.214]
      [ifn 2, type  "inet", linkBW 1000000Kbps, availBW 899232Kbps, ipAddr 64.57.23.218]
      [ifn 3, type  "p2p", linkBW 1000000Kbps, availBW 899232Kbps, ipAddr 10.1.1.2]
      [ifn 4, type  "p2p", linkBW 1000000Kbps, availBW 899232Kbps, ipAddr 10.1.2.2]
      [ifn 5, type  "p2p", linkBW 1000000Kbps, availBW 899232Kbps, ipAddr 10.1.7.2]
      [ifn 6, type  "p2p", linkBW 1000000Kbps, availBW 899232Kbps, ipAddr 10.1.8.2]

This output shows:

  • There are seven external interfaces numbered from 0 to 7.
  • type: There are two types of interfaces: Internet (inet) and point-to-point (p2p).
  • linkBW: The capacity of each interface is 1 Gbps (i.e., 1000000 Kbps).
  • availBW: The available bandwidth of each interface is 899.232 Mbps (i.e., 899232 Kbps); that is, that portion of the capacity that hasn't already been allocated.
  • ipAddr: The IP addresses of each interface.

Getting Information About Peers

The type inet interfaces are physically connected to the Internet. The type p2p interfaces are physically connected to other SPPs through point-to-point links. That's why you can only ping interfaces with type inet from your host.

You can use the get_peer command to show the IP address of the interface at the other end of a point-to-point link. For example, I would enter:

    scfg --cmd get_peer --ifn 3

to find out the IP address of interface 3's peer. These seven commands will show the peer IP addresses of interfaces 0-6:

    scfg --cmd get_peer --ifn 0
    scfg --cmd get_peer --ifn 1
    scfg --cmd get_peer --ifn 2
    scfg --cmd get_peer --ifn 3
    scfg --cmd get_peer --ifn 4
    scfg --cmd get_peer --ifn 5
    scfg --cmd get_peer --ifn 6

Running these commands on the Salt Lake City SPP produces this output:

    SPP Peer IP address: 0.0.0.0
    SPP Peer IP address: 0.0.0.0
    SPP Peer IP address: 0.0.0.0
    SPP Peer IP address: 10.1.1.1
    SPP Peer IP address: 10.1.2.1
    SPP Peer IP address: 10.1.7.1
    SPP Peer IP address: 10.1.8.1

Notice that the p2p interfaces are the only ones with a peer IP address that is not 0.0.0.0. Furthermore, these addresses have the same 10.1.x.y format as other p2p interfaces.

Constructing an SPP Interconnection Map

We can now build a complete interconnection map of the SPPs if we combine the output of the get_ifaces and get_peer commands from all SPPs. This output is shown at the bottom of the The GENI SPP Configuration page. The interconnection tables shown near the top of the The GENI SPP Configuration page were constructed from this output.

The Salt Lake City table is:

Interface Type IP Address Peer Address
0 inet 64.57.23.210 0.0.0.0
1 inet 64.57.23.214 0.0.0.0
2 inet 64.57.23.218 0.0.0.0
3 p2p 10.1.1.2 10.1.1.1 (KC ifn 3)
4 p2p 10.1.2.2 10.1.2.1 (KC ifn 4)
5 p2p 10.1.7.2 10.1.7.1 (DC ifn 5)
6 p2p 10.1.8.2 10.1.8.1 (DC ifn 6)

For example, the peer IP address of interface 3 is 10.1.1.1 which is the IP address of Kansas City's interface 3. You can verify the labeling of the peer IP addresses for interfaces 4-6 by looking at the output at the bottom of The GENI SPP Configuration page. Below is a diagram of the SPP interconnection map:

scfg has other information commands and also commands for allocating/freeing SPP resources and managing queues. The example below will describe some of these commands. The page SPP Command Interface summarizes all of the commands.

Hello GPE World

The first program we will run on a GPE is a variant of the UDP echo server. You will run the client on your Linux host which will send a UDP packet containing the 6-byte C-string (including the terminating NUL byte) "hello" to the server. The server listens on port 50000 for an incoming UDP packet. When it receives a packet, it displays the content of the read buffer in both ASCII and hexadecimal formats and sends the "hello" string back to the client.

Going through this example should demonstrate to you that using a GPE is just like using any other general-purpose host except that you need to setup and teardown the SPP.

Here are the steps involved in this example:

  • Create the client and server executables.
  • Copy the server executable and scripts to a GPE.
  • Setup the SPP.
  • Run the server and the client.
  • Teardown the SPP.

Create the Client and Server Executables

>>>>> How to get the tar file ??? <<<<<

In the command block below, we assume that you will extract the tar file into the directory ~/hello-gpe in your home directory:

    host> cd                                 # change directory to your home directory
    host> tar tf ~/Download/hello-gpe.tar    # see what is in the tar file
    host> tar xf ~/Download/hello-gpe.tar    # extract contents into ~/hello-gpe/ directory
    host> cat README                         # read about the example
    host> make                               # make the two executables
    ... Follow the insructions for doing a test using localhost ...

You now have the two executables: hello-client and hello-server.

Copy the Server Executable and Scripts to a GPE

Now, create a tar file that contains the two above executables and SPP scripts:

    host> make spp-hello.tar
    host> scp spp-hello.tar YOUR_SLICE@SPP_ADDRESS:
    host> ssh YOUR_SLICE@SPP_ADDRESS
    GPE>  tar tf spp-hello.tar        # look at what is in the tar file
    GPE>  tar xf spp-hello.tar        # creates and populates ~/hello-gpe/

The spp-hello.tar file contains the scripts from the hello-gpe.tar file and the two executables hello-server and hello-client that you just created. We will first lead you through the process of setting up the SPP, running the executables and then tearing down the SPP in a step-by-step manner. Afterwards, we will discuss how to script the setup and teardown procedures.

Setup the SPP

Setting up the SPP so that packets from hello-client can get to your hello-server process running on a GPE involves these steps:

  • Make a PlanetLab reservation for the endpoint XXXXX
    GPE>  cd hello-gpe
    GPE>  scripts/setup-hello-gpe.sh SPP_ADDRESS UDP_PORT
    GPE>  cd hello-gpe
    GPE>  scripts/setup-hello-gpe.sh 64.57.23.210 50000     # use Salt Lake City ifn 0, port 50000
    XXX what you should see XXX

The setup-hello-gpe.sh Script

Run the Server and the Client

    GPE>  hello-server UDP_PORT
    GPE>  hello-server 50000
    XXX what you should see XXX
    host> hello-client 64.57.23.210 50000
    XXX what you should see XXX

Teardown the SPP

    GPE>  scripts/teardown-hello-gpe.sh SPP_ADDRESS UDP_PORT
    GPE>  scripts/teardown-hello-gpe.sh 64.57.23.210 50000
    XXX what you should see XXX

The teardown-hello-gpe.sh Script

Putting Everything Together

>>>>> HERE <<<<<