Assignment#2 is marked

Apparently second assignment has been quite challenging as only five submissions were received. It's been marked and all of them have passed the assignment. Source code of any of the submissions can be obtained on the anti-plagiarism system report.

Torrents are good


Downloading large files using P2P technology can be quite convenient. As an example I've uploaded the ISO image of Graduation Ceremony DVD to Mininova. These guys are now prevented by a court order to distribute copyrighted contents. However there is no problem if the contents is public domain or posted by the rights holder. So here you have the torrent file.

If you did not graduate this year and therefore missed the ceremony, now you can have a look at it.

Class source code

Today we talked about Multi-thread servers and how we can create them easily in Java.

There are the three examples I wrote.

And let me correct myself: The first implementation of synchronized methods (using inc and dec methods for the simultaneous client counter) is as good as the last one (using just inc) as it is explained in here.Enlace

Excellence in Teaching Awards 2009

I've been granted an Excellence in Teaching award from the local government. Among other things lecturing in English (or other foreign languages) and having high-marks on student surveys of teaching were topics assessed.

Now it is time to look around and to thank all the people that made this possible: from my colleagues who share an interest on teaching to my students who keep on asking questions. From all of them I learn a lot every day.

I'm also grateful for my University and government that through various programs have supported different visits and stays at foreign universities.

And last, but not least, to my dear family and friends who have always been there for me.

For all of these I'm grateful.

Assignment#1 report


Not that the results are very bad but I want you to know that measures are taken to keep you all honest.


The following report checks the similarities between all of your submitted assignments.

Class problem

A 4-MByte file is transferred between two computers linked by a router. Each link is 100 Mbps and 100 meters long. Signal propagates at 85% the speed of light. TCP is used for the transfer with MSS=1460 bytes and Receive window is 2048 bytes. How long does it take for the transfer to complete?

Assume only data and TCP headers are transmitted. Assume TCP acknowledgments transmission and queuing delay are negligible. Assume TCP uses delayed acknowledgments. Assume no transmission errors happen and no congestion control is used. Assume TCP connection already established.

For solution OpenOffice's spreadsheet click on this entry title.


Or...


No thanks, I prefer to shot myself on the foot than to use OpenOffice.

Solution to assignment#1

As you have asked me for a solution I'm providing you mine.

You can see that as soon as a client does not provide expected command it is kicked out.

This server won't accept multiple messages sent over the same connection (nor it was required).

An alternative implementation using a finite state machine for the implementation is shown in this other solution.

Second assignment is out

Second assignment is about coding a simple web proxy. No local storage (no cache handling). Just a simple iterative server but with a twist: As you need to read from two streams (request and response) you have to figure out the best way of doing it.

Only GET method is permitted, so you can safely reject any other method coming from the browser (to keep things as simple as possible).

You can click on this entry title to get the assignment text. Second assignment due date is December 23rd, 2009.

Haven't read RFC 821 yet?

Please note that some of you are doing assumptions for assignment#1 that do not match the protocol specification. I want to bring your attention to page 4 of RFC 821 where MAIL FROM and RCPT TO commands syntax is shown. Please note there is not a space between the colon and mailbox name. Do not confuse that with what appears inside the message header (From: and To: headers, where a space is found).

Click on the image on the left to get a better view of it.

Issues with Assignment#1


Apparently there are some difficult statements on the assignment text (given the submissions I'm getting). Let me repeat some of them here (pasted from original document, boldface added here):
  1. Please include a MANDATORY comment on the source code with your name.
  2. Please send me the java source code file by email to the email account shown here with
    EXACTLY the subject: Assignment#1
  3. Each time your server receives a message it will write it down to a text file named "received.txt".
  4. Main class name MUST BE SmtpServer.

In case you have not noticed it, I was using UPPER CASE to remark that these were IMPORTANT information.

Class code

Thrusday's class source code below:

How to write to a text file in Java?

I would suggest you to use PrintWriter class to write to a text file the same way you'll print to a socket. In the below example object out is created so later on out.println("whatever") can be invoked.

PrintWriter out = new PrintWriter(new FileOutputStream("received.txt"));

Friday's code

You can click on the title to get the code I typed in the class today.
 

Office hours change

I've changed office hours due to agenda conflicts. You can see below the new office hours.

Lab#2

This week lab#2 starts. You can get the lab text from this page file repository (or by clicking on this message's title). On the other hand, it has been a subtle change about lab's local storage: Now your home directory is set to your own private network storage. So, contrary to what the lab instructs you to do, you can keep the lab folder if you want.

This lab is about using sockets from the command line interface (CLI). FTP protocol is also presented here.

 

Java Network Programming


There are many good sources to learn from. But I think the best advice I can give you is that network programming is like riding a bike: you learn by doing it.

While on the campus network you can access a huge collection of Safari Books Online. A relevant one is this one.

But among many online resources, the Java Tutorial is worth trying. They even have a Sockets section you may enjoy reading.

Please remember that Java is free and open. You can easily download JDK to your system, so you can both compile and run any examples. I encourage to do so.

First assignment


I've published the first assignment on our file repository. If lazy, just click on this entry title.

You have till Nov 20th, 2009 to turn it in. Remember that while optional, assignments will count to your final mark.

Those from foreign universities can use a programming language different than Java.

I'm providing you a sample server binary that, hopefully, will work. You can run it by typing
java SmtpServer

Update:
There is been already one submission.

Lab Blues


I failed to mention that there is a self-assessment test at the end of each lab session. Unfortunately these exams are only available in Spanish. The good news is that you can safely skip them. It is ok if you do them too. It is ok if you provide random answers too.

The real assessment for the lab exercises will happen in the written exams, where 30% of the mark will come from questions about the labs. Please note other students (not the English one) have a different policy regarding the lab tests (these being mandatory). Please note the teacher in the lab may not know you're from the English group.

I am sorry I did not mention that before but please remember last week we did not have lectures of RED.

Fiber optics Nobel prize


It is said that success has many fathers.

Charles Kao, one of the fathers of fiber optic technology has been awarded this year's Nobel prize in Physics. The prize is shared with two other notable physicists.

This gives you an idea of how important fiber optic technology is.

Odd week


As you know next Friday is a national holiday. Next Thursday, however, it is not a holiday. But, in order to balance the number of weekdays next Thursday will be like a Monday regarding to lectures' schedule.

So to make a long story short: This week we won't have RED lectures.

September marks

Just in case you've not searched for them on the usual place, here you have September marks. They will become official by the end of this week.

Sorry, former link was not public, it should be fixed by now.

Some ideas if you bring your laptop to the lectures

A former student, Ismael, mentioned that some students found interesting to use software for adding comments on PDF slide files. Apparently PDF-Xchange Viewer (for Windows) and Skim (for OS X) can do the job (for free).

Of course this may only be interesting for those of you that are bringing a laptop to the class. But, time-proven technology, like paper and pen, can be very useful tool too.

 

Welcome to the 2010 class of RED


We'll use this blog for posting interesting data about the subject, slides, laboratory exercises, solved exams, assignments and marks.

Contrary to PoliformaT this blog is open to anyone, whether you are enrolled in the subject or not (or not yet).

Feel free to use the comments on any topic to ask questions or to make any comment you think it is appropriated.

Please note the "File Repository" link on the top right side will lead you to a Google site with (hopefully) all the required files related to the course.












Let's keep in touch

While I do know some of you are going to stay around for a while, others are already back to your home country. Because many of you are using the university provided email, contact will be lost as soon as your account has expired.

You still can reach me on Facebook or Linkedin networks, and I think it is a good idea to keep the link on. Sometimes you may need a recommendation letter or discuss any technical issue. Other times I may ask for some traveling advice. Who knows.

So farewell and see you online.

Challenge your programming skills

The new edition of Google's CodeJam contest is about to start. While you won't get any points on this subject, it can be fun and you can also get some cash!

Summer reading

I've found this article on Tom's hardware website quite interesting to read.

Spicing up your marks

After some changes on the marking due to your requests, marks have been adjusted so all the available range of the pass mark is covered. As a result some of the marks actually crossed the fail/pass border and those of you affected will be pleasantly surprised. Still some of you did not make it and you will have to come back in September for another exam. Please note the exam "algorithm" will be the same as in June: You can take 1st term, 2nd term or both exams.

REDES-2008_09

Do you want to check your exam?

Please note you'll need to scroll down to find your exam. They are not stored in any special order, so be patient.

1st term exam

and

2nd term exam

are available for you to see them on-line (no download is allowed).

Exams will only be available for a limited time.

Update: Question 21 of 2nd term exam has been re-examined and now Dijkstra is also considered a valid answer. Marks have been modified accordingly for all of you.

June 2009 2nd and 1st term solved exams

As we did before, please double check the solved exam and with the answers you remember you provided and then, mark your own exam and email the mark to me.

Thanks.

Jun2009A Solved

The 1st term exam solution is below. As with the other exam, please mark yours and email it.

Jun2009B Solved

A few more solved exams

If you took the time to explore this blog's content backwards you've realized some of the older links are dead. But fear not, some of that content is brought back to life here. These are a few solved exams more for you to look at.

Don't forget next Monday we'll have the exam.

Either you are attending to one term exam or two, see you there.
 

Breaking bad

Some years ago we've got a situation at UPV. This paper details some of the events that happened. I reckon both students involved are still at UPV.
Paper

Exam details

Next June 2009 exam will consist of two parts. Those of you only interested on the second term part have to come at 10:00. 2nd term exam will last two hours.

After the 2nd term exam a 1st term exam will be held (same place but fewer rooms).

Please note that it is mandatory you take now the 2nd term exam but the 1st term one is optional. If you are happy with the mark you already have got in the 1st term then you do not need to repeat that. Your final mark will average the mark of both semesters "no strings attached".

Both exams will follow a similar format than the ones on the blog (sorry but old links may not work).
 

Improve your Spanish while learning cryptography


Manuel Lucena is a professor from Jaen University who has a great book on cryptographic algorithms and who is kind enough to provide us a free PDF version.

There is only a catch on this offer: it's only available in Spanish. What a good opportunity for practicing your newly acquired skills!!

Contrary to what happened in the classroom, the book provides a detailed view of many cryptographic algorithms, including DES, IDEA, AES, RSA, ElGamal, DSA, ... etc

Update:
For those of you that still prefer a book written in English you can download this one. Though a bit aged it is still a very solid book.
 

Put your crypto skills to work


For many of you [non-Spaniards] this might be a more difficult challenge as Spanish knowledge can help. Can you discover what is the hidden part of this message?

You are welcome to bring the solution to the class and I'll pay you a coffee.

For more challenging proposals you can go to this contest.
 

Last two chapters


Chapter 6 and Chapter 8 are the last chapters of our course. There is not much time left and we will skip some of the sections, please stay tuned to get the details about what is left out.

Lab#10

This is the last lab of the course. Click on the title to get the file.

More info here.

Easter Fun


Now that we're approaching the end of the course you might be eager to see the whole thing in action. There is no better way to learn anything that when you're facing the task of building a working system. And I mean to build all of it!

Most of the time you work on a personal computer. Not the hardware or the operating system are part of what you have to build. In an extreme case you might be rebuilding the kernel of the operating system you're running.

If you like hardware and to experiment I propose you to get one Arduino board and a LAN adapter for it. I've used in the past the ones I'm referencing and I've found that seller the cheapest option at the time.

To get things running you'll need to download the software library for the LAN card plus the Arduino IDE appropriated for your computer (OS X, Linux or Windows).

Arduino is an easy-to-use low-cost "open hardware" microcontroller board around ATmega168 chip. USB bus server to both power the board and download developed code to it. Many extensions are possible and the LAN card adds a simple Microchip LAN controller to Arduino. All the source code you see is all what's available: no operating system below, no hidden strings, just the bare source of the library.

Lab#9

Click on the title.

Error checking (kind of)

If you want to know the character (for error control purposes) of a Spanish identification document, just perform the modulo 23 operation over the DNI number. Then use the next table. That's it.

0 T 12 N
1 R 13 J
2 W 14 Z
3 A 15 S
4 G 16 Q
5 M 17 V
6 Y 18 H
7 F 19 L
8 P 20 C
9 D 21 K
10 X 22 E
11 B



And if you want to get a better idea about how CRC works you can visit this old post. There is a detailed Wikipedia article too.

Chapter #5 slides

Oops, I've almost forgot to post it here. You can click on the title to get the file.

Lab#8

Just click on the title.

IPv6 survey result

It was published recently on NetworkWorld site. ISP's are not seeing a big business drive for IPv6.

Sample implementation of assignment#3

You'll need it if you're planning to do assignment#4 but you did not do #3. Source code is available here. It consists of a main class and three additional classes one for each server (peer, query and file server).

Better late than never

After some questions I've learned that I mention nowhere what the expected command-line parameters order for #3 and #4 is. Three are the parameters you need: port number, shared folder and initial peer, like this:

$ java P2P 7123 ./ 158.42.53.17:7777
| | |
port | |
folder |
initial peer

I just thought this afternoon that a test tool might come in handy for you to test your assignment #3 servers. So here you have such a tool. Please remember a full implementation of a peer was also available (as another way to test that your server works nicely).

The test program is intended to be run in the same computer as #3, so you only need to provide the port information.

$ java P2Tester 7777
>>> CONNECT OK
158.42.53.17:7777
158.42.53.17:8899
1.1.1.1:1234

P2P.class
QueryServer.class
ListManagement.class
Peers.class
FileServer.class

>>> READ FROM FILE (first ten bytes): FileServer.class
ca fe ba be 00 00 00 32 00 72
Please note the output above shows the expected behaviour where you have three sections. On the top it is the peer list, after connect ok message that tells you the three server ports are open (p, p+1 and p+2). Next you have the list of filenames (only if your code reacts this way to an empty line query, something mine does) and in the third place you have the first 10 data bytes of the filename that appears last on your file list (FileServer.class).

Please note the file is not read from the filesystem but sending a file download request to your server listening on port P+2.

Also note that peer 1.1.1.1:1234 might not appear on the peer list till you run test program twice.

Do not use an empty folder for your P2P server: share some files!!

Last assignment is out


Fourth and last assignment completes the P2P software you started building on #3. Therefore you'll need to add the #4 code to the one you wrote for #3. If you did not do third assignment but you'd like to attempt the fourth, please contact me for a reference implementation for third assignment (once #3 due time has expired).

This last assignment takes care of the user interface of the peer to peer program, that allows the user to search for files on the network of peers and to download a file from a peer. It also takes care of maintaining a "live" list of active peers (pruning it when a peer is found not responsive).

Due date is April 30th, 2009.

Assume command line information is correct.

Lab #7 available only in Spanish

Just click on the title to get the file.

IPv6 addresses problem

IPv6 is proposed as an almost unlimited source of addresses to overcome the IPv4 address shortage some people have suggested. As IPv6 addresses are 128-bit long, 2^128 (aprox 3.4 x 10^38 ) addresses are possible. This should be large enough.

To put things into perspective consider the following problem: How many IPv6 addresses could you put into each squared centimeter of the planet? (Assume the Earth is a regular sphere of 40.000 Km of perimeter).

And a second part ... compare the above number of IPv6 addresses per square centimeter to the total address space of IPv4.

Fragmentation exercise


A 4000 byte-long datagram has to be transmitted over a network whose MTU is 512 bytes. Determine the number of fragments and, for each one of them, write down the fragment offset field contents and the number of data bytes of each fragment.

Solution was presented as a spreadsheet in the class. Here you have a copy. You can export it to your favorite spreadsheet software too (to see the formulas).

Third assignment announcement


Third and forth assignments will be based on a peer-to-peer protocol invented for the occasion. The so-called "P+2" protocol has been created to be one of the simplest P2P protocols (but not any simpler). You need to read and to understand the protocol specification. Protocol was already presented in the class but if there is general call I will repeat the explanation.

This assignment covers three different servers needed to create a full implementation. Assignment's servers can be tested to work using either telnet, netcat (nc) or sock commands. Java language is mandatory for Spanish students but the rest may use the language of your choice. A working implementation of a peer is available too (just a binary version).

You can download assignment text from here. Or you can just go to the file repository (linked on the top right corner, under the new stuff title).

There is a sample peer running too. You may not need it yet for this assignment. Anyway, it is available at 158.42.53.17:7777

You are welcome to ask me for help. Please remember you have to write code by yourself. As assignments are marked individually, it is not something you can develop jointly with a classmate. If two or more assignments are copied from each other all the involved parties will fail the assignment. Due date is March 13th.

p_2

Second term starts

Chapter 4 slides are already available. For those of you joining us for the second term please note you should read the syllabus that contains important details about how the subject works.

Next week we'll start with the lab again. Lab#6 is out too.
 

Marks are out

Not all of you have sent me your own grading of your exam. The reason I was asking you to do that is not because I can save some work this way but because I want you to have a look at your own answers. Most of your marks are quite close to what I've got, at least from the set of students who sent them to me.

You can check your mark on-line. There a few more students who have never attended lectures that will appear at the end of the list of names. This marks are not final as you still have a choice to check your exam. If you want to do that, please tell me so next week in the classroom (or send me an e-mail).

You can see we have a tie on the top performers. I want to congratulate both: Rasmus and Juliusz. Keep up the good work!

Solved 1st term exam Feb 2009

Feb2009 Solved

You know what you have answered. Now you know the right answers. So please check them out, use a binary logic (an answer is either right or wrong, and it scores or not) and calculate your mark and email it to me.

My mark after the exam ...

  1. Exam will be marked from 0 to 10 (being 10 the best mark possible).
  2. Attendance is already marked as a value from 0 to 1 (expressed as a %).
  3. Assignments have been marked too (0 to 2).
First term mark (again from 0 to 10) we'll be calculated as:

1st-term = attendance + (9-assignments)*exam/10 + assignments

Same process will hold for the second term. Course mark will be obtained by averaging both terms. There is not a minimum average you need to obtain on each term, but course average needs to be equal or higher than 5 points to pass the course.

To know more about threads synchronization


Assignment#2 presented you an scenario where multiple threads handle one client each. However, given that each thread has to send a text line to each any other thread's client, a synchronization problem may happen.

If all you use to test server's code is a few telnet clients running on your computer, it is difficult you see any problem (as only one client is typing at a time). If you're interested on researching this topic further, you may use IMTester.java code. This program will throw one hundred simultaneous clients to your server, each one sending on hundred text lines and then the mandatory quit command.

You may well see errors like this "Exception in thread "Thread-85" java.util.ConcurrentModificationException" on the server program. It basically means that an object was modified while others were reading from it (not a good thing). While I was not interested on raising this topic of synchronization, some of you pointed it out, so I cannot avoid explaining a bit more.

The main problem happens because the list of clients may change while one (or more) thread is iterating through it. If the client list changes while messages are being sent to other clients it is possible that either a client is missing the message or that a message is attempted to be delivered to client who is gone.

The solution is pretty simple but not obvious, and most of you failed to provide a proper one (not that it was a requirement though). I'm including an slightly modified version of my sample implementation for you that addresses the synchronization problem. The basic idea is that looping through client list and removing a client from the list are performed exclusively.

Update: A Vector object should have been used instead of ArrayList (as Vector is Thread safe and ArrayList is not).

Assignment #2 is marked


You should have got an email answer about your work. At any rate, marks are on the usual place (assignments tab). Those with a 0 mark still can try to fix it by Thursday 15th.

If any of you is missing a mark, please let me know.



You can have a look at my implementation.