Page 1 of 1

UDP Working!

Posted: Fri Sep 19, 2008 7:07 pm
by pcmattman
Hi everyone,

Just posting to show that I now have UDP working. This means I now start coding TCP into my system, after which I'll be even more excited :P

The code that runs to send the UDP packet to my (homemade) UDP server is as simple as:

Code: Select all

	Network::Udp::Send(
		0,
		"Hello world from NetStack - the OS I wrote to learn how to write a network stack!",
		strlen("Hello world from NetStack - the OS I wrote to learn how to write a network stack!") + 1,
		inetAddress(192, 168, 1, 110),
		12345
	);
In my system each protocol sits under the Network namespace, and provides an interface of at least "Receive" (which handles incoming packets). Functionality for sending packets is optional, and if it is implemented must use the other Network objects to create and send the packet.

As an example, things like ARP requests are abstracted by Network::Arp in order to provide an easy way to get MACs for IPs. Network::Arp::Receive is called by Ethernet::Receive (which is called by the driver) when the system finds that the Ethernet packet specifies ARP.

You can see a screenshot here: http://www.wikiforall.net/net_stack_udp.jpg (wide image so I'm not embedding it).

Now, I'm off to implement TCP :D

Re: UDP Working!

Posted: Fri Sep 19, 2008 9:36 pm
by 01000101
awesome!
implementing network protocols is always exciting.

have you implemented checksumming? or have you left that out due to UDP not requiring it?
Also, have you tested this on real hardware or through BOCHS ne2k emulation only?

Re: UDP Working!

Posted: Fri Sep 19, 2008 9:48 pm
by pcmattman
I use full checksumming (even though it's optional, it's useful for sending outside of the local network).

Unfortunately I've only tested on Bochs' emulation so far, although I do have an NE2K lying around ready for me to get around to finding a spare testbed system.