Sophie

Sophie

distrib > Fedora > 17 > i386 > media > updates > by-pkgid > 675c8c8167236dfcf8d66da674f931e8 > files > 166

erlang-doc-R15B-03.3.fc17.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../doc/otp_doc.css" type="text/css">
<title>Erlang -- Distribution Protocol</title>
</head>
<body bgcolor="white" text="#000000" link="#0000ff" vlink="#ff00ff" alink="#ff0000"><div id="container">
<script id="js" type="text/javascript" language="JavaScript" src="../../../doc/js/flipmenu/flipmenu.js"></script><script id="js2" type="text/javascript" src="../../../doc/js/erlresolvelinks.js"></script><script language="JavaScript" type="text/javascript">
            <!--
              function getWinHeight() {
                var myHeight = 0;
                if( typeof( window.innerHeight ) == 'number' ) {
                  //Non-IE
                  myHeight = window.innerHeight;
                } else if( document.documentElement && ( document.documentElement.clientWidth ||
                                                         document.documentElement.clientHeight ) ) {
                  //IE 6+ in 'standards compliant mode'
                  myHeight = document.documentElement.clientHeight;
                } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
                  //IE 4 compatible
                  myHeight = document.body.clientHeight;
                }
                return myHeight;
              }

              function setscrollpos() {
                var objf=document.getElementById('loadscrollpos');
                 document.getElementById("leftnav").scrollTop = objf.offsetTop - getWinHeight()/2;
              }

              function addEvent(obj, evType, fn){
                if (obj.addEventListener){
                obj.addEventListener(evType, fn, true);
                return true;
              } else if (obj.attachEvent){
                var r = obj.attachEvent("on"+evType, fn);
                return r;
              } else {
                return false;
              }
             }

             addEvent(window, 'load', setscrollpos);

             //--></script><div id="leftnav"><div class="innertube">
<img alt="Erlang logo" src="../../../doc/erlang-logo.png"><br><small><a href="users_guide.html">User's Guide</a><br><a href="index.html">Reference Manual</a><br><a href="release_notes.html">Release Notes</a><br><a href="../pdf/erts-5.9.3.1.pdf">PDF</a><br><a href="../../../doc/index.html">Top</a></small><p><strong>Erlang Run-Time System Application (ERTS)</strong><br><strong>User's Guide</strong><br><small>Version 5.9.3.1</small></p>
<br><a href="javascript:openAllFlips()">Expand All</a><br><a href="javascript:closeAllFlips()">Contract All</a><p><small><strong>Chapters</strong></small></p>
<ul class="flipMenu" imagepath="../../../doc/js/flipmenu">
<li id="no" title="Match specifications in Erlang" expanded="false">Match specifications in Erlang<ul>
<li><a href="match_spec.html">
              Top of chapter
            </a></li>
<li title="Grammar"><a href="match_spec.html#id67432">Grammar</a></li>
<li title="Function descriptions"><a href="match_spec.html#id65382">Function descriptions</a></li>
<li title="Variables and literals"><a href="match_spec.html#id73136">Variables and literals</a></li>
<li title="Execution of the match"><a href="match_spec.html#id73066">Execution of the match</a></li>
<li title="Differences between match specifications in ETS and tracing"><a href="match_spec.html#id69369">Differences between match specifications in ETS and tracing</a></li>
<li title="Examples"><a href="match_spec.html#id69408">Examples</a></li>
</ul>
</li>
<li id="no" title="How to interpret the Erlang crash dumps" expanded="false">How to interpret the Erlang crash dumps<ul>
<li><a href="crash_dump.html">
              Top of chapter
            </a></li>
<li title="General information"><a href="crash_dump.html#id71973">General information</a></li>
<li title="Memory information"><a href="crash_dump.html#id69719">Memory information</a></li>
<li title="Internal table information"><a href="crash_dump.html#id69746">Internal table information</a></li>
<li title="Allocated areas"><a href="crash_dump.html#id71628">Allocated areas</a></li>
<li title="Allocator"><a href="crash_dump.html#id71654">Allocator</a></li>
<li title="Process information"><a href="crash_dump.html#id71693">Process information</a></li>
<li title="Port information"><a href="crash_dump.html#id70337">Port information</a></li>
<li title="ETS tables"><a href="crash_dump.html#id70354">ETS tables</a></li>
<li title="Timers"><a href="crash_dump.html#id70452">Timers</a></li>
<li title="Distribution information"><a href="crash_dump.html#id77672">Distribution information</a></li>
<li title="Loaded module information"><a href="crash_dump.html#id77796">Loaded module information</a></li>
<li title="Fun information"><a href="crash_dump.html#id77887">Fun information</a></li>
<li title="Process Data"><a href="crash_dump.html#id77959">Process Data</a></li>
<li title="Atoms"><a href="crash_dump.html#id78034">Atoms</a></li>
<li title="Disclaimer"><a href="crash_dump.html#id78051">Disclaimer</a></li>
</ul>
</li>
<li id="no" title="How to implement an alternative carrier for  the Erlang distribution" expanded="false">How to implement an alternative carrier for  the Erlang distribution<ul>
<li><a href="alt_dist.html">
              Top of chapter
            </a></li>
<li title="Introduction"><a href="alt_dist.html#id78171">Introduction</a></li>
<li title="The driver"><a href="alt_dist.html#id78261">The driver</a></li>
<li title="Putting it all together"><a href="alt_dist.html#id79511">Putting it all together</a></li>
</ul>
</li>
<li id="no" title="The Abstract Format" expanded="false">The Abstract Format<ul>
<li><a href="absform.html">
              Top of chapter
            </a></li>
<li title="Module declarations and forms"><a href="absform.html#id79791">Module declarations and forms</a></li>
<li title="Atomic literals"><a href="absform.html#id79999">Atomic literals</a></li>
<li title="Patterns"><a href="absform.html#id80061">Patterns</a></li>
<li title="Expressions"><a href="absform.html#id80275">Expressions</a></li>
<li title="Clauses"><a href="absform.html#id80983">Clauses</a></li>
<li title="Guards"><a href="absform.html#id81203">Guards</a></li>
<li title="The abstract format after preprocessing"><a href="absform.html#id81478">The abstract format after preprocessing</a></li>
</ul>
</li>
<li id="no" title="tty - A command line interface" expanded="false">tty - A command line interface<ul>
<li><a href="tty.html">
              Top of chapter
            </a></li>
<li title="Normal Mode"><a href="tty.html#id81651">Normal Mode</a></li>
<li title="Shell Break Mode"><a href="tty.html#id82034">Shell Break Mode</a></li>
</ul>
</li>
<li id="no" title="How to implement a driver" expanded="false">How to implement a driver<ul>
<li><a href="driver.html">
              Top of chapter
            </a></li>
<li title="Introduction"><a href="driver.html#id82159">Introduction</a></li>
<li title="Sample driver"><a href="driver.html#id82191">Sample driver</a></li>
<li title="Compiling and linking the sample driver"><a href="driver.html#id82593">Compiling and linking the sample driver</a></li>
<li title="Calling a driver as a port in Erlang"><a href="driver.html#id82629">Calling a driver as a port in Erlang</a></li>
<li title="Sample asynchronous driver"><a href="driver.html#id82736">Sample asynchronous driver</a></li>
<li title="An asynchronous driver using driver_async"><a href="driver.html#id83010">An asynchronous driver using driver_async</a></li>
</ul>
</li>
<li id="no" title="Inet configuration" expanded="false">Inet configuration<ul>
<li><a href="inet_cfg.html">
              Top of chapter
            </a></li>
<li title="Introduction"><a href="inet_cfg.html#id83274">Introduction</a></li>
<li title="Configuration Data"><a href="inet_cfg.html#id83378">Configuration Data</a></li>
<li title="User Configuration Example"><a href="inet_cfg.html#id84255">User Configuration Example</a></li>
</ul>
</li>
<li id="no" title="External Term Format" expanded="false">External Term Format<ul>
<li><a href="erl_ext_dist.html">
              Top of chapter
            </a></li>
<li title="Introduction"><a href="erl_ext_dist.html#id84356">Introduction</a></li>
<li title="Distribution header"><a href="erl_ext_dist.html#id84636">Distribution header</a></li>
<li title="ATOM_CACHE_REF"><a href="erl_ext_dist.html#id85209">ATOM_CACHE_REF</a></li>
<li title="SMALL_INTEGER_EXT"><a href="erl_ext_dist.html#id85285">SMALL_INTEGER_EXT</a></li>
<li title="INTEGER_EXT"><a href="erl_ext_dist.html#id85348">INTEGER_EXT</a></li>
<li title="FLOAT_EXT"><a href="erl_ext_dist.html#id85412">FLOAT_EXT</a></li>
<li title="ATOM_EXT"><a href="erl_ext_dist.html#id85488">ATOM_EXT</a></li>
<li title="REFERENCE_EXT"><a href="erl_ext_dist.html#id85583">REFERENCE_EXT</a></li>
<li title="PORT_EXT"><a href="erl_ext_dist.html#id85741">PORT_EXT</a></li>
<li title="PID_EXT"><a href="erl_ext_dist.html#id85860">PID_EXT</a></li>
<li title="SMALL_TUPLE_EXT"><a href="erl_ext_dist.html#id86004">SMALL_TUPLE_EXT</a></li>
<li title="LARGE_TUPLE_EXT"><a href="erl_ext_dist.html#id86096">LARGE_TUPLE_EXT</a></li>
<li title="NIL_EXT"><a href="erl_ext_dist.html#id86186">NIL_EXT</a></li>
<li title="STRING_EXT"><a href="erl_ext_dist.html#id86237">STRING_EXT</a></li>
<li title="LIST_EXT"><a href="erl_ext_dist.html#id86329">LIST_EXT</a></li>
<li title="BINARY_EXT"><a href="erl_ext_dist.html#id86448">BINARY_EXT</a></li>
<li title="SMALL_BIG_EXT"><a href="erl_ext_dist.html#id86545">SMALL_BIG_EXT</a></li>
<li title="LARGE_BIG_EXT"><a href="erl_ext_dist.html#id86652">LARGE_BIG_EXT</a></li>
<li title="NEW_REFERENCE_EXT"><a href="erl_ext_dist.html#id86755">NEW_REFERENCE_EXT</a></li>
<li title="SMALL_ATOM_EXT"><a href="erl_ext_dist.html#id86928">SMALL_ATOM_EXT</a></li>
<li title="FUN_EXT"><a href="erl_ext_dist.html#id87034">FUN_EXT</a></li>
<li title="NEW_FUN_EXT"><a href="erl_ext_dist.html#id87281">NEW_FUN_EXT</a></li>
<li title="EXPORT_EXT"><a href="erl_ext_dist.html#id87658">EXPORT_EXT</a></li>
<li title="BIT_BINARY_EXT"><a href="erl_ext_dist.html#id87802">BIT_BINARY_EXT</a></li>
<li title="NEW_FLOAT_EXT"><a href="erl_ext_dist.html#id87908">NEW_FLOAT_EXT</a></li>
</ul>
</li>
<li id="loadscrollpos" title="Distribution Protocol" expanded="true">Distribution Protocol<ul>
<li><a href="erl_dist_protocol.html">
              Top of chapter
            </a></li>
<li title="EPMD Protocol"><a href="erl_dist_protocol.html#id88085">EPMD Protocol</a></li>
<li title="Handshake"><a href="erl_dist_protocol.html#id89383">Handshake</a></li>
<li title="Protocol between connected nodes"><a href="erl_dist_protocol.html#id89399">Protocol between connected nodes</a></li>
<li title="New Ctrlmessages for distrvsn = 1 (OTP R4)"><a href="erl_dist_protocol.html#id89841">New Ctrlmessages for distrvsn = 1 (OTP R4)</a></li>
<li title="New Ctrlmessages for distrvsn = 2"><a href="erl_dist_protocol.html#id89939">New Ctrlmessages for distrvsn = 2</a></li>
<li title="New Ctrlmessages for distrvsn = 3 (OTP R5C)"><a href="erl_dist_protocol.html#id89951">New Ctrlmessages for distrvsn = 3 (OTP R5C)</a></li>
<li title="New Ctrlmessages for distrvsn = 4 (OTP R6)"><a href="erl_dist_protocol.html#id89963">New Ctrlmessages for distrvsn = 4 (OTP R6)</a></li>
</ul>
</li>
</ul>
</div></div>
<div id="content">
<div class="innertube">
<h1>9 Distribution Protocol</h1>
  

<p>
The description here is far from complete and will therefore be further
refined in upcoming releases.

The protocols both from Erlang nodes towards
EPMD (Erlang Port Mapper Daemon) and between Erlang nodes, however, are
stable since many years.
</p>

<p>The distribution protocol can be divided into four (4) parts:</p>
<ul>
  <li>
    <p>
      1. Low level socket connection.
    </p>
  </li>
  <li>
    2. Handshake, interchange node name and authenticate.
  </li>
  <li>
    3. Authentication (done by net_kernel).
  </li>
  <li>
    4. Connected. 
  </li>
</ul>
<p>
  A node fetches the Port number of another node through the EPMD (at the
  other host) in order to initiate a connection request.
</p>
<p>
For each host where a distributed Erlang node is running there should also
be an EPMD running. The EPMD can be started explicitly or automatically
as a result of the Erlang node startup.
</p>
<p>
By default EPMD listens on port 4369.
</p>
<p>
  3 and 4 are performed at the same level but the net_kernel disconnects the
  other node if it communicates using an invalid cookie (after one (1) second).
</p>

<p>The integers in all multi-byte fields are in big-endian order.</p>

  <h3><a name="id88085">9.1 
        EPMD Protocol</a></h3>
    
    <p>
      The requests served by the EPMD (Erlang Port Mapper Daemon) are 
      summarized in the figure below.
    </p>

      <img alt="IMAGE MISSING" src="erl_ext_fig.gif"><br>
	<em>Figure
        9.1:
         
        
	  Summary of EPMD requests. 
	</em>
      
      <p>
	Each request <span class="code">*_REQ</span> is preceded by a two-byte length field. 
	Thus, the overall request format is:
      </p>

      <table border="1" cellpadding="2" cellspacing="0">
<tr>
	  <td align="left" valign="middle">2</td>
	  <td align="left" valign="middle">n</td>
	</tr>
<tr>
	  <td align="left" valign="middle">Length</td>
	  <td align="left" valign="middle">Request</td>
	</tr>
</table>
<em>Table
        9.1:
         
        </em>

      <h4>Register a node in the EPMD</h4>
	
	<p>
	  When a distributed node is started it registers itself in EPMD.
	  The message ALIVE2_REQ described below is sent from the node towards
	  EPMD. The response from EPMD is ALIVE2_RESP.
	</p>
	<table border="1" cellpadding="2" cellspacing="0">
<tr>
	    <td align="left" valign="middle">1</td>
	    <td align="left" valign="middle">2</td>
	    <td align="left" valign="middle">1</td>
	    <td align="left" valign="middle">1</td>
	    <td align="left" valign="middle">2</td>
	    <td align="left" valign="middle">2</td>
	    <td align="left" valign="middle">2</td>
	    <td align="left" valign="middle">Nlen</td>
	    <td align="left" valign="middle">2</td>
	    <td align="left" valign="middle">Elen</td>
	  </tr>
<tr>
	    <td align="left" valign="middle">120</td>
	    <td align="left" valign="middle">PortNo</td>
	    <td align="left" valign="middle">NodeType</td>
	    <td align="left" valign="middle">Protocol</td>
	    <td align="left" valign="middle">HighestVersion</td>
	    <td align="left" valign="middle">LowestVersion</td>
	    <td align="left" valign="middle">Nlen</td>
	    <td align="left" valign="middle">NodeName</td>
	    <td align="left" valign="middle">Elen</td>
	    <td align="left" valign="middle">Extra</td>
	  </tr>
</table>
<em>Table
        9.2:
         
        ALIVE2_REQ (120)</em>
	  <dl>
	    <dt><strong><span class="code">PortNo</span></strong></dt>
	    <dd>
	      The port number on which the node accept connection requests.
	    </dd>
	    <dt><strong><span class="code">NodeType</span></strong></dt>
	    <dd>
	      77 = normal Erlang node, 72 = hidden node (C-node),...
	    </dd>
	    <dt><strong><span class="code">Protocol</span></strong></dt>
	    <dd>
	      0 = tcp/ip-v4, ...
	    </dd>
	    <dt><strong><span class="code">HighestVersion</span></strong></dt>
	    <dd>
	      The highest distribution version that this node can handle.
	      The value in R6B and later is 5.
	    </dd>
	    <dt><strong><span class="code">LowestVersion</span></strong></dt>
	    <dd>
	      The lowest distribution version that this node can handle.
	      The value in R6B and later is 5.
	    </dd>
	    <dt><strong><span class="code">Nlen</span></strong></dt>
	    <dd>
	      The length of the <span class="code">NodeName</span>.
	    </dd>
	    <dt><strong><span class="code">NodeName</span></strong></dt>
	    <dd>
	      The NodeName as a string of length <span class="code">Nlen</span>.
	    </dd>
	    <dt><strong><span class="code">Elen</span></strong></dt>
	    <dd>
	      The length of the <span class="code">Extra</span> field.
	    </dd>
	    <dt><strong><span class="code">Extra</span></strong></dt>
	    <dd>
	      Extra field of <span class="code">Elen</span> bytes.
	    </dd>
	  </dl>
	<p>
	  The connection created to the EPMD must be kept as long as the
	  node is a distributed node. When the connection is closed
	  the node is automatically unregistered from the EPMD.
	</p>
	<p>
	  The response message ALIVE2_RESP is described below.
	</p>

	<table border="1" cellpadding="2" cellspacing="0">
<tr>
	    <td align="left" valign="middle">1</td>
	    <td align="left" valign="middle">1</td>
	    <td align="left" valign="middle">2</td>
	  </tr>
<tr>
	    <td align="left" valign="middle">121</td>
	    <td align="left" valign="middle">Result</td>
	    <td align="left" valign="middle">Creation</td>
	  </tr>
</table>
<em>Table
        9.3:
         
        ALIVE2_RESP (121)</em>
	<p>
	  Result = 0 -&gt; ok, Result &gt; 0 -&gt; error
	</p>
      

      <h4>Unregister a node from the EPMD</h4>
	
	<p>
	  A node unregisters itself from the EPMD by simply closing the
	  TCP connection towards EPMD established when the node was registered.
	</p>
      

      <h4>Get the distribution port of another node</h4>
	
	<p>
	  When one node wants to connect to another node it starts with
	  a PORT_PLEASE2_REQ request towards EPMD on the host where the 
	  node resides in order to get the distribution port that the node 
	  listens to.
	</p>

	<table border="1" cellpadding="2" cellspacing="0">
<tr>
	  <td align="left" valign="middle">1</td>
	  <td align="left" valign="middle">N</td>
	</tr>
<tr>
	  <td align="left" valign="middle">122</td>
	  <td align="left" valign="middle">NodeName</td>
	</tr>
</table>
<em>Table
        9.4:
         
        PORT_PLEASE2_REQ (122)</em>
      <p>
	where N = Length - 1
      </p>

      <p>
      </p>
      <table border="1" cellpadding="2" cellspacing="0">
<tr>
	  <td align="left" valign="middle">1</td>
	  <td align="left" valign="middle">1</td>
	</tr>
<tr>
	  <td align="left" valign="middle">119</td>
	  <td align="left" valign="middle">Result</td>
	</tr>
</table>
<em>Table
        9.5:
         
        
	  PORT2_RESP (119) response indicating error, Result &gt; 0.
	</em>
      <p>Or</p>
      <table border="1" cellpadding="2" cellspacing="0">
<tr>
	  <td align="left" valign="middle">1</td>
	  <td align="left" valign="middle">1</td>
	  <td align="left" valign="middle">2</td>
	  <td align="left" valign="middle">1</td>
	  <td align="left" valign="middle">1</td>
	  <td align="left" valign="middle">2</td>
	  <td align="left" valign="middle">2</td>
	  <td align="left" valign="middle">2</td>
	  <td align="left" valign="middle">Nlen</td>
	  <td align="left" valign="middle">2</td>
	  <td align="left" valign="middle">Elen</td>
	</tr>
<tr>
	  <td align="left" valign="middle">119</td>
	  <td align="left" valign="middle">Result</td>
	  <td align="left" valign="middle">PortNo</td>
	  <td align="left" valign="middle">NodeType</td>
	  <td align="left" valign="middle">Protocol</td>
	  <td align="left" valign="middle">HighestVersion</td>
	  <td align="left" valign="middle">LowestVersion</td>
	  <td align="left" valign="middle">Nlen</td>
	  <td align="left" valign="middle">NodeName</td>
	  <td align="left" valign="middle">Elen</td>
	  <td align="left" valign="middle">Extra</td>
	</tr>
</table>
<em>Table
        9.6:
         
        PORT2_RESP when Result = 0.</em>
<p>
If Result &gt; 0, the packet only consists of [119, Result].
</p>

        <p>EPMD will close the socket as soon as it has sent the information.</p>
      

      <h4>Get all registered names from EPMD</h4>
	
	<p>
	  This request is used via the Erlang function 
	  <span class="code">net_adm:names/1,2</span>. A TCP connection is opened
	  towards EPMD and this request is sent.
	</p>
	<table border="1" cellpadding="2" cellspacing="0">
<tr>
	    <td align="left" valign="middle">1</td>
	  </tr>
<tr>
	    <td align="left" valign="middle">110</td>
	  </tr>
</table>
<em>Table
        9.7:
         
        NAMES_REQ (110)</em>
	

	<p>The response for a <span class="code">NAMES_REQ</span> looks like this:</p>
	<table border="1" cellpadding="2" cellspacing="0">
<tr>
	    <td align="left" valign="middle">4</td>
	    <td align="left" valign="middle"> </td>
	  </tr>
<tr>
	    <td align="left" valign="middle">EPMDPortNo</td>
	    <td align="left" valign="middle">NodeInfo*</td>
	  </tr>
</table>
<em>Table
        9.8:
         
        NAMES_RESP</em>
	<p>
	  NodeInfo is a string written for each active node.
	  When all NodeInfo has been written the connection is
	  closed by EPMD.
	</p>
	<p>
	  NodeInfo is, as expressed in Erlang:
	</p>
	<div class="example"><pre>
	io:format("name ~s at port ~p~n", [NodeName, Port]).
	</pre></div>
      


      <h4>Dump all data from EPMD</h4>
	
	<p>
	  This request is not really used, it should be regarded as a debug
	  feature.
	</p>
	<table border="1" cellpadding="2" cellspacing="0">
<tr>
	  <td align="left" valign="middle">1</td>
	  </tr>
<tr>
	    <td align="left" valign="middle">100</td>
	  </tr>
</table>
<em>Table
        9.9:
         
        DUMP_REQ</em>

	<p>The response for a <span class="code">DUMP_REQ</span> looks like this:</p>
	<table border="1" cellpadding="2" cellspacing="0">
<tr>
	    <td align="left" valign="middle">4</td>
	    <td align="left" valign="middle"> </td>
	  </tr>
<tr>
	    <td align="left" valign="middle">EPMDPortNo</td>
	    <td align="left" valign="middle">NodeInfo*</td>
	  </tr>
</table>
<em>Table
        9.10:
         
        DUMP_RESP</em>
	<p>
	  NodeInfo is a string written for each node kept in EPMD.
	  When all NodeInfo has been written the connection is
	  closed by EPMD.
	</p>
	<p>
	  NodeInfo is, as expressed in Erlang:
	</p>
	<div class="example"><pre>
	io:format("active name     ~s at port ~p, fd = ~p ~n",
	          [NodeName, Port, Fd]).
	</pre></div>
	<p>
	  or
	</p>
	<div class="example"><pre>
	io:format("old/unused name ~s at port ~p, fd = ~p~n",
	          [NodeName, Port, Fd]).
	</pre></div>

      

      <h4>Kill the EPMD</h4>
	
	<p>
	  This request will kill the running EPMD. It is almost never used.
	</p>
	<table border="1" cellpadding="2" cellspacing="0">
<tr>
	  <td align="left" valign="middle">1</td>
	  </tr>
<tr>
	    <td align="left" valign="middle">107</td>
	  </tr>
</table>
<em>Table
        9.11:
         
        KILL_REQ</em>

	<p>The response fo a <span class="code">KILL_REQ</span> looks like this:</p>
	<table border="1" cellpadding="2" cellspacing="0">
<tr>
	    <td align="left" valign="middle">2</td>
	  </tr>
<tr>
	    <td align="left" valign="middle">OKString</td>
	  </tr>
</table>
<em>Table
        9.12:
         
        KILL_RESP</em>
	<p>
	  where <span class="code">OKString</span> is "OK".
	</p>
      

      <h4>STOP_REQ  (Not Used)</h4>
	
	<p></p>
	<table border="1" cellpadding="2" cellspacing="0">
<tr>
	    <td align="left" valign="middle">1</td>
	    <td align="left" valign="middle">n</td>
	  </tr>
<tr>
	    <td align="left" valign="middle">115</td>
	    <td align="left" valign="middle">NodeName</td>
	  </tr>
</table>
<em>Table
        9.13:
         
        STOP_REQ</em>
	<p>
	  where n = Length - 1
	</p>
	<p>
	  The current implementation of Erlang does not care if the connection
	  to the EPMD is broken.
	</p>
	<p>The response for a <span class="code">STOP_REQ</span> looks like this.</p>
	<table border="1" cellpadding="2" cellspacing="0">
<tr>
	    <td align="left" valign="middle">7</td>
	  </tr>
<tr>
	    <td align="left" valign="middle">OKString</td>
	  </tr>
</table>
<em>Table
        9.14:
         
        STOP_RESP</em>
	<p>
	  where OKString is "STOPPED".
	</p>
	<p>A negative response can look like this.</p>
	<table border="1" cellpadding="2" cellspacing="0">
<tr>
	    <td align="left" valign="middle">7</td>
	  </tr>
<tr>
	    <td align="left" valign="middle">NOKString</td>
	  </tr>
</table>
<em>Table
        9.15:
         
        STOP_NOTOK_RESP</em>
	<p>
	  where NOKString is "NOEXIST".
	</p>
      


    

      <h3><a name="id89383">9.2 
        Handshake</a></h3>
	
	<p>
	  The handshake is discussed in detail in the internal documentation for 
	  the kernel (Erlang) application.
	</p>
      

      <h3><a name="id89399">9.3 
        Protocol between connected nodes</a></h3>
        <a name="connected_nodes"></a>
	
	<p>
	  As of erts version 5.7.2 the runtime system passes a distribution
	  flag in the handshake stage that enables the use of a
	  <span class="bold_code"><a href="erl_ext_dist.html#distribution_header">distribution
	  header</a></span> on all messages passed. Messages passed between
	  nodes are in this case on the following format:
	</p>
	<table border="1" cellpadding="2" cellspacing="0">
<tr>
	    <td align="left" valign="middle">4</td>
	    <td align="left" valign="middle">d</td>
	    <td align="left" valign="middle">n</td>
	    <td align="left" valign="middle">m</td>
	  </tr>
<tr>
	    <td align="left" valign="middle"><span class="code">Length</span></td>
	    <td align="left" valign="middle"><span class="code">DistributionHeader</span></td>
	    <td align="left" valign="middle"><span class="code">ControlMessage</span></td>
	    <td align="left" valign="middle"><span class="code">Message</span></td>
	  </tr>
</table>
<em>Table
        9.16:
         
        </em>
	<p>
	  where:
	</p>
	<p>
	  <span class="code">Length</span> is equal to d + n + m
	</p>
	<p>
	  <span class="code">ControlMessage</span> is a tuple passed using the external format of
	  Erlang.
	</p>
	<p>
	  <span class="code">Message</span> is the message sent to another node using the '!'
	  (in external format). Note that <span class="code">Message</span> is only passed in
	  combination with a <span class="code">ControlMessage</span> encoding a send ('!').
	</p>
	<p>
	  Also note that <span class="bold_code"><a href="erl_ext_dist.html#overall_format">the
	  version number is omitted from the terms that follow a
	  distribution header</a></span>.
	</p>
	<p>
	  Nodes with an erts version less than 5.7.2 does not pass the
	  distribution flag that enables the distribution header. Messages
	  passed between nodes are in this case on the following format:
	</p>
	<table border="1" cellpadding="2" cellspacing="0">
<tr>
	    <td align="left" valign="middle">4</td>
	    <td align="left" valign="middle">1</td>
	    <td align="left" valign="middle">n</td>
	    <td align="left" valign="middle">m</td>
	  </tr>
<tr>
	    <td align="left" valign="middle"><span class="code">Length</span></td>
	    <td align="left" valign="middle"><span class="code">Type</span></td>
	    <td align="left" valign="middle"><span class="code">ControlMessage</span></td>
	    <td align="left" valign="middle"><span class="code">Message</span></td>
	  </tr>
</table>
<em>Table
        9.17:
         
        </em>
	<p>
	  where:
	</p>
	<p>
	  <span class="code">Length</span> is equal to 1 + n + m
  	</p>
	<p>
	  Type is: 112 (pass through)
	</p>
	<p>
	  <span class="code">ControlMessage</span> is a tuple passed using the external format of
	  Erlang.
	</p>
	<p>
	  <span class="code">Message</span> is the message sent to another node using the '!'
	  (in external format).  Note that <span class="code">Message</span> is only passed in
	  combination with a <span class="code">ControlMessage</span> encoding a send ('!').
	</p>
	<p>
	  The <span class="code">ControlMessage</span> is a tuple, where the first element
	  indicates which distributed operation it encodes.
	</p>
	<dl>
	  <dt><strong><span class="code">LINK</span></strong></dt>
	  <dd>
	    <p>
	      <span class="code">{1, FromPid, ToPid}</span>
	    </p>
	  </dd>
	  
	  <dt><strong><span class="code">SEND</span></strong></dt>
	  <dd>
	    <p>
	      <span class="code">{2, Cookie, ToPid}</span>
	    </p>
	    <p>
	    <strong>Note</strong> followed by <span class="code">Message</span>
	    </p>
	  </dd>

	  <dt><strong><span class="code">EXIT</span></strong></dt>
	  <dd>
	    <p>
	      <span class="code">{3, FromPid, ToPid, Reason}</span>
	    </p>
	  </dd>
	  
	  <dt><strong><span class="code">UNLINK</span></strong></dt>
	  <dd>
	    <p>
	      <span class="code">{4, FromPid, ToPid}</span>
	    </p>
	  </dd>
	  
	  <dt><strong><span class="code">NODE_LINK</span></strong></dt>
	  <dd>
	    <p>
	      <span class="code">{5}</span>
	    </p>
	  </dd>
	  
	  <dt><strong><span class="code">REG_SEND</span></strong></dt>
	  <dd>
	    <p>
	      <span class="code">{6, FromPid, Cookie, ToName}</span>
	    </p>
	    <p>
	    <strong>Note</strong> followed by <span class="code">Message</span>
	    </p>
	  </dd>

	  <dt><strong><span class="code">GROUP_LEADER</span></strong></dt>
	  <dd>
	    <p>
	      <span class="code">{7, FromPid, ToPid}</span>
	    </p>
	  </dd>
	
	  <dt><strong><span class="code">EXIT2</span></strong></dt>
	  <dd>
	    <p>
	      <span class="code">{8, FromPid, ToPid, Reason}</span>
	    </p>
	  </dd>
	</dl>
      

  
    <h3><a name="id89841">9.4 
        New Ctrlmessages for distrvsn = 1 (OTP R4)</a></h3>
      
      <dl>
	<dt><strong><span class="code">SEND_TT</span></strong></dt>
	<dd>
	<p>
	  <span class="code">{12, Cookie, ToPid, TraceToken}</span>
	</p>
	<p>
	<strong>Note</strong> followed by <span class="code">Message</span>
	</p>
	</dd>

	<dt><strong><span class="code">EXIT_TT</span></strong></dt>
	<dd>
	<p>
	  <span class="code">{13, FromPid, ToPid, TraceToken, Reason}</span>	  
	</p>
	</dd>
      
	<dt><strong><span class="code">REG_SEND_TT</span></strong></dt>
	<dd>
	<p>
	  <span class="code">{16, FromPid, Cookie, ToName, TraceToken}</span>
	</p>
	<p>
	<strong>Note</strong> followed by <span class="code">Message</span>
	</p>
	</dd>
      
	<dt><strong><span class="code">EXIT2_TT</span></strong></dt>
	<dd>
	<p>
	  <span class="code">{18, FromPid, ToPid, TraceToken, Reason}</span>
	</p>
	</dd>
      </dl>
    
    
    <h3><a name="id89939">9.5 
        New Ctrlmessages for distrvsn = 2</a></h3>
      
      <p>
	distrvsn 2 was never used.
      </p>
    
    
    <h3><a name="id89951">9.6 
        New Ctrlmessages for distrvsn = 3 (OTP R5C)</a></h3>
      
      <p>
	None, but the version number was increased anyway.
      </p>
    

    <h3><a name="id89963">9.7 
        New Ctrlmessages for distrvsn = 4 (OTP R6)</a></h3>
      
      <p>
	These are only recognized by Erlang nodes, not by hidden nodes.
      </p>
      <dl>
	<dt><strong><span class="code">MONITOR_P</span></strong></dt>
	<dd>
	<p>
	  <span class="code">{19, FromPid, ToProc, Ref}</span>
	  
	  <span class="code">FromPid</span> = monitoring process
	  <span class="code">ToProc</span> = monitored process pid or name (atom)
	</p>
	</dd>
      
	<dt><strong><span class="code">DEMONITOR_P</span></strong></dt>
	<dd>
	<p>
	  <span class="code">{20, FromPid, ToProc, Ref}</span>
	  We include the FromPid just in case we want to trace this.
	  
	  <span class="code">FromPid</span> = monitoring process
	  <span class="code">ToProc</span> = monitored process pid or name (atom)
	</p>
	</dd>

	<dt><strong><span class="code">MONITOR_P_EXIT</span></strong></dt>
	<dd>
	<p>
	  <span class="code">{21, FromProc, ToPid, Ref, Reason}</span>
	  
	  <span class="code">FromProc</span> = monitored process pid or name (atom)
	  <span class="code">ToPid</span> = monitoring process
	  <span class="code">Reason</span> = exit reason for the monitored process
	</p>
	</dd>
      </dl>
    
  </div>
<div class="footer">
<hr>
<p>Copyright © 1997-2012 Ericsson AB. All Rights Reserved.</p>
</div>
</div>
</div></body>
</html>