Page 2 of 3
Re: Bounty: TCP/IP stack for BareMetal OS
Posted: Thu Dec 08, 2011 11:15 am
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.
Re: Bounty: TCP/IP stack for BareMetal OS
Posted: Thu Dec 08, 2011 1:39 pm
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.
Re: Bounty: TCP/IP stack for BareMetal OS
Posted: Thu Dec 08, 2011 3:33 pm
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
See here:
http://www.returninfinity.com/docs/Bare ... mples.html
Re: Bounty: TCP/IP stack for BareMetal OS
Posted: Thu Dec 08, 2011 4:00 pm
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.
Re: Bounty: TCP/IP stack for BareMetal OS
Posted: Thu Dec 08, 2011 4:24 pm
by Combuster
More important than being technically correct though, you need UDP to support DNS. You want DNS. Really.
Re: Bounty: TCP/IP stack for BareMetal OS
Posted: Thu Dec 08, 2011 4:32 pm
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.
Re: Bounty: TCP/IP stack for BareMetal OS
Posted: Thu Dec 08, 2011 4:37 pm
by turdus
guyfawkes wrote:From my understanding, it's written in C
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.
Re: Bounty: TCP/IP stack for BareMetal OS
Posted: Thu Dec 08, 2011 4:40 pm
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.
Re: Bounty: TCP/IP stack for BareMetal OS
Posted: Thu Dec 08, 2011 6:05 pm
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.
Re: Bounty: TCP/IP stack for BareMetal OS
Posted: Thu Dec 08, 2011 7:47 pm
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
Re: Bounty: TCP/IP stack for BareMetal OS
Posted: Fri Dec 09, 2011 7:16 am
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.)
Re: Bounty: TCP/IP stack for BareMetal OS
Posted: Wed Jan 04, 2012 11:21 am
by IanSeyler
@Combuster: Free up your schedule then
Still looking for someone interested in helping with this.
-Ian
Re: Bounty: TCP/IP stack for BareMetal OS
Posted: Sun Jan 08, 2012 8:29 pm
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
Re: Bounty: TCP/IP stack for BareMetal OS
Posted: Sun Jan 08, 2012 9:17 pm
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
Re: Bounty: TCP/IP stack for BareMetal OS
Posted: Tue Jan 10, 2012 1:32 pm
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