| 1 |
<pre>Network Working Group W. Naylor |
| 2 |
Request for Comments #143 J. Wong |
| 3 |
NIC #6728 C. Kline |
| 4 |
Categories: D.1, D.3 J. Postel |
| 5 |
Obsoletes: None UCLA - NMC |
| 6 |
Updates: <a href="./rfc123">123</a>, <a href="./rfc145">145</a> 3 May 1971 |
| 7 |
|
| 8 |
<span class="h1">Regarding Proferred Official ICP</span> |
| 9 |
|
| 10 |
We should like to comment on a race condition discovered in the ICP as |
| 11 |
proposed in NWG/RFC #123. The problem arises when the server attempts |
| 12 |
to initiate a second connection to the user's receive socket and the |
| 13 |
first connection is not yet closed. Using a similar notation to that of |
| 14 |
NWG/RFC #123 the following table illustrates the sequence of events in |
| 15 |
the proferred and proposed ICP. The last two columns indicate which |
| 16 |
actions must be completed before the current action may be initiated. |
| 17 |
User and Server are third level programs, and UNCP and SNCP are the |
| 18 |
users NCP and Servers NCP respectively. Allocates have not been |
| 19 |
included since they add nothing to the argument. |
| 20 |
|
| 21 |
Required Predecessors |
| 22 |
--------------------- |
| 23 |
Reference # Action Initiator "Proferred" Proposed |
| 24 |
----------- ------ --------- ----------- -------- |
| 25 |
1 Listen(L,32) Server -- -- |
| 26 |
|
| 27 |
2 Init(U,L,32) User -- -- |
| 28 |
|
| 29 |
3 RTS(U,L,'l') UNCP 2 2 |
| 30 |
|
| 31 |
4 STR(L,U,32) SNCP 1 and 3 1 and 3 |
| 32 |
|
| 33 |
5 Send(L,S) Server 4 4 |
| 34 |
|
| 35 |
6 SEND('l',S) SNCP 5 5 |
| 36 |
|
| 37 |
7 RECEIVE('l',S) UNCP 6 6 |
| 38 |
|
| 39 |
8 Receive(U,S) User 7 7 |
| 40 |
|
| 41 |
9 Close(L) Server 5 5 |
| 42 |
|
| 43 |
10 CLS(L,U) SNCP 9 and 7 9 and 7 |
| 44 |
|
| 45 |
11 Close(U) User 8 not used |
| 46 |
|
| 47 |
12 CLS(U,L) UNCP 11 10 |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
<span class="grey"> [Page 1]</span></pre> |
| 53 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-2" ></span> |
| 54 |
<span class="grey">NWG Regarding Proferred Official ICP <a href="./rfc143">RFC 143</a></span> |
| 55 |
|
| 56 |
|
| 57 |
Required Predecessors |
| 58 |
--------------------- |
| 59 |
Reference # Action Initiator "Proferred" Proposed |
| 60 |
----------- ------ --------- ----------- -------- |
| 61 |
|
| 62 |
13 Init(S,U+1,B ) Server 9 9 |
| 63 |
u |
| 64 |
|
| 65 |
14 RTS(S,U+1,'l' ) SNCP 13 13 |
| 66 |
2 |
| 67 |
|
| 68 |
15 Init(S+1,U,B ) Server 13 14 and 18 |
| 69 |
s |
| 70 |
|
| 71 |
16 STR(S+1,U,B ) SNCP 15 15 |
| 72 |
s |
| 73 |
|
| 74 |
17 Init(U+1,S,B ) User 11 12 |
| 75 |
u |
| 76 |
|
| 77 |
18 STR(U+1,S,B ) UNCP 17 17 |
| 78 |
u |
| 79 |
|
| 80 |
19 Init(U,S+1,B ) User 17 17 |
| 81 |
s |
| 82 |
|
| 83 |
20 RTS(U,S+1,'l' ) UNCP 19 19 |
| 84 |
3 |
| 85 |
|
| 86 |
Note that in the Proferred Order column, 16 can occur before 12 in which |
| 87 |
case UNCP would find socket U in use and probably return a CLS (U,S+1). |
| 88 |
The Server would probably then assume the User was finished with the |
| 89 |
conversation. |
| 90 |
|
| 91 |
The above problem is resolved by eliminating the Close from one side and |
| 92 |
causing that side to wait for the CLS from the other side before doing |
| 93 |
an Init. We propose that eliminating the user's Close (U) is the best |
| 94 |
solution. (The user NCP must of course return a CLS in response to the |
| 95 |
CLS sent by the server NCP). |
| 96 |
|
| 97 |
The Server's Close (L) leads more quickly to the reuse of socket L thus |
| 98 |
the serving of another user. |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
<span class="grey"> [Page 2]</span></pre> |
| 109 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-3" ></span> |
| 110 |
<span class="grey">NWG Regarding Proferred Official ICP <a href="./rfc143">RFC 143</a></span> |
| 111 |
|
| 112 |
|
| 113 |
To clarify the above discussion which may seem confusing at first |
| 114 |
glance, let us demonstrate the problem in the language of RFC #123. |
| 115 |
|
| 116 |
Server User |
| 117 |
------ ---- |
| 118 |
(S1) Listen(L,32) (U1) Init(U,L,32) |
| 119 |
|
| 120 |
(S2) [Wait for match] (U2) |
| 121 |
|
| 122 |
(S3) Send(L,S) (U3) Receive(U,S) |
| 123 |
|
| 124 |
(S4) Close(L) (U4) Close(U) |
| 125 |
|
| 126 |
(S5) Init(S,U+1,B ) (U5) Init(U+1,S,B ) |
| 127 |
u u |
| 128 |
|
| 129 |
(S6) Init(S+1,U,B ) (U6) Init(U,S+1,B ) |
| 130 |
s s |
| 131 |
|
| 132 |
Notice that since server and user are independent (probably in different |
| 133 |
hosts), server could execute (S6) before user executes (U4) and could |
| 134 |
receive an error back from user's NCP that socket U is busy. Similarly, |
| 135 |
user could execute (U6) before server executes (S4) and could receive an |
| 136 |
error back from his own NCP that socket U is not yet closed (assuming an |
| 137 |
implementation where sockets are kept busy until a CLS match). |
| 138 |
|
| 139 |
Various modifications could be made to ICP to solve this problem. We |
| 140 |
propose the following ICP: |
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
<span class="grey"> [Page 3]</span></pre> |
| 165 |
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-4" ></span> |
| 166 |
<span class="grey">NWG Regarding Proferred Official ICP <a href="./rfc143">RFC 143</a></span> |
| 167 |
|
| 168 |
|
| 169 |
Server User |
| 170 |
------ ---- |
| 171 |
Listen(L,32) Init(U,L,32) |
| 172 |
|
| 173 |
[Wait for match] |
| 174 |
|
| 175 |
Send(L,S) Receive(U,S) |
| 176 |
|
| 177 |
Close(L) [Wait for CLS] |
| 178 |
|
| 179 |
Init(S,U+1,B ) Init(U+1,S,B ) |
| 180 |
u u |
| 181 |
|
| 182 |
[Wait for match] Init(U,S+1,B ) |
| 183 |
s |
| 184 |
|
| 185 |
Init(S+1,U,B ) |
| 186 |
s |
| 187 |
|
| 188 |
This ICP assumes the following: |
| 189 |
|
| 190 |
<span class="h2"><a class="selflink" id="section-1" href="#section-1">1</a>. The user can inquire or is notified of the fact that one of his</span> |
| 191 |
<span class="h2"> connections has been closed.</span> |
| 192 |
|
| 193 |
<span class="h2"><a class="selflink" id="section-2" href="#section-2">2</a>. The server can inquire or is notified that a connection for which</span> |
| 194 |
<span class="h2"> he has done an Init (or Listen) is now open.</span> |
| 195 |
|
| 196 |
Both of the above seem basic to any NCP - user interface. |
| 197 |
|
| 198 |
This race condition problem would not exist had the dynamic reconnection |
| 199 |
features of RFC #36 been included in the NCP protocol and had dynamic |
| 200 |
reconnection been used in this ICP. |
| 201 |
|
| 202 |
|
| 203 |
[ This RFC was put into machine readable form for entry ] |
| 204 |
[ into the online RFC archives by Walter Pienciak 1/98 ] |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
[Page 4] |
| 221 |
</pre> |