* build datagram service UDP packet;
*/
convert source and destination NetBIOS names into
half-ASCII, biased encoded name;
SOURCE_NAME = cat(source, SCOPE_ID);
SOURCE_IP = this nodes IP address;
SOURCE_PORT = DGM_SRVC_UDP_PORT;
IF NetBIOS broadcast THEN
BEGIN
DESTINATION_NAME = cat("*", SCOPE_ID)
END
ELSE
BEGIN
DESTINATION_NAME = cat(destination, SCOPE_ID)
END
MSG_TYPE = select_one_from_set
{BROADCAST, DIRECT_UNIQUE, DIRECT_GROUP}
DGM_ID = next transaction id for Datagrams;
DGM_LENGTH = length of data + length of second level encoded
source and destination names;
IF (length of the NetBIOS Datagram, including UDP and
IP headers, > MAX_DATAGRAM_LENGTH) THEN
BEGIN
/*
* fragment NetBIOS datagram into 2 UDP packets
*/
Put names into 1st UDP packet and any data that fits
after names;
Set MORE and FIRST bits in 1st UDP packet's FLAGS;
OFFSET in 1st UDP = 0;
Replicate NetBIOS Datagram header from 1st UDP packet
into 2nd UDP packet;
Put rest of data in 2nd UDP packet;
Clear MORE and FIRST bits in 2nd UDP packet's FLAGS;
OFFSET in 2nd UDP = DGM_LENGTH - number of name and
data bytes in 1st UDP;
END
BEGIN
/*
* Only need one UDP packet
*/
USER_DATA = data;
Clear MORE bit and set FIRST bit in FLAGS;
OFFSET = 0;
END
IF (group == TRUE) OR (NetBIOS broadcast) THEN
BEGIN
/*
* Sending of following query is optional.
* Node may send datagram to NBDD immediately
* but NBDD may discard the datagram.
*/
send DATAGRAM QUERY REQUEST to NBDD;
IF response is POSITIVE QUERY RESPONSE THEN
send UDP packet(s) to NBDD Server IP address;
ELSE
BEGIN
get list of destination nodes from NBNS;
FOR EACH node in list
BEGIN
send UDP packet(s) to this node's
IP address;
END
END
END
ELSE
BEGIN
send UDP packet(s) to IP address returned by name
discovery;
END /* procedure */
5.3.3. RECEPTION OF NetBIOS DATAGRAMS BY ALL NODES
The following algorithm discards out of order NetBIOS Datagram
fragments. An implementation which reassembles out of order
NetBIOS Datagram fragments conforms to this specification. The
fragment discard timer is initialized to the value FRAGMENT_TO.
This value should be user configurable. The default value is
given in Section 6, "Defined Constants and Variables".
PROCEDURE datagram_packet(packet)
/*
* processing initiated by datagram packet reception
* on B, P and M nodes
*/
BEGIN
/*
* if this node is a P node, ignore
* broadcast packets.
*/
IF this is a P node AND incoming packet is
a broadcast packet THEN
BEGIN
discard packet;
END
CASE packet type OF
DATAGRAM SERVICE:
BEGIN
IF FIRST bit in FLAGS is set THEN
BEGIN
IF MORE bit in FLAGS is set THEN
BEGIN
Save 1st UDP packet of the Datagram;
Set this Datagram's fragment discard
timer to FRAGMENT_TO;
return;
END
ELSE
Datagram is composed of a single
UDP packet;
END
ELSE
BEGIN
/* Have the second fragment of a Datagram */
Search for 1st fragment by source IP address
and DGM_ID;
IF found 1st fragment THEN
Process both UDP packets;
ELSE
BEGIN
discard 2nd fragment UDP packet;
return;
END
END
IF DESTINATION_NAME is '*' THEN
BEGIN
/* NetBIOS broadcast */
deliver USER_DATA from UDP packet(s) to all
outstanding receive broadcast
datagram requests;
return;
END
ELSE
BEGIN /* non-broadcast */
/* Datagram for Unique or Group Name */
IF DESTINATION_NAME is not present in the
local name table THEN
BEGIN
/* destination not present */
build DATAGRAM ERROR packet, clear
FIRST and MORE bit, put in
this nodes IP and PORT, set
ERROR_CODE;
send DATAGRAM ERROR packet to
source IP address and port
of UDP;
discard UDP packet(s);
return;
END
ELSE
BEGIN /* good */
/*
* Replicate received NetBIOS datagram for
* each recipient
*/
FOR EACH pending NetBIOS user's receive
datagram operation
BEGIN
IF source name of operation
matches destination name
of packet THEN
BEGIN
deliver USER_DATA from UDP
packet(s);
END
END /* for each */
return;
END /* good */
END /* non-broadcast */
END /* datagram service */
DATAGRAM ERROR:
BEGIN
/*
* name service returned incorrect information
*/
inform local name service that incorrect
information was provided;
IF this is a P or M node THEN
BEGIN
/*
* tell NetBIOS Name Server that it may
* have given incorrect information
*/
send NAME RELEASE REQUEST with name
and incorrect IP address to NetBIOS
Name Server;
END
END /* datagram error */
END /* case */
END
5.3.4. PROTOCOLS FOR THE NBDD
The key to NetBIOS Datagram forwarding service is the packet
delivered to the destination end node must have the same NetBIOS
header as if the source end node sent the packet directly to the
destination end node. Consequently, the NBDD does not reassemble
NetBIOS Datagrams. It forwards the UDP packet as is.
PROCEDURE datagram_packet(packet)
/*
* processing initiated by a incoming datagram service
* packet on a NBDD node.
*/
BEGIN
CASE packet type OF
DATAGRAM SERVICE:
BEGIN
IF packet was sent as a directed
NetBIOS datagram THEN
BEGIN
/*
* provide group forwarding service
*
* Forward datagram to each member of the
* group. Can forward via:
* 1) get list of group members and send
* the DATAGRAM SERVICE packet unicast
* to each
* 2) use Group Multicast, if available
* 3) combination of 1) and 2)
*/
...
END
ELSE
BEGIN
/*
* provide broadcast forwarding service
*
* Forward datagram to every node in the
* NetBIOS scope. Can forward via:
* 1) get list of group members and send
* the DATAGRAM SERVICE packet unicast
* to each
* 2) use Group Multicast, if available
* 3) combination of 1) and 2)
*/
...
END
END /* datagram service */
DATAGRAM ERROR:
BEGIN
/*
* Should never receive these because Datagrams
* forwarded have source end node IP address and
* port in NetBIOS header.
*/
send DELETE NAME REQUEST with incorrect name and
IP address to NetBIOS Name Server;
END /* datagram error */
DATAGRAM QUERY REQUEST:
BEGIN
IF can send packet to DESTINATION_NAME THEN
BEGIN
/*
* NBDD is able to relay Datagrams for
* this name
*/
send POSITIVE DATAGRAM QUERY RESPONSE to
REQUEST source IP address and UDP port
with request's DGM_ID;
END
ELSE
BEGIN
/*
* NBDD is NOT able to relay Datagrams for
* this name
*/
send NEGATIVE DATAGRAM QUERY RESPONSE to
REQUEST source IP address and UDP port
with request's DGM_ID;
END
END /* datagram query request */
END /* case */
END /* procedure */
6. DEFINED CONSTANTS AND VARIABLES
GENERAL:
SCOPE_ID The name of the NetBIOS scope.
This is expressed as a character
string meeting the requirements of
the domain name system and without
a leading or trailing "dot".
An implementation may elect to make
this a single global value for the
node or allow it to be specified
with each separate NetBIOS name
(thus permitting cross-scope
references.)
BROADCAST_ADDRESS An IP address composed of the
nodes's network and subnetwork
numbers with all remaining bits set
to one.
I.e. "Specific subnet" broadcast
addressing according to section 2.3
of RFC950.
BCAST_REQ_RETRY_TIMEOUT 250 milliseconds.
An adaptive timer may be used.
BCAST_REQ_RETRY_COUNT 3
UCAST_REQ_RETRY_TIMEOUT 5 seconds
An adaptive timer may be used.
UCAST_REQ_RETRY_COUNT 3
MAX_DATAGRAM_LENGTH 576 bytes (default)
NAME SERVICE:
REFRESH_TIMER Negotiated with NBNS for each name.
CONFLICT_TIMER 1 second
Implementations may chose a longer
value.
NAME_SERVICE_TCP_PORT 137 (decimal)
NAME_SERVICE_UDP_PORT 137 (decimal)
INFINITE_TTL 0
SESSION SERVICE:
SSN_SRVC_TCP_PORT 139 (decimal)
SSN_RETRY_COUNT 4 (default)
Re-configurable by user.
SSN_CLOSE_TIMEOUT 30 seconds (default)
Re-configurable by user.
SSN_KEEP_ALIVE_TIMEOUT 60 seconds, recommended, may be set to
a higher value.
(Session keep-alives are used only
if configured.)
DATAGRAM SERVICE:
DGM_SRVC_UDP_PORT 138 (decimal)
FRAGMENT_TO 2 seconds (default)
REFERENCES
[1] "Protocol Standard For a NetBIOS Service on a TCP/UDP
Transport: Concepts and Methods", RFC1001, March 1987.
[2] J. Reynolds, J. Postel, "Assigned Numbers", RFC990, November
1986.
[3] P. Mockapetris, "Domain Names - Implementation and
Specification", RFC883, November 1983.