how long would it take to implement TCP/IP stack?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
nulik
Member
Member
Posts: 46
Joined: Thu Oct 20, 2011 2:07 pm

how long would it take to implement TCP/IP stack?

Post by nulik »

Hi,
for an appliance server I need to implement a high performance TCP/IP stack, so I have to estimate project time and would like to ask advice. I have 10 years experience in C , I know all about unix operating system at the user space level, but I have little knowledge of kernel internals. I know many folks here wrote their own TCP/IP stack, how long did it take? How much do you think it would take me to finish it (bug free)? I work 12 hours a day.

Now, there is a little detail, the stack I am going to implement is not going to be for an OS. I am going to use DPDK (dpdk.org) and it is going to manage one network adapter dedicated to my application. This is for a project of an http server appliance, so I am only going to pay attention to port 80, no ICMP, no UDP, and no other protocols. This should be implemented quicker than full TCP/IP stack, right?

Thanks in advance.
Nulik
p.s.
(just in case you wonder, I can't reuse any of the existent solutions)
shmx
Member
Member
Posts: 68
Joined: Sat Jan 16, 2016 10:43 am

Re: how long would it take to implement TCP/IP stack?

Post by shmx »

I know nothing about DPDK. You plan to develop a network card drivers? TCP/IP stack entirely too bulky. I do not think you need to realize it all.
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: how long would it take to implement TCP/IP stack?

Post by alexfru »

shmx wrote:I know nothing about DPDK. You plan to develop a network card drivers?
dpdk is the driver(s).
shmx
Member
Member
Posts: 68
Joined: Sat Jan 16, 2016 10:43 am

Re: how long would it take to implement TCP/IP stack?

Post by shmx »

Then I refrain from commenting. Much depends on the functionality of the dpdk.
nulik
Member
Member
Posts: 46
Joined: Thu Oct 20, 2011 2:07 pm

Re: how long would it take to implement TCP/IP stack?

Post by nulik »

shmx wrote:Then I refrain from commenting. Much depends on the functionality of the dpdk.
Really on dpdk?
DPDK gives you a pointer to ring buffer, the NIC puts raw packets into it, and then you have to process raw packets yourself. No interrupt management (DPDK uses polling because interrupts are performance expensive) , the driver management is done by DPDK, it is all made easy for developers to do not get into the hardware stuff. My question goes for how much the implementation of the TCP stack itself would take. From what I have read , the window negotiation options and extensive parameters list will take a long time to complete. But I don't know, do I really need to implement all that TCP options? For high performance TCP stack ? I am short on development time, I need to deliver this project ASAP, that's why I am asking.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: how long would it take to implement TCP/IP stack?

Post by gerryg400 »

A quick estimate:

Code: Select all

TCP 1000 lines
IP 200 lines
utility/support functions 200
wrapper 200
Total: 1600 lines.

Assume a sustainable rate of 2.5 lines per hour.
Add 20% because TCP is well specified already
2.5 x 1.2 = 3 lines per hour. 

total hours = 1600 / 3 = 533 hours
total days = 533hrs / (12hrs/day) = 44 days
If I were asked to estimate this for me I would say 15 weeks at 36 hours per week.
If a trainstation is where trains stop, what is a workstation ?
nulik
Member
Member
Posts: 46
Joined: Thu Oct 20, 2011 2:07 pm

Re: how long would it take to implement TCP/IP stack?

Post by nulik »

gerryg400 wrote: 2.5 x 1.2 = 3 lines per hour.
3 lines per hour??? Are you kidding? May I ask if your company is hiring, I need vacations!

Few years ago I was measuring how much code I write in C. I had no clear spec, I was designing and at the same time coding. I was doing from 250 to 350 lines of code per day. This is my today's work, a stress test program i need for testing:

Code: Select all

[niko@dev1 src]$ wc -l http-stress.h http-stress.c
  23 http-stress.h
 212 http-stress.c
 235 total
[niko@dev1 src]$ 

3 lines per hour is almost nothing. If you code clear spec (in mind or in paper) you could do even 1,000 lines per day. It all depends if you know what you have to do.

However, thanks a lot for the info. If TCP/IP stack is only 1600 lines of code, thats a relief! I feel better now, maybe I could do it in 2 months, well tested ... tough I know nothing about TCP, I suppose this is how it is going to be:
1 week - studying RFCs
1 week - looking other people's code
2 weeks - coding
1 month -testing

I already downloaded about 4 different mini stack implementations, wish me luck!
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: how long would it take to implement TCP/IP stack?

Post by alexfru »

3 lines per hour comes out as 3*8=24 lines a day, which is not far from the average figure (~10 LOC/day in the industry).
Everything has its cost:
  • finding a/the solution to the problem
  • understanding the existing code
  • working around/fixing/rewriting the existing code
  • actually writing the code you need
  • reading docs
  • debugging/troubleshooting
  • writing tests
  • running tests
  • code reviews
  • working with other people otherwise (helping out, mentoring, presenting, etc)
  • writing docs
  • meetings
  • various forms of support
Some days you can get 1+KLOC, others 0. The average (over a year, let's say) tends to be closer to tens.

If you think 3 lines an hour is low, it means you don't have to do a lot of the above, which has its implications, most often in the form of code quality. Or you're a solo programmer superstar.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: how long would it take to implement TCP/IP stack?

Post by gerryg400 »

nulik wrote:
gerryg400 wrote: 2.5 x 1.2 = 3 lines per hour.
3 lines per hour??? Are you kidding? May I ask if your company is hiring, I need vacations!

Few years ago I was measuring how much code I write in C. I had no clear spec, I was designing and at the same time coding. I was doing from 250 to 350 lines of code per day. This is my today's work, a stress test program i need for testing:

Code: Select all

[niko@dev1 src]$ wc -l http-stress.h http-stress.c
  23 http-stress.h
 212 http-stress.c
 235 total
[niko@dev1 src]$ 

3 lines per hour is almost nothing. If you code clear spec (in mind or in paper) you could do even 1,000 lines per day. It all depends if you know what you have to do.

However, thanks a lot for the info. If TCP/IP stack is only 1600 lines of code, thats a relief! I feel better now, maybe I could do it in 2 months, well tested ... tough I know nothing about TCP, I suppose this is how it is going to be:
1 week - studying RFCs
1 week - looking other people's code
2 weeks - coding
1 month -testing

I already downloaded about 4 different mini stack implementations, wish me luck!
My estimate for you to do it based on 3 lines per hour is 6.2 weeks (44 days). Your estimate is 8 weeks. They're not that different. In fact your estimate is higher.
If a trainstation is where trains stop, what is a workstation ?
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: how long would it take to implement TCP/IP stack?

Post by Kevin »

nulik wrote:However, thanks a lot for the info. If TCP/IP stack is only 1600 lines of code, thats a relief!
I would doubt that. The tcpip driver in tyndur has 4.5 KLOC and that's a crappy, low-performance, not spec compliant, works-for-now style hobby OS driver, i.e. far from something that you would want to use in production.

To be fair, it includes not only TCP and IP, but also ARP, UDP, DHCP and DNS, and I'm not sure if and which of them you want. But even just with TCP and IP (excluding the interface to actually provice the service to other processes...), I'm at 1.8 KLOC and as I said, that only implements the bare minimum to get something somehow working, ignoring considerable parts of the specs.
Developer of tyndur - community OS of Lowlevel (German)
nulik
Member
Member
Posts: 46
Joined: Thu Oct 20, 2011 2:07 pm

Re: how long would it take to implement TCP/IP stack?

Post by nulik »

alexfru wrote: If you think 3 lines an hour is low, it means you don't have to do a lot of the above, which has its implications, most often in the form of code quality. Or you're a solo programmer superstar.
I must be living in another world because I am not superstar programmer by any way. I write some code, then I go take a coffee, relax and do other stuff.Or maybe you talk about coding in assembly language, then this is another story, I was talking about C. One of my biggest projects right not surpassed 20,000 lines of code. I have 2 years writing it and I do not write every day. In fact, it has been on standby for 3 months. If I use your formula of 3 lines per day, then 20,000 / 3 = 6,666 days / 365 = 18 years. That's way far from the truth. The effective working days would be around 6 months or so for this project, if I take out all the days it has been on hold because I was doing something else. If talking about quality I don't have much of the segfaults, valgrind is a good help for making your code stable. I also comment a lot inside the code because I am myself sometimes forgetting what I wrote. There have been a lot of projects for example like Napster, which have been made by one programmer very quickly, so , 3 lines of code per day is absurd. As I say, the key here is: to know what you want to achieve. And it will be written very quickly.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: how long would it take to implement TCP/IP stack?

Post by gerryg400 »

Kevin wrote:
nulik wrote:However, thanks a lot for the info. If TCP/IP stack is only 1600 lines of code, thats a relief!
I would doubt that. The tcpip driver in tyndur has 4.5 KLOC and that's a crappy, low-performance, not spec compliant, works-for-now style hobby OS driver, i.e. far from something that you would want to use in production.

To be fair, it includes not only TCP and IP, but also ARP, UDP, DHCP and DNS, and I'm not sure if and which of them you want. But even just with TCP and IP (excluding the interface to actually provice the service to other processes...), I'm at 1.8 KLOC and as I said, that only implements the bare minimum to get something somehow working, ignoring considerable parts of the specs.
Yeah it is low but the original question as I understood it was for a custom TCPIP with a single 'hard-coded' adaptor on a single port.
If a trainstation is where trains stop, what is a workstation ?
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: how long would it take to implement TCP/IP stack?

Post by gerryg400 »

nulik wrote:3 lines of code per day is absurd. As I say, the key here is: to know what you want to achieve. And it will be written very quickly.
3 lines per hour.

My initial calculation told you that it would take 44 days to do your TCPIP. You told me that was absurd, that you lived in another world and are much faster than that and could get it done in 8 weeks. Somewhere along the line there is a miscommunication between us :)

I use 'cloc' to count the lines in my projects. Try it on your 20k project and see how many lines of actual code there is. Then calculate the hours and look how close your 20k project is to delivery to your customers.

I've been using calculations like this for many years to help improve the quality of software projects and I can tell you that for a single engineer, delivering 5000 lines of quality code in a real project to a real end-user in one year is a monumental achievement.
If a trainstation is where trains stop, what is a workstation ?
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: how long would it take to implement TCP/IP stack?

Post by Kevin »

gerryg400 wrote:Yeah it is low but the original question as I understood it was for a custom TCPIP with a single 'hard-coded' adaptor on a single port.
True, I didn't read carefully enough. My bad.
Developer of tyndur - community OS of Lowlevel (German)
nulik
Member
Member
Posts: 46
Joined: Thu Oct 20, 2011 2:07 pm

Re: how long would it take to implement TCP/IP stack?

Post by nulik »

gerryg400 wrote:
nulik wrote:hour.
.
sorry, that makes 30 lines per day. I think production related tasks should not be considered into development time but anyway. I got the answer to my question, thanks a lot!

p.s.
I also measure with "cloc"
Post Reply