Main Site Documentation

NetBIOS Name Service class


#1

I’ve just posted my NetBIOS Name Service class on fezzer.

Stop pinging and connecting to your FEZ’s IP addres and start using a real network name :wink:

All I’m asking is to credit my work if you’re using it in your project.


#2

Awesome, thanks for the post!


#3

Can you please amend your code whit a license? Apache 2 is ideal if you do not mind.


#4

@ Gus: Done


#5

Sweet! This is going right onto my fez …

So this will work with anything on the PC?

Like
ping FEZCOBRA
and
telnet FEZCOBRA
?
I am assuming browsers too?

What about using a specific port? Can I use this in a browser for port 123?
FEZCOBRA:123


#6

You could also just use IP’s “…/etc/hosts” file (and/or dns or Wins server) and not have another network stack running on the fez.

Sample contents

\windows\system32\drivers\etc\hosts

10.0.0.2 MyFez1
10.0.0.3 MyOtherFez
127.0.0.1 localhost


#7

Not ideal. Let us say someone makes a product with FEZ and that product is networked connected. Now you can get toe the product by knowing the IP address but then how sweet it would be if you can just use the name.

With DHCP, you do not know the IP easily.


#8

You can if you are also using WINS server on the network. The DHCP lease can instruct the dhcp client to register with WINS. DNS server can then query the WINS server - a form of dynamic dns. So you can query client names from netbios or dns clients. Naturally more useful if IP device count starts getting over some number (i.e. >~5).


#9

Hi!

Wouter, your code works like a charm with my FEZ Spider!

I have a question for you. I’m developing a library for FEZ Spider and .NET Gadgeteer, called .NET Gadgeteer Toolkit. This library is open source, with Apache 2.0 license, and will be released on CodePlex, http://gadgeteertoolkit.codeplex.com. At this moment, the project isn’t published yet, but I think it will be online during the next week. So, I would like to know if I can add your Name Service class in the library, obviously with the credit to you for this portion of code.

What do you think about this idea?

Thanks in advance for the attention.
Regards.


#10

@ Marco: as long as you credit me and add the hyperlink to the original page on code.tinyclr.com, I’m fine with that!


#11

Perfect!

Thanks again for your support!


#12

@ Wouter This is excellent code!

I would like all my FEZs to appear in their own Windows Group. Can I use this service to add a new Group name as well as a new Host name to a Windows network?

Thanks.


#13

It should be possible by playing with the NameType and MsSuffix flags. I never tried it.

You can see MsSuffix and NameType from your own Windows device with this method:

  1. run > “cmd”
  2. “ipconfig” (write down your own IP)
  3. "nbtstat -a "

You should get a list of all names registered on your device.


#14

Thanks @ Wouter. I’ll give it a try when I get home tonight.


#15

@ Wouter
I added two unique names and one group name to the FEZ Cobra (see image).
This image also shows the groups on my local computer.
However, the FEZ Cobra still does not show up in the My Network Places under HOMEGROUP.


#16

There might be some additional broadcast methods the code needs to respond too. I’ll have to check that. I’ll be back 8)


#17

Thanks @ Wouter.
I thought that might be the case, and I was going to read the RFC some more, but I was too tired last night :slight_smile:

I also noticed that one PC on my LAN had a group called “–_MSBROWSE” with a Suffix of 0x01. That must be the master browser, correct?


#18

I tried a lot, even used workarounds detailed here: http://www.cifs.org/wiki/IETF_STD_19_(NBT)_Bugs

But didn’t get the FEZ appear in the network list of windows. I think windows is checking some other protocols before deciding to show a device in that list…

I welcome everyone that can help a hand here :slight_smile:


#19

I have uploaded modified source code to http://code.tinyclr.com/project/244/name-service---give-your-fez-a-real-network-name/

Note that I also have changed the licensing from Apache 2.0 to GNU 3.

I was experimenting with this setup:


nameService = new NameService();
nameService.AddName("FEZCOBRA", NameService.NameType.Unique, NameService.MsSuffix.Default);
nameService.AddName("FEZCOBRA", NameService.NameType.Unique, NameService.MsSuffix.FileServerService);
nameService.AddName("HOME", NameService.NameType.Group, NameService.MsSuffix.Default);
nameService.AddName("HOME", NameService.NameType.Group, NameService.MsSuffix.MasterBrowserUnique);
nameService.AddName("HOME", NameService.NameType.Group, NameService.MsSuffix.BrowserServiceElections);


#20

I tried a similar setup with these name requests:


nameService.AddName("HOMEGROUP", NameService.NameType.Group, NameService.MsSuffix.Default);
nameService.AddName("FEZCOBRA", NameService.NameType.Unique, NameService.MsSuffix.Default);
nameService.AddName("FEZCOBRA", NameService.NameType.Unique, NameService.MsSuffix.FileServerService);

I ran this utility nbtscan.exe found at http://www.unixwiz.net/tools/nbtscan.html, and got these results:

C:\Documents and Settings\Jim>nbtscan -f 192.168.1.0-200
192.168.1.4 HOMEGROUP\OFFICEPC SHARING
OFFICEPC <00> UNIQUE Workstation Service
OFFICEPC <20> UNIQUE File Server Service
HOMEGROUP <00> GROUP Domain Name
00:30:1b:bc:ce:25 ETHER OfficePC.home

192.168.1.8 HOMEGROUP\HNSERVER1 SHARING
HNSERVER1 <00> UNIQUE Workstation Service
HOMEGROUP <00> GROUP Domain Name
HNSERVER1 <20> UNIQUE File Server Service
HOMEGROUP <1e> GROUP Browser Service Elections
HOMEGROUP <1d> UNIQUE Master Browser
MSBROWSE.<01> GROUP Master Browser
70:71:bc:9a:90:66 ETHER HNServer1.home

192.168.1.6 HOMEGROUP\NETBOOKPC SHARING
NETBOOKPC <00> UNIQUE Workstation Service
HOMEGROUP <00> GROUP Domain Name
NETBOOKPC <20> UNIQUE File Server Service
HOMEGROUP <1e> GROUP Browser Service Elections
00:1e:64:20:83:72 ETHER NetbookPC.home

192.168.1.200 HOMEGROUP\FEZCOBRA SHARING
HOMEGROUP <00> GROUP Domain Name
FEZCOBRA <00> UNIQUE Workstation Service
FEZCOBRA <20> UNIQUE File Server Service
00:1a:f1:00:42:0d ETHER HOMEGROUP

Notice that this utility thinks the FEZCOBRA is in HOMEGROUP, and also the name registrations for FEZCOBRA look very similar to the registrations by OFFICEPC (the computer I’m using right now).

Based on this, I agree with you that the configuration is correct, but that there is either some other NetBIOS message that needs to be handled, or that Windows computers are running some other protocol that enables the computers to show up in My Network Places.

RFC 1001 defines this Name Query process:

15.3.1. QUERY BY B NODES

Name query is generally, but not necessarily, a prelude to NetBIOS
session establishment or NetBIOS datagram transmission. However,
name query may be used for other purposes.

A B node may elect to build a group membership list for subsequent
use (e.g. for session establishment) by collecting and saving the
responses.

And also this group membership process:

15.3.4. ACQUIRE GROUP MEMBERSHIP LIST

The entire membership of a group may be acquired by sending a NAME
QUERY REQUEST to the NBNS. The NBNS will respond with a POSITIVE
NAME QUERY RESPONSE or a NEGATIVE NAME QUERY RESPONSE. A negative
response completes the procedure and indicates that there are no
members in the group.

If the positive response has the truncation bit clear, then the
response contains the entire list of group members. If the
truncation bit is set, then this entire procedure must be repeated,
but using TCP as a foundation rather than UDP.