Bounty: TCP/IP stack for BareMetal OS

This forums is for OS project announcements including project openings, new releases, update notices, test requests, and job openings (both paying and volunteer).
guyfawkes
Member
Member
Posts: 93
Joined: Mon Jul 18, 2011 9:47 am

Re: Bounty: TCP/IP stack for BareMetal OS

Post by guyfawkes »

Combuster wrote: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).
I agree, for example you may not have the right Ethernet card and need to buy one etc.
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: Bounty: TCP/IP stack for BareMetal OS

Post by turdus »

Brynet-Inc wrote:
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.
No, not only for completeness. As I wrote: "The point is, you'll need to implement datagram service anyway, even if you don't want UDP. That's all I say."
Brynet-Inc wrote: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.
Agreed.

For the OP:
From another thread, there was a link to a promo video of generating primes (ca. 10000 primes in 10 secs on a 1.5GHz). You are doing it wrong.

Seriously ReturnInfinity, what kind of crappy prime generating algorithm did you use? I wrote a small unoptimized C code to generate primes, and tested on a 1733Mhz machine (that was the closest to your's I could get) in a multitask environment (linux). It took less than a sec to generate 10 000 primes. Within 16 secs I could generate 100 000. And it can be even faster if rewritten and optimized in assembly and run alone on a bare metal node. Do you need the algorithm? It would look better on promo video, don't you think?
I won't write TCP/IP stack for your OS, but I can give you the C code (no more than 40 lines) or rewrite it in x86_64 asm if you like.
guyfawkes
Member
Member
Posts: 93
Joined: Mon Jul 18, 2011 9:47 am

Re: Bounty: TCP/IP stack for BareMetal OS

Post by guyfawkes »

turdus wrote: For the OP:
From another thread, there was a link to a promo video of generating primes (ca. 10000 primes in 10 secs on a 1.5GHz). You are doing it wrong.

Seriously ReturnInfinity, what kind of crappy prime generating algorithm did you use? I wrote a small unoptimized C code to generate primes, and tested on a 1733Mhz machine (that was the closest to your's I could get) in a multitask environment (linux). It took less than a sec to generate 10 000 primes. Within 16 secs I could generate 100 000. And it can be even faster if rewritten and optimized in assembly and run alone on a bare metal node. Do you need the algorithm? It would look better on promo video, don't you think?
I won't write TCP/IP stack for your OS, but I can give you the C code (no more than 40 lines) or rewrite it in x86_64 asm if you like.
From my understanding, it's written in C =D>
See here:
http://www.returninfinity.com/docs/Bare ... mples.html
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Bounty: TCP/IP stack for BareMetal OS

Post by Kevin »

guyfawkes wrote:I agree, for example you may not have the right Ethernet card and need to buy one etc.
Probably not a huge problem in this case. You need just any NIC that the OS has a driver for. That's about 2.69 EUR for a rtl8139. ;)
turdus wrote:No, not only for completeness. As I wrote: "The point is, you'll need to implement datagram service anyway, even if you don't want UDP. That's all I say."
Yeah, if what you're trying to say is that UDP doesn't add much to IP, so you could just as well implement it when you do IP, I can see your point. It still must be wired up so that applications can use it, and depending on whether you can reuse your TCP interfaces that may actually take more effort than the actual UDP implementation itself.
Developer of tyndur - community OS of Lowlevel (German)
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Bounty: TCP/IP stack for BareMetal OS

Post by Combuster »

More important than being technically correct though, you need UDP to support DNS. You want DNS. Really.
"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 ]
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Bounty: TCP/IP stack for BareMetal OS

Post by Kevin »

You don't strictly need UDP for it. It's also defined for TCP, even though it's rather uncommon to use that.
Developer of tyndur - community OS of Lowlevel (German)
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: Bounty: TCP/IP stack for BareMetal OS

Post by turdus »

guyfawkes wrote:From my understanding, it's written in C =D>
A mathematical algorithm is an algorithm regardless of what language it's implemented in. I offer the C code as a template for assembly, and I also offer to rewrite it in asm if ReturnInfinity prefers. Please don't start the language war here.
Last edited by turdus on Thu Dec 08, 2011 4:43 pm, edited 1 time in total.
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: Bounty: TCP/IP stack for BareMetal OS

Post by turdus »

Kevin wrote:...that may actually take more effort than the actual UDP implementation itself.
Exactly. By the way Combuster's DNS is another really good point.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: Bounty: TCP/IP stack for BareMetal OS

Post by Brynet-Inc »

Kevin wrote:You don't strictly need UDP for it. It's also defined for TCP, even though it's rather uncommon to use that.
The RFC specifies that clients should attempt TCP if the request is too large or the server returns the TC (..truncate) flag.

On OpenBSD, you can force TCP in resolv.conf, which makes it handy for tunnelling DNS over proxies.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
IanSeyler
Member
Member
Posts: 326
Joined: Mon Jul 28, 2008 9:46 am
Location: Ontario, Canada
Contact:

Re: Bounty: TCP/IP stack for BareMetal OS

Post by IanSeyler »

turdus wrote:For the OP:
From another thread, there was a link to a promo video of generating primes (ca. 10000 primes in 10 secs on a 1.5GHz). You are doing it wrong.

Seriously ReturnInfinity, what kind of crappy prime generating algorithm did you use? I wrote a small unoptimized C code to generate primes, and tested on a 1733Mhz machine (that was the closest to your's I could get) in a multitask environment (linux). It took less than a sec to generate 10 000 primes. Within 16 secs I could generate 100 000. And it can be even faster if rewritten and optimized in assembly and run alone on a bare metal node. Do you need the algorithm? It would look better on promo video, don't you think?
I won't write TCP/IP stack for your OS, but I can give you the C code (no more than 40 lines) or rewrite it in x86_64 asm if you like.
The code for what was shown in the video is here: http://cl.ly/CSCE

If you have something better then I would gladly use it. The code above was from before I implemented newlib to get the standard ANSI C calls.

As for hardware none should be required. BareMetal OS has drivers for the Intel 8254x (E1000) so the entire dev setup can be virtual. Personally I use VirtualBox.

There is no set date to have this completed by and any help would be appreciated. I'm going to start looking into it myself as well.

-Ian
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: Bounty: TCP/IP stack for BareMetal OS

Post by turdus »

ReturnInfinity wrote: The code for what was shown in the video is here: http://cl.ly/CSCE

If you have something better then I would gladly use it. The code above was from before I implemented newlib to get the standard ANSI C calls.

As for hardware none should be required. BareMetal OS has drivers for the Intel 8254x (E1000) so the entire dev setup can be virtual. Personally I use VirtualBox.

There is no set date to have this completed by and any help would be appreciated. I'm going to start looking into it myself as well.

-Ian
You use the brute force method :-)
I suggest to use Sieve of Erathosthenes, much much faster: http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
The basic algorithm is the same as yours, but
a) no need to check for even numbers (j+=2 instead of j++)
b) no need to check division by any other number than previously found primes
c) because 3 is the smallest odd prime, it's enough to check number till i/3 instead of i-1

Here's my (really unoptimized) code (compile with gcc primes.c -o primes):

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

//global variables
long *primes=NULL;      //array to hold the primes
long num_primes=0;      //number of elements in primes array

void is_prime(long n)
{
        long prime=0,i,third;
        //sort out even numbers (sanity check)
        if(n%2==0) return;
        //shortcut for the first 4 primes
        if(n==1 || n==3 || n==5 || n==7) prime=n;
        else {
                prime=n; third=n/3;
                for(i=1;i<num_primes && primes[i]<=third;i++) if(n%(primes[i])==0) { prime=0; break; }
        }
        //if it's a prime, append it to our list
        if(prime){
                primes=realloc(primes,(num_primes+1)*sizeof(long));
                primes[num_primes]=prime;
                num_primes++;
        }
}

//the main function
int main(int argc,char **argv)
{
        long argument,i;
        time_t s=0,e=0;
        FILE *f;
        //if we have an argument then use it, if not, ask for it
        if(argv[1]!=NULL) argument=strtol(argv[1],NULL,10);
        else {
                printf("Number of primes to generate? ");
                scanf("%ld",&argument);
        }
        printf("Generating primes... "); fflush(stdout);
        time(&s);
        //check every odd number
        for(i=1;num_primes<argument;i+=2) is_prime(i);
        time(&e);
        printf("OK (%d secs)\n",(int)(e-s));
        //save primes for later
        f=fopen("primes.txt","w+");
        for(i=0;i<num_primes;i++) fprintf(f,"%ld\n",primes[i]);
        fclose(f);
}
It's just a sketch, you can improve it by many ways (pre-allocate primes array, elimiante the call in main loop, using register for prime flag etc. etc. etc.)
User avatar
IanSeyler
Member
Member
Posts: 326
Joined: Mon Jul 28, 2008 9:46 am
Location: Ontario, Canada
Contact:

Re: Bounty: TCP/IP stack for BareMetal OS

Post by IanSeyler »

@Combuster: Free up your schedule then :)

Still looking for someone interested in helping with this.

-Ian
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly
User avatar
Thomas
Member
Member
Posts: 281
Joined: Thu Jun 04, 2009 11:12 pm

Re: Bounty: TCP/IP stack for BareMetal OS

Post by Thomas »

Hi ReturnInfinity ,
Combuster +1

500$ is a lot of money for someone in India . That amount is more than a months salary of many people. I will forward this link to some of my juniors in my college and let them get back to you . Even I could have helped , but it is not ethical for me to do so without permission and getting permission may not be very smooth :(

--Thomas
shikhin
Member
Member
Posts: 274
Joined: Sat Oct 09, 2010 3:35 am
Libera.chat IRC: shikhin
Contact:

Re: Bounty: TCP/IP stack for BareMetal OS

Post by shikhin »

Hi,
Thomas wrote:500$ is a lot of money for someone in India.
Like me. :)

The point is that I am not THAT familiar with how to implement a TCP/IP stack myself. But, I do have the time to study on the topic, and I assure that I will give results. But I'm not sure if ReturnInfinity wants someone to give results NOW, or he can wait..


Regards,
Shikhin
http://shikhin.in/

Current status: Gandr.
User avatar
IanSeyler
Member
Member
Posts: 326
Joined: Mon Jul 28, 2008 9:46 am
Location: Ontario, Canada
Contact:

Re: Bounty: TCP/IP stack for BareMetal OS

Post by IanSeyler »

Hmm. I never thought of that. The trouble would be finding someone who knows TCP/IP as well as x86-64 assembly. As soon as possible would be ideal but waiting is fine.

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