Weekly Report – 4/8/08

August 3rd, 2008 by Ryan French

I managed to get a few things done this week which and spend a few hours going over FreeBSD networking code and making changes to my own code. I am very close to being able to get the basics of MPLS going, and once that is done the more advanced features will actually be a bit easier as I have the Ayame project to reference those off, whereas at the moment I have no real reference material on how to integrate my MPLS code with the FreeBSD networking code. As I said last week, if anyone has any advice or experience on how to get netisr calling my MPLS code, I think I almost have it, but it would be hugely appreciated as it will save me precious time that I dont really have. I realised this weekend that there is only a month till the end of the Summer of Code, at which point I really need to have at least simple sending/receiving and basic label switching going. Luckily, I am also doing this project as a dissertation for my Post Graduate Diploma in Computer Science this year, so I will be working on it for at elast another month after the summer of code stuff has finished, and I plan on getting a fully working implementation of MPLS going for FreeBSD eventually by completing it once I leave university.

Accomplished Last Week:

- Went through the FreeBSD networking code, trying to figure out where abouts the actual call to the protocol initialising functions are made. It’s not as easy as you would think for someone with almost no previous Operating System code experience to look at this stuff and try and figure it all out, but I’m getting there.

- Made some changes to my own code to use the FreeBSD specific networking routines, rather than the OpenBSD ones, particularly involving if_ethersubr.c and the netisr files.

Plans for Next Week:

- Finally finish figuring out where I am to call the mplsinitr function and getting the protocol registered with netisr. I’ve said this many times before, and  it keeps elluding me, but basically once this is done then the protocol will have a basic functionality and I can actually be semi-happy with the work I have accomplished.

- Figure out what feature is more important to concentrate on next. With so little time remaining in the GSoC I am wanting to make sure I have gotten as many features of the protocol implemented as I can, but I want to make sure I have all the key features that I need implemented as well.

Weekly Report – 24/7/08

July 24th, 2008 by Ryan French

So university is already in it’s second week down here in New Zealand, and things are already getting underway, with my first assignment due today. I’m taking some “interesting” papers this semester. Operating Systems will be really good, as we are learning how to write Linux modules, and we in fact are going to write a file system for Waikato Universities “unique” cluster computer (it has been described as just an office network running fancy software, and in fact it is pretty much just a bunch of Dell computers on an ethernet network), with the main focus being something that supports migration from one node’s hard drive to another. Advanced Communications may or may not actually help me in the real world, I’m not sure, but it’s all just to do with carrier networks and setting up/maintaining a network in a workplace or ISP. For fun I decided my last paper to be “Graphics and Computer Games”, which focuses more on graphics than anything, using C# and Microsofts (sorry for saying a dirty word) XNA package. Sadly, I’m actually already a huge fan of XNA after only a week. I’ve already gone from no previous knowledge to having 3D models loaded on the screen and letting the user control the camera. Yes its that easy.

The Goggle Summer of Code midterm evaluations have been completed, and I passed, despite being able to work much on MPLS for the past while, and not being as far through the project as I had hoped, but thanks to the money I have now been able to cut 2 or 3 days a week off my work at the liquor store, so I can concentrate more on getting this project working. Also, I got myself a 26″ Viewsonic screen.

On to the report.

Accomplished Last Week:

- With the normal start of semester stuff going on I wasnt able to do much more on MPLS, other than try to sort out where I am supposed to call my mplsintr function from. In OpenBSD this is done directly inside netisr, but in FreeBSD this is not the case. If anyone has any ideas on this please leave a comment as it would save me a lot of time.

Plans for Next Week:

 - I have the next 2 days off with no work and no uni, so depending on how much work my lecturers gve me today I will have at least 1 full day to work on MPLS. I am hoping to figure out the netisr problem and have the port completely finished by Sunday.

- Work out my next step and where the port has left me. As far as I can tell, once the port from OpenBSD is done I will be able to send and receive MPLS packets, and switch the label based on a table that is manually setup using the route command. From there I would like to look at setting up automatic route table stuff, using Ayame’s MPLS-TE code as a basis, but it might turn out that there are more pressing features of MPLS that need my attention.

Weekly Report – 17/7/08

July 16th, 2008 by Ryan French

Haven’t done one of these for the past two weeks, due to a very hectic holiday travelling to a few different places to catch up with friends and family while I still had a chance.

Accomplished Last Week:

- Began porting over the Ayame/OpenBSD code to FreeBSD. The problem I’ve come across at the moment is in the differences between OpenBSD and FreeBSD in terms of the netisr stuff. I’m looking into at the moment and should hopefully have it done soon.

- Turned 24. For those of you who know me, you’ll realise that it was quite an accomplishment for me to make it this far through my life and still be alive.

- GSoC midterm evaluations were submitted, only 6 weeks left in the program.

Plans for this week:

- University has started up again for me, and its straight back into it. Luckily it looks like I’m going to be able to work a few less days a week thanks to my GSoC money and having my work employ a few new people, so I should be able to devote a few more days a week to MPLS.

- Finish porting over the OpenBSD code. This will mean I will be able to send and receive MPLS packets, using labels that can be manually entered using the route command. I have to still look into the code a bit more to decipher if the label switching is doing everything I was planning on implementing with it.

Weekly Report – 30/06/08

June 30th, 2008 by Ryan French

Real Life really doesnt like me working on this project. Thanks to exam time at university I was have to cover a few shifts for other students this past week, and ended up doing 6 days in a row. Thankfully I have some holiday time coming up starting this Thursday, and while I’ll be away for both weekends I’m on holiday I’ll have a full week to work on MPLS from the moment I get up to the moment I go to sleep, without any distractions.

Accomplished Last Week:

- Worked on my FreeBSD wiki pages.

- Went over OpenBSD/Ayame code again to try and get a bit more understanding on how it works.

Plans for Next Week:

- Port over the protocol description file mpls_proto.c, then begin working on porting over code for simple sending and receiving of MPLS packets.

- Once sending and receiving is working, look at implementing static label switching, then working towards dynamic label switching off a routing table.

Weekly Report – 24/6/08

June 24th, 2008 by Ryan French

Man these weeks are flying by. I managed to get a bit of work done on MPLS, but not much, before a suprise trip to visit friends up in Auckland dragged me away for the weekend.

Accomplished Last Week:

- Began looking over the OpenBSD implementation, looking through what has been submitted on their CVS, and just generally trying to get how the code does what it needs to do, and where it does it.

- Finally got a call back with an answer from IBM about my application. They have decided not to invite me to their interview day this time, but apparently if they hold another one then they will invite me to that. I’m not holding my breath. It appears as though it is very hard to get a job in New Zealand working with operating systems or networking stuff, unless you have experience. Unfortunately for me, my grades in my first 2 years of uni where anything but flash, and I seem to be suffering for it now. It’s almost making me wish I had some PHP or web programming under my belt, which is what all the NZ jobs seem to be looking for. Oh well, onwards and upwards with the job hunt hopefully.

Plans for Next Week:

- Once I have sorted out the licencing stuff with using OpenBSDs code (I havent had anything to do with Open Source licences befire, and I dont want to step on anyones toes by doing the wrong thing) then I will be porting over the code that I need to start working on.

- Figure out where exactly the code from OpenBSD has gotten to in terms of my plans, and then start working on improving it or moving on to new features I need.

Thats all for now. If anyone knows of any jobs in NZ for someone studing networking and operating systems, let me know :)

Weekly Report – 16/06/08

June 16th, 2008 by Ryan French

Yet again another week has gone by, and unfortunately I still havent accomplished much on MPLS. However, university has finished for me until mid July, so I will be working on it as much as I can between now and then.

Accomplished Last Week:

- Nothing, well, not completely nothing, just nothing MPLS related. I had my last test and report done by Thursday, and I’ve worked almost every day since, so I havent had much time to work on MPLS.

Plans for this Week:

- Begin browsing and porting over code from OpenBSDs under development version of MPLS, which I believe is based a lot on the Ayame MPLS patch for NetBSD. Aren’t we all just a big happy family of BSD’s after all?

- Will start by getting the protocol description file done, and then look at receiving MPLS packets, then maybe if I get time I will transfer over sending packets. I dont want to just coy and paste, compile, debug and hope I can get it to work, cause I really want to understand how it works right down to the basics, and I wont if I just rush through it all.

Weekly Report – 08 June 2008

June 8th, 2008 by Ryan French

So I said I would try and write one of these every week, and its been two weeks since I wrote my first one, so I’m not going too well at the moment. Uni is over for me in a few days then I’m going to take a weekend off before I start working almost exclusively (I still have to work at my job at the liquor store) on MPLS for FreeBSD. I only have 4 weeks of holidays to work mostly on this unfortunately, its one of the main problems with trying to do GSoC, when its not actually summer where you live.

Accomplished last week:

- Finished my first ever research paper that I needed to do for one of my classes this semester, The paper is on Inferring Traffic Shaping via Port Number. Its not a very interesting topic, nor a very challenging paper, it was just something that I could do without taking up too much of my time. I may upload it later for anyone interested in reading it.

- Finished 1 of my 3 papers for the semester. This week I will be finishing the other two with 2 last assignments due as well as a final test on thursday. I’m very happy to know that unless I fail something, I wont have to go to classes anymore after the end of this year.

Plans for this week:

- Nothing really MPLS related. With uni finishing on thursday (well, technically my last assignment is due on friday but thanks to my job I have no way of getting up there to hand it in) and work on friday and sunday I wont be working on MPLS at all.

- Not related to GSoC or University in any way, but I’m going to kick up my search for a job for when I graduate at the end of the year. Still waiting to hear from IBM to see if I got through to the next stage of interviews, going to call them later today if I havent heard anything back from them.

Weekly Report

May 26th, 2008 by Ryan French

I will be attempting to write one of these every week from now on, if I can remember to. This particular report goes back to shortly after I started working on MPLS.

Accomplished Last Week:

  • Wrote MPLS-Needle, a tool to inject semi-custom MPLS packets into the network.
  • Read through a lot of code already written such as Ayame, and the OpenBSDs currently in development work.

Working on This Week:

  • Not much as I have 2 more weeks of this semester left before I get 5 weeks off to work on MPLS.
  • If time I will continue to read through code and possibly look at porting some over.

Injecting Custom Packets in FreeBSD

May 24th, 2008 by Ryan French

Well, over the past couple of weeks I have been working on the begginings of my MPLS implementation. The first step was to write a program that can inject semi-customisable MPLS packets into the FreeBSD networking stack. I found when I started this project there was very few resources that I could find that helped me complete this. So, in an effort to help anyone else attempting to write an injection tool I figured I might write a short post (well as short as I can keep it) on how to acheive this. I’ll try and keep it brief.

The first step is to create the datagram packet that will be sent.

uint8_t datagram[1500]

where the size of the array is the number of bytes you are wanting to send.
Once the datagram is created you need to fill it with the packets header values. Most types of headers you will already find defined inside the /src/netinet/ folder. These are normally very easy to use. They are created as follows:

struct ether_header *eth = (struct ether_header *)(datagram);
struct ip *iph = (struct ip *)(datagram + sizeof(uint32_t) + sizeof(struct ether_header));
struct icmphdr *icmph = (struct icmphdr *)(datagram + sizeof(struct ip) + sizeof(struct ether_header));

In this example the struct is defined, with a pointer which also points to the point in the datagram where the header needs to start. For instance, the icmp header needs to point to the next byte after the IP header, which is the size of the ip header + the size of the ethernet header, past the start of the datagram. Once these have been created it’s fairly simple to assign values to the headers, like so:

iph->ip_hl = 5;
iph->ip_v = 4;
iph->ip_tos = ip4_tos;
iph->ip_len = htons((iph->ip_hl<<2) + 8 + 20);

I’ll leave it up to you to figure out the rest of the values, which is pretty easy if you look at the struct definitions.

If you require a header that is not already defined in the netinet package, the easiest way I found to do this was to create a int larger than the size of the header, then once it has had the values inserted into it, use byte shifting to make the header values lined up correctly. Then the values are copied into the datagram using memcpy.

uint32_t mplsh;
mplsh = htonl(mpls_label << 12 | mpls_qos << 9 | mpls_bos_flag << 8 | mpls_ttl);
memcpy(&datagram[14], &mplsh, 4);

After this the packet has been created and is ready to send along the wire. To do this we use a BPF device. So, we need to find a spare BPF device, open it up, and writing the packet to it.

To find a spare device, you basically have to poll through every possible BPF device until you find one that isnt being used.

int
dl_bpf_open_dev(char *dev, const size_t len)
{
int i=0, fd;
do {
snprintf(dev, len, "/dev/bpf%d", i);
if ((fd = open(dev, O_RDWR)) == -1) {
if (errno == EBUSY)
continue;
else {
fprintf(stderr, "could not open %s\n", dev);
return -1;
}
}
else break;
}
while (++i < 32768);
return fd;
}

Once this is done you need to open the device to allow you to write to it.

int
dl_bpf_open(const char *ifname)
{
struct ifreq ifreq;
char dev[16];
int fd;
memset(&ifreq, 0, sizeof(ifreq));
strcpy(ifreq.ifr_name, ifname);
if ((fd = dl_bpf_open_dev(dev, sizeof(dev))) == -1)
return -1;
if (ioctl(fd, BIOCSETIF, &ifreq) == -1) {
fprintf(stderr, "%s BIOCSETIF %s failed\n", dev, ifreq.ifr_name);
close(fd);
return -1;
}
return fd;
}

Note: Thank you to Matthew Luckie for giving me the code to find and open the device. ALso, if you wish to use this code, then all you need to do is make a call to dl_bpf_open() and it will do the rest for you.

Once this is done you simply need to write to the open device, then close it up and you’re all done.

if ((wb = write(fd, datagram, len)) < (ssize_t)len) {
if (wb == -1)
fprintf(stderr, "%d bytes failed\n", len);
else
printf("%d bytes sent of %d total\n", wb, len);
return -1;
}

So thats basically it. I dont think I’ve gone quite as indepth as I possibly could, but from this most people should be able to get something working. If anyone has anymore questions post them at either of my websites and I’ll get back to you. Also, if anyone out there notices a mistake I’ve made, please let me know asap, before I put too many people wrong.

EDIT: I’m having a few problems with keeping tabs and spacing formatting in the code sections, if anyone knows how to fix this please let me know.

Automatic RSS Syndication to www.driven-monkey.com

May 12th, 2008 by Ryan French

So, all things going to plan, this post should be appearing both on my FreeBSD Contributors blog as well as my main blog, and if it doesn’t, well I’m just gonna delete it and try again.

I’m using the FeedWordPress plugin which is pretty quick and easy to install and use. All I had to do was put in the address of this blog under the Syndication tabs, change a few options to automatically update the blogs, and hey presto, the internets magic does its thing. Its gonna make life a lot simpler than having to post any work I do on MPLS on both blogs.