Setting up a TNFS Server - FujiNetWIFI/fujinet-firmware GitHub Wiki

Overview

One of FujiNet's core features is its ability to access system disk images from a TNFS server. We use a slightly updated version of the TNFSD server created for the Spectranet project. TNFS communicates over UDP Port 16384. Please see our fork of the project to build your own: https://github.com/FujiNetWIFI/tnfsd

This TNFS server now support TCP connections, and falls back to UDP if that fails.

The TNFSD code found in the project's tnfs/tnfsd directory has been built and tested with current versions of Linux and Windows (using MSYS2). It should also build on macOS and BSD derivatives, although only minimal testing has been done outside Linux and Windows.

The project has current builds of the 64-bit Linux ("tnfsd") and 64-bit Windows ("tnfsd.exe") binaries included in the tnfs/tnfsd/bin directory.

Recent builds for Linux/RasPi/Mac/Windows can also be found on the FujiNet.online Download Page.

FujiNet has been tested accessing a TNFS server both on a local network and across the internet.

Setting up TNFS on Raspberry Pi or Linux

Easy

Steve Boswell (@a8bit) has produced a pre-made Raspberry Pi image, which automatically sets up a TNFS server. Simply follow the instructions here: https://atari8bit.net/projects/software/fujinet-tnfs-server-image/

Advanced

  • Install raspbian lite
  • Run raspi-config
  • Set your hostname.
  • Set gpu memory to 16MB
  • Enable SSH if wanted
  • Set locale/timezone
  • Enable/set WiFi in raspi-config if needed.
  • exit raspi-config
  • sudo -i
  • apt-get install git
  • apt-get install samba samba-common-bin
  • git clone https://github.com/FujiNetWIFI/spectranet.git
  • cd spectranet
  • cd tnfs/tnfsd
  • make OS=LINUX DEBUG=Y
  • sudo cp bin/tnfsd /usr/local/sbin
  • useradd -m tnfs
  • mkdir -p /tnfs
  • chown tnfs:tnfs /tnfs
  • create file /etc/systemd/system/tnfsd.service and add into it:
[Unit]
Description=TNFS Server
After=remote-fs.target
After=syslog.target

[Service]
User=tnfs
Group=tnfs
ExecStart=/usr/local/sbin/tnfsd /tnfs

[Install]
WantedBy=multi-user.target
  • edit /etc/samba/smb.conf and add to bottom:
[tnfs]
        path = /tnfs
        writeable = Yes
        create mask = 0777
        directory mask = 0777
        public = yes
        force user = tnfs
        force group = tnfs
  • systemctl daemon-reload
  • systemctl enable tnfsd
  • systemctl start tnfsd
  • systemctl restart smbd
  • verify that you can access the share on your tnfs from the desired hostname

Setting Up TNFS On Windows 10

Give your Windows 10 PC a machine name, static IP address, and other values appropriate for your network. Typically a private home network will be in the “192.168.x.x” range, but there are other private ranges as well.

Download the pre-compiled binary FujiNet version of the TNFSD server.
https://fujinet.online/download

(Optional) Note that you can find the custom FujiNet tnfsd source code on Github if you want to build it yourself (and customize it). https://github.com/FujiNetWIFI/spectranet/tree/master/tnfs/tnfsd

Create a folder on the Windows 10 box named “C:\tnfsd”. Put the downloaded tnfsd.exe file in this folder. This is the server software.

Create a folder on the Windows 10 box named “C:\tnfsroot”. This is where you would put subfolders and Atari 8-bit disk images, etc.

On the Windows 10 box, right click Start. Click Search and enter “Firewall”. Click on “Allow an app through firewall”. Click on “Change settings”, then click on “Allow another app…”. Click “Browse…” and browse to the “C:\tnfsd\tnfsd.exe” file and click “Open”, then click “Add”. Next to the newly added “tnfsd.exe” app, check both the “Private” and “Public” checkboxes.

Right click Start, then click Computer Management. Click Task Scheduler. Click Create a Basic Task. Name it “TNFSD”. Set the trigger to “When the computer starts”. Set the action to “Start a program”. Browse to the “C:\tnfsd\tnfsd.exe” file and give it an argument of “C:\tnfsroot”. Check “Open the Properties dialog for this task when I click Finish”. When the properties open, select “Run whether user is logged on or not”, and “Run with highest privileges”. Click “Ok”. Reboot.

At this point, the TNFS server should be set up for your internal network. You should be able to enter the IP address of the TNFS server into the Fujinet and be able to browse and load files from the “C:\tnfsroot” folder that exist on the Windows 10 PC.

Once you have your TNFS server working, lock it down. Create a new user that has read only access to the tnfsroot folder, then make that new user the user account that runs the task created above and uncheck "Run with highest privileges".

Setting Up TNFS On macOS

Your Mac likely already has a machine name. You will find it in System Settings under General/Sharing. At the bottom of the list, you will see a local hostname. Note that name because you will want to use it from Fujinet. You should set up a static IP address for your Mac. The instructions for that will vary depending on your router. Typically a private home network will be in the “192.168.x.x” range, but there are other private ranges as well.

Download the pre-compiled binary FujiNet version of the TNFSD server.
https://fujinet.online/download

You will need to know if you have an Intel or Apple Silicon (M series Mac) so you download the correct version of tnfsd for your Mac.

(Optional) Note that you can find the custom FujiNet tnfsd source code on Github if you want to build it yourself (and customize it). https://github.com/FujiNetWIFI/spectranet/tree/master/tnfs/tnfsd. In order to do this on your Mac, you will need the Xcode development environment available at the Mac App Store. You will need to install the Xcode command-line tools. After the command-line tools are installed, simply go to ("cd") to the tnfsd directory from the source archive you downloaded and expanded by double-clicking on the zip file. The correct command to compile tnfsd for the Mac is "make OS=BSD" (no quotation marks) from the Terminal prompt.

Create a folder on your Mac where the tnfsd executable should go. With a recent Mac, you will likely create a directory under "/opt". You will probably need to use "sudo" in order to create the new directory. You could create a directory called "/opt/local" where tnfsd resides. Copy the downloaded tnfsd.m1mac file to this folder. You will probably need to use "sudo" again to copy tnfsd to the directory you created. This is the server software. If you are not as comfortable with the Command prompt, you can copy the file to somewhere in your /Users (home) directory.

Create a folder on your Mac named “/Users/(your username)/tnfsroot”. This is where you would put subfolders and Atari 8-bit disk images, etc. If you already have a folder on your Mac that contains your Atari 8-bit ATR, XEX, and CAR files, you can point tnfsd to that folder. For instance, you could have saved your Atari 8-bit files in "/Users/(your username)/Documents/AtariFiles". To make setting up the tnfsd server easier, it is better not to have spaces in your folder names.

To allow the tnfsd server to run whenever you start your Mac and log into your user account, you will need to create a plist file in "/Users/(your username)/Library/LaunchAgents". The plist file needs to be created in an editor that can save a text file (not RTF, Word, or any other format). Important: do NOT use TextEdit to create the plist file. It does not have the ability to save a simple text file. If you are comfortable with Unix, vi is built into macOS so you can use it to create the file. If you prefer a friendlier editor, Bare Bones Software (https://www.barebones.com) allows you to download BBEdit for free. If you want all of the functionality, you will have to pay to upgrade it. However, for this purpose, the free version is all you need.

This is the format of the plist file you will need to create:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
        <dict>
                <key>Label</key>
                <string>com.bobc.tnfsd</string>
                <key>ProgramArguments</key>
                <array>
                <string>/opt/local/tnfsd</string>
                <string>/Users/bobc/Documents/Altirra</string>
                </array>
                <key>RunAtLoad</key>
                <true/>
        </dict>
</plist>

In this example, bobc is the username. Plist files are normally named with a standard of com.(developer).(program).plist. /opt/local/tnfsd is the location where tnfsd was copied. /Users/bobc/Documents/Altirra is where the Atari 8-bit files are stored. In this case, the file is called com.bobc.tnfsd.plist. Make sure to save your file in /Users/(your username)/Library/LaunchAgents". At this point, you should see the tnfsd file in your login items on your Mac. You can find your login items in System Settings/General/Login Items. From my experience, shortcuts like "~/Documents/Altirra" do not work with tnfsd. The pathname needed to be completely spelled out in order to work.

The easiest way to test your new Launch Agent is to reboot your Mac. Once the Mac is rebooted, you can see that your tnfsd server is running by running Activity Monitor (in the /Applications/Utilities folder) and searching for tnfsd. If you put the plist file in /Users/(your username)/Library/LaunchAgents, you will need to log onto the Mac as that user. If you want to have tnfsd start up regardless of which user is logged in, you will need to put the plist file in /Library/LaunchAgents. The tnfsd server will run with the permissions of your user.

Depending on where you put your Atari 8-bit files, your Mac may ask you for permission to access that folder from tnfsd on the first time you try to access it from Fujinet. Therefore, you will want to be able to answer the question on your Mac so that Fujinet can access files using the TNFS server.

Since your Mac likely will go to sleep, you may wish to disable sleep to allow Fujinet to always access your TNFS server. Otherwise, you will need to press a key to wake up your Mac in order for the Fujinet to be able to access the server. If you wish to disable sleep on your Mac, the command to do this is: "sudo pmset -a disablesleep 1" (no quotation marks).

Allow TNFS Access to the World

To make your TNFS server available on the public internet, on your router, configure “Port Forwarding” for UDP 16384 to the IP address of the local TNFS host machine. If you have a domain name and it is configured to point to your external IP address, you should be good. If you do not have a domain name registered and configured, use https://whatismyipaddress.com/ to get your external IP address. To test from an external Fujinet device, enter either your domain name or external IP address into an external Fujinet and try to browse/load files from your TNFS server.

TCP on TNFS

Q&A

I have what is hopefully a simple question. I have upgraded to the 1.3 firmware and compiled the latest tnfsd. My tnfsd server is not available outside of my network. Here are my two questions:

  1. Do I need to do anything to have tnfsd use TCP connections?
  2. Will connecting via TCP allow me to turn back on the sleep mode on my Mac? Even if you run Windows or Linux, I assume the same situation applies.

Re: question 1 - in the 1.3 firmware the TCP for CONFIG is activated by default, if only the server supports it (and the newest version of the tnfsd does).

If TCP is not supported by the tnfsd server (or e.g.: the TCP 16384 port is blocked by firewall), firmware 1.3 will fallback to UDP. You can also force using TCP (and disable UDP fallback) by adding _tcp. prefix to the hostname, e.g.: _tcp.192.168.1.12. However adding this prefix usually is not required. This is only useful if you want to make sure that it's the TCP protocol which is used, not UDP.

Also: tnfsd logs every new TCP connection, so you can confirm which protocol is used by watching the server output.

TNFS Python Client

Can the tnfs python script be adapted (or maybe it just does it) to work with tcp vs udp, then you can have accurate timings of the same resource from the same site from both protocols so you're comparing apples with apples?

Already done 🙂

It'll behave similarly to Fujinet, so it'll try to autodetect TCP/UDP. Also, --tcp and --udp switches can be used to force using a specific protocol.

https://github.com/FujiNetWIFI/spectranet-tnfs-fuse

Sample Usage:

python3 tnfs_client3.py tnfs.fujinet.online
⚠️ **GitHub.com Fallback** ⚠️