OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 5:28 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 41 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Bounty: TCP/IP stack for BareMetal OS
PostPosted: Tue Nov 29, 2011 1:13 pm 
Offline
Member
Member
User avatar

Joined: Mon Jul 28, 2008 9:46 am
Posts: 325
Location: Ontario, Canada
Hello everyone,

I have received a generous donation of $500 USD to add a TCP/IP stack to BareMetal OS. Unfortunately I do not have the time to complete this myself (or the required knowledge) so I would like to open this up to the community.

TCP handling is the only requirement at the moment (and perhaps some additional ARP work). BareMetal OS already has the ability to set an IP for itself and can respond to ARP and ICMP requests. The stack would need to be written in x86-64 Assembly just like the rest of the system. Some of the required framework is already in place.

If you are interested please send me a message. There is no timeline for this work to be completed but the sooner the better. If they are any questions please let me know.

Thanks,
Ian Seyler

_________________
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly


Top
 Profile  
 
 Post subject: Re: Bounty: TCP/IP stack for BareMetal OS
PostPosted: Wed Nov 30, 2011 6:45 am 
Offline
Member
Member

Joined: Thu Aug 11, 2011 12:04 am
Posts: 125
Location: Watching You
Why not just use uIP?

_________________
Get back to work!
Github


Top
 Profile  
 
 Post subject: Re: Bounty: TCP/IP stack for BareMetal OS
PostPosted: Wed Nov 30, 2011 12:21 pm 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 9:29 pm
Posts: 2426
Location: Canada
ACcurrent wrote:
Why not just use uIP?

The OP has indicated he wants something written in assembly, uIP/lwIP is written in C.

He probably shouldn't have accepted the donation if he didn't already have someone lined up to do the work, hopefully he plans on refunding them.

_________________
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.


Top
 Profile  
 
 Post subject: Re: Bounty: TCP/IP stack for BareMetal OS
PostPosted: Wed Nov 30, 2011 2:47 pm 
Offline
Member
Member
User avatar

Joined: Mon Jul 28, 2008 9:46 am
Posts: 325
Location: Ontario, Canada
It needs to be written in Assembly as the rest of the OS is in Assembly.

I would have thought it to be more important to get the funding before announcing the bounty. The money will be returned if there are no takers. Paypal stated that it could be refunded within 60 days without penalty.

Another thing to note is that the core functionality will need to translate to BSD sockets at the C/C++ application level. So functions like send, recv, accept, bind, listen, and connect will need to be implemented. UDP is not required at the moment. BareMetal OS already has functionality to send and receive raw Ethernet frames:
Code:
; os_ethernet_tx -- Transmit a packet via Ethernet
;  IN:   RSI = Memory location where data is stored
;   RDI = Pointer to 48 bit destination address
;    BX = Type of packet (If set to 0 then the EtherType will be set to the length of data)
;    CX = Length of data
; OUT:   Nothing. All registers preserved

The TCP handler would need split the data into Ethernet packets (as well as reassemble them) and handle the SYN/ACK communication.

I'm thinking of functions like:
os_tcp_open
os_tcp_close
os_tcp_send
os_tcp_recv
os_tcp_listen
os_tcp_accept

This should be a pretty good challenge and I'm interested to see what someone else can do. I wrote the incoming ICMP handler but TCP is a bit beyond me at the moment with all the handshakes and error correction.

Here is my ICMP code:
Code:
; -----------------------------------------------------------------------------
; os_icmp_handler -- Handle an incoming ICMP packet
;  IN:   RCX = packet length
;   RSI = location of received ICMP packet
os_icmp_handler:
   push rsi
   push rax

   ; Check if reply or request

   ; Swap the MAC addresses
   mov rax, [rsi]         ; Grab the Destination MAC as 8 bytes even though the MAC is 6 bytes
   mov ax, [rsi+0x0C]      ; Store the EtherType in the low 16-bits of RAX
   push rax         ; Save the new Source MAC (with EtherType) to the stack
   mov rax, [rsi+0x06]      ; Grab the Source MAC as 8 bytes (the last two bytes will be overwritten)
   mov [rsi], rax         ; Store the new Destination MAC in the packet
   pop rax            ; Restore the new Source MAC + EtherType
   mov [rsi+0x06], rax      ; Write it to the packet

   ; Swap the IP addresses
   mov eax, [rsi+0x1A]      ; Grab the Source IP
   push rax
   mov eax, [rsi+0x1E]      ; Grab the Destination IP
   mov dword [rsi+0x1A], eax   ; Overwrite the 'old' Source with the 'new' Source
   pop rax
   mov dword [rsi+0x1E], eax   ; Overwrite the 'old' Destination with the 'new' Destination

   ; Set to Echo Reply
   mov byte [rsi+0x22], 0x00   ; Set to 0 for Echo Reply (Was originally 8 for Echo Request)

   ; Adjust the checksum
   mov ax, [rsi+0x24]
   add ax, 8         ; Add 8 since we removed 8 (by clearing the Echo Request)
   mov word [rsi+0x24], ax

   call os_ethernet_tx_raw      ; Send the packet

   pop rax
   pop rsi
   ret
; -----------------------------------------------------------------------------


Best regards,
Ian Seyler

_________________
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly


Top
 Profile  
 
 Post subject: Re: Bounty: TCP/IP stack for BareMetal OS
PostPosted: Wed Dec 07, 2011 1:26 pm 
Offline
Member
Member

Joined: Mon Jul 18, 2011 9:47 am
Posts: 93
Why not just convert the stack from menuetOS or DexOS they are both open source.


Top
 Profile  
 
 Post subject: Re: Bounty: TCP/IP stack for BareMetal OS
PostPosted: Wed Dec 07, 2011 2:34 pm 
Offline
Member
Member
User avatar

Joined: Mon Jul 28, 2008 9:46 am
Posts: 325
Location: Ontario, Canada
That would be possible as well. It's up to whomever wants the bounty.

_________________
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly


Top
 Profile  
 
 Post subject: Re: Bounty: TCP/IP stack for BareMetal OS
PostPosted: Thu Dec 08, 2011 3:26 am 
Offline
Member
Member
User avatar

Joined: Tue Feb 08, 2011 1:58 pm
Posts: 496
ReturnInfinity wrote:
UDP is not required at the moment.

But TCP is, and TCP is build on top of UDP, ICMP and ARP.


Last edited by turdus on Thu Dec 08, 2011 3:29 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Bounty: TCP/IP stack for BareMetal OS
PostPosted: Thu Dec 08, 2011 3:29 am 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1070
Location: Germany
Not really. Both TCP and UDP are built on top of IP.

_________________
Developer of tyndur - community OS of Lowlevel (German)


Top
 Profile  
 
 Post subject: Re: Bounty: TCP/IP stack for BareMetal OS
PostPosted: Thu Dec 08, 2011 3:33 am 
Offline
Member
Member
User avatar

Joined: Tue Feb 08, 2011 1:58 pm
Posts: 496
Kevin wrote:
Not really. Both TCP and UDP are built on top of IP.

Read RFC793.
"TCP assumes it can obtain a simple,
potentially unreliable datagram service from the lower level
protocols."
and datagram service is...


Top
 Profile  
 
 Post subject: Re: Bounty: TCP/IP stack for BareMetal OS
PostPosted: Thu Dec 08, 2011 3:57 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
Kevin is correct; TCP and UDP are both on the transport layer and both work on top of IP. There's even a figure in the document that you've quoted, you should look at that.

I suggest reading TCP/IP Illustrated, Volume 1: The Protocols, 2nd ed. (yes, the classic has been finally updated).

_________________
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]


Top
 Profile  
 
 Post subject: Re: Bounty: TCP/IP stack for BareMetal OS
PostPosted: Thu Dec 08, 2011 4:17 am 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1070
Location: Germany
turdus wrote:
Read RFC793.

I have not only read the RFC, but also implemented something that resembles TCP close enough to make it work. And I did that long before I even started implementing UDP (the protocols using TCP are so much more interesting to have ;)).

_________________
Developer of tyndur - community OS of Lowlevel (German)


Top
 Profile  
 
 Post subject: Re: Bounty: TCP/IP stack for BareMetal OS
PostPosted: Thu Dec 08, 2011 7:33 am 
Offline
Member
Member
User avatar

Joined: Tue Feb 08, 2011 1:58 pm
Posts: 496
Let me put it this way:
you don't have to act on ip header field protocol number 17, but you've to write what's behind in order to handle ip protocol number 6.
Is this definition good enough for you?

The point is, you'll need to implement datagram service anyway, even if you don't want UDP. That's all I say.


Top
 Profile  
 
 Post subject: Re: Bounty: TCP/IP stack for BareMetal OS
PostPosted: Thu Dec 08, 2011 8:08 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
turdus wrote:
and datagram service is...
IPv4 or IPv6.

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: Bounty: TCP/IP stack for BareMetal OS
PostPosted: Thu Dec 08, 2011 9:43 am 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 9:29 pm
Posts: 2426
Location: Canada
turdus wrote:
But TCP is, and TCP is build on top of UDP, ICMP and ARP.

No.

TCP and UDP are independent protocols, you do not need to implement both, but you should for sake of completness.

I still say this bounty is rather absurd and poorly thought out, this supposed payout of $500 is hardly worth the effort of writing an entirely TCP/IP stack in assembly.. especially in the time allotted.

_________________
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.


Top
 Profile  
 
 Post subject: Re: Bounty: TCP/IP stack for BareMetal OS
PostPosted: Thu Dec 08, 2011 10:48 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
It's a donation, not a hired job. At least he's trying to give him his pennies worth, and if I wasn't epicly busy I would've done that it for that price (after all, someone else would need a stack too in due time).

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 41 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 93 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group