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.

Hello World!!

May 6th, 2008 by Ryan French

Time for the obligatory Hello World post. This FreeBSD Contributors blog will be a resource mostly on developing a networking protocol for FreeBSD, due to the nature of the Summer of Code project I am working on (MPLS in FreeBSD). This blog will be fed into my main blog, www.driven-monkey.com, but if you want to leave a comment here I’ll get back to you asap.