First, a super short intro on me: I've been an Apple II user since 2004, and I started learning 6502 assembly language in 2010, which not coincidentally is when I joined this forum.
My last project was a multitasking system called the
Mouse Multitasking Demo in 2014, and the project that I'm now working on this year is a TCP/IP stack called
Marina.
I don't do any cross-assembly, but instead do all programming and debugging on an Apple IIe using the Merlin Pro editor/assembler. (I will admit however that in the multitasking project, I did debug the ISR in an emulator, because I'd have been foolish not to!)
The Marina IP StackSo, on to the main subject! The Marina project is not even a year old; I started writing it February 1st this year, and the latest release was last month.
Marina is the newest TCP/IP stack for the Apple II series, written in 6502 assembly language only. Marina uses the Uthernet 10 Mb/s Ethernet card by
A2RetroSystems to connect to an Ethernet LAN. I'm also working on a driver for the new Uthernet II. With Marina, the Apple assembly language programmer has access to the UDP, DNS, ICMP, and IP protocols through a Berkeley sockets API. Written with performance in mind, the send throughput of Marina on a standard Apple II can reach 15 packets per second. The October 2015 edition of Marina adds Multicasting level 1 conformance and several improvements to the ARP and ICMP implementations.
Project GoalsI had two goals in mind for writing Marina:
1. To learn more about Ethernet and TCP/IP networking
2. To create a new TCP/IP stack for the Apple II that had more robust RFC compliance than the existing implementations
Interesting FeaturesMarina has several features not present in other TCP/IP implementations for the Apple II, including:
1. A Berkeley sockets API
2. An automatic DHCP client more compliant with RFC 2131.
3. An ARP implementation fully compliant with RFC 826.
4. A Link-Local addressing implementation following RFC 3927.
5. Address conflict detection implementation following RFC 5227.
6. Separate send buffers for the ARP, DHCP, and DNS modules.
7. A split-buffer design for sending user datagrams to eliminate copying blocks of data.
8. A more robust Ethernet driver that verifies each Ethernet frame has been successfully transmitted.
9. A special-case checksum routine optimized for 20 byte IP header checksums.
10. Robust error and consistency checks for incoming data.
11. Multicast level 1 conformance
DocumentationMarina is fairly well documented for a one-man project. There is a 6-page User's Manual which covers the basics, but there is also the
Marina Technical Library which contains several documents describing various aspects of the system, including algorithms, source code excerpts, and implementation notes.
The source code also is pretty well commented, though I am working my way through it and improving both the number of comments, and also the formatting of them to ensure that the source is more readable.
A technical overview of the whole system, layer by layer, is given in the document
Marina from the bottom up, which may be a bit dry, but it's all we've got, other than just
reading the source code!
Challenges in the DesignThe first challenge in the design of Marina is that the Apple II has no built-in clock or timer (except for the last model, the Apple IIgs). There isn't even a VBL interrupt on all models, and compatibility is something I want to keep for as long as I can. This will make implementing TCP retransmissions a little tricky, I think.
The second challenge is that some of the existing network interfaces don't support IRQ, meaning that I have to poll the device to see if there's new data from the network. If I don't poll fast enough, packets get dropped. Now I realize that with TCP, there will be retransmissions, but what about UDP datagrams? I'd like to avoid dropping packets as much as I can.
Testing the DNS resolver, June 2015: