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.

December 18th


Today's class was used to explain the basics of a P2P protocol that will be used for assignments #3 and #4. Same explanation is here.

Please note the text of the assignments will not be provided until the beginning of the second term lectures after the exams break.

Not sure how useful it will be ...


It's been suggested that having all the information in one place might be interesting. So I am putting everything together on a Google site (as an excuse to learn a bit about that feature).

First term last lab


You're required to write a concurrent web server. Here you have the source code of the lab (which appears written on the lab document). You're not supposed to waste your time re-typing it.

Second assignment is out


Now that assignment#1 is due I'm publishing assignment#2 text.

This second assignment is about writing a multithreaded server application for an instant messaging server. Not that you're going to program the next Messenger server (at least not yet) but I hope it'll be fun.

Please remember this assignment is due on January 12th, 2009.

Third lab

Some programming will be required for the third lab.

TCP sockets programming

Here you can find a copy of the source code java files I wrote during last class.

This is the client.

import java.net.Socket;
import java.io.*;
import java.util.Scanner;

class TestTCP {
public static void main(String args[]) throws java.net.UnknownHostException, java.io.IOException , java.lang.InterruptedException{
Socket s = new Socket ( "www.upv.es", 80 );
// Thread.sleep(100000);
PrintWriter output = new PrintWriter( s.getOutputStream(), true);
output.println("GET / HTTP/1.0");
output.println("");
Scanner input = new Scanner( s.getInputStream());
while(true) System.out.println(input.nextLine());
}
}


And this is the server code:

import java.net.*;
import java.io.*;
import java.util.Scanner;

class Server {

public static void main(String args[]) throws IOException, InterruptedException{
ServerSocket ss = new ServerSocket(8080);
while(true) {
Socket s = ss.accept();
Scanner input = new Scanner( s.getInputStream());
PrintWriter output = new PrintWriter( s.getOutputStream(), true);
System.out.println(input.nextLine()); // reads a line from the socket (client)
output.println("Hello client!");
s.close();
}
}
}



Please note that I detailed during the class some DOs and DON'Ts that not necessarily show in my (quick and dirty) code.

First assignment is out


You have till December 1st to turn in this first assignment. You may need to have a look to SMTP protocol specification (RFC 821). Please note that this RFC has been obsoleted by newer versions. However, for the purpose of this assignment, the original version of SMTP specs are ok.

Second chapter

Here you have second chapter slides and second lab too.

I know some of you still need to get a valid user account and I'm sorry. While this is not fixed, please ask the lab teacher to pair you with another student with a valid user account so you can do the lab.

Laboratory starts this week

Just in case you haven't noticed, lab sessions started October 13th. I'm afraid you may be looking for the English version of the lab I forgot to post :-(

1st chapter slides


As I mentioned today in the lecture, here you have the slides from Chapter 1. I have created a Google Docs spreadsheet that will contain all the relevant information about your performance (i.e. class attendance, assignments, etc).

Unfortunately today the service is not working nicely and at the moment I cannot even access that page. As soon as they are back on-line I'll post here the URL for that page.

It is advisable that you check your attendance record from time to time. Please report any error you may find as soon as possible.

Update: Attendance spreadsheet is back on-line.

Update2: Lab calendar is here.

Here we go again


A new course starts on Monday. Amazingly over 25 students are already enrolled on the group, this has to be an all times record for our subject. I want to welcome you all and I hope you'll enjoy the subject.

For the moment I'm only making the course syllabus available. All the slides and interesting materials will be added to this blog little by little. Feel free to go back in time too, but please be warned that links from years ago may no longer be working.

Applied knowledge to physical layer


Most of you are young enough not to have ever used a cassette tape as a digital storage system. But still you may feel curious about how it sounded and, even more important how it worked. This entry links to an article about using software to decode an old BASIC interpreter for Apple I computer.

Different techniques were used long time ago to create audio signals representing digital files that could be stored and recovered from a cassette using an inexpensive cassette player.

And we are back online!!

After one year of using the PoliformaT platform I've got enough. It might well be ok for some people but I'm not among them. I refuse to be a good well-trained monkey.

In what I think is the best interest of my students (and my own sanity) I'm recovering this blog as the vehicle to distribute the class material.

There are a number of reasons for this move:
  1. Students will no longer need to log-in to read any class related news.
  2. Visitors will now be able to see what's going on in the subject.
  3. Prospective students will learn what the subject is all about.
  4. I will be able to avoid to do a dance to upload a single comment or document. However I will have to add a comment with any document I add, which I find appropriated.
  5. Anyone could comment on the topics of the blog, whether they are enrolled in the subject or not.
  6. Availability will improve upon university's.
  7. I will be able to keep the English group of the subject apart from the noise of other languages' groups.
  8. Blogger's usability is miles away from the ugly and clunky interface of PoliformaT.
  9. We will be free to enjoy videos of any size (PoliformaT limits to 20 MB max which is a joke).
  10. Maybe the site will open up collaboration links with other universities.
  11. Site appearance could easily be changed (if I were not so lazy).

As an starter I'm posting here the solved exams of last June 9th, 2008.

Read this document on Scribd: solved exam 1st term


And the second semester's ...

Read this document on Scribd: Solved exam 2nd term


Please note that older material that is linked from previous entries may not work as it was lost after a hard disk crash. If you absolutely need to get any of them send me an email and I'll recover it for you.

Local storage is gone!

After the last storm the computer that used to act as this blog storage server gave up the ghost.
That means that the copies of laboratory exercises and course slides are gone too. Together with many of the documents referenced in this blog. I am not planning on restoring either the contents or the server anytime soon.

However, I will be posting each new document on the "private" PoliformaT site.

I have to let this blog go

I want to welcome all the new students. This blog has been the home for the English language class of the subject RED (code 5662). The format was simple (and sometimes even Internet Explorer rendered it properly) and you needed no silly authorization to download anything. However, the UPV in its infinite wisdom has decided to curtail the use of external tools, like this blog, in favor of their locally cooked version of Sakai they have named PoliformaT.

It seems that faculty not using this tool will be considered as doing no work on cyberspace. There is some money involved, don't get me wrong, we have a job to do and some money to make. By putting the carrot on the use of PoliformaT they are insuring all of us will end up using that platform whether it fits our (or your) needs or not.

For our English group it has been a constant cause of trouble the fact that students join us a bit later than the beginning of the term. Because of the involved paperwork, they use to come to the class sooner than they have got a username and password. Under the university instituted systems (so called microwebs and now PoliformaT) they have no access to course syllabus or slides. To address this problem I have been using for two years this blog (the fact blogger interface was cooler and simpler than the local alternatives did help too).

So from here I want to apology in advance for the possible trouble you are facing with this new move at the UPV. While technically I cannot claim this is censorship I would say they are giving as the same choice that Ford Motor Company gave to T-model customers: "You can choose any color you like as long as it is black".

September marks

!!! I am glad to inform you that after marking the exams all of you have passed the subject. Details can be found on the usual place.

Next September 11th

Those of you who haven't pass the subject yet do not forget exam will be held September 11th, at 4:00pm.

Course Marks available

On our usual place in the "exams" tab.

Results are quite disappointing as several people did not show up for the exam. Others did but failed the subject by not scoring good enough. Most of you did pass, for those of you, congratulations.

Those who did not pass the subject, please think whether you could have done better by turning in any of the assignments, showing up for the lectures more often, doing the lab exam and, perhaps, studying a bit more.

Anyway, you are welcome to review your exam so you see for yourself what was wrong. Drop me an email for a reviewing appointment.

Solved exam is now available.

Graded assignments

All the assignments turned in have been graded. Please go to the attendance/marks page to check yours.

So you want a video as reading is too hard ...

Here you have an interesting presentation:

Weekend reading

I mentioned today in the class I will post this article on one of the many network security battles. I guess the printer friendly version will remove most of the annoying advertising from the web page (but I was not sure the server would be happy about my referencing of a printer friendly page).

It seems that another one bites the dust in terms of getting their encryption system hacked (not that I am interested or worried as I do not have either content or player for that format).

Fourth assignment

It's only one month left so here is the last assignment for you. Please note its due date is May 28th.

Some people's comments about IPv6

Slashdot was publishing a note about the use of IPv6 in space. Some people found this an opportunity to voice their opinion about IPv6.

All you wanted to know about bit error rate but were afraid to ask

One important detail about BER (bit error ratio) is that it is an average value. If you use it as such there is no problem. But for if you have link whose BER=10^-4 and you transmit 10000 bits over that channel it is likely you won't get any error at all. The reason is that BER is an statistic but not a RULE.

If you want to learn more abot what this means, read on this interesting but yet accessible document.

Computer Networks by Andrew S. Tanembaum


It seems the book is also available for campus-wide access in electronic format (part of the O'Reilly Safari Books on-line package) so as far as you are part of the campus network either connected locally or by a VPN from your home you should be able to read the recomended chapter 4.

CRC java applet

This one will show you both the calculation and the associated circuit.

Green third assignment

It seems the current trend is all for recycling and reducing the waste we create. I am joining this effort now by presenting you a fully recycled third assignment about IP fragmentation.

Please note that the due date is wrong (recycling sometimes has some problems). The correct due date is April 6th.

Solved 1st term exam

Already available, just follow this link.

Marks will be available in a few days in this same site as an update of this post.

Update: Exam marks are available in the same link as the attendance pages. Please note that solved exam contained a couple of errors that have been now fixed, just download a fresh version.

Second Update: It seems that some of you have trouble doing the math to know your current score, so now you have that numbers on the mark's page. I repeat what I explained the first day of class and it is detailed in Chapter0 slides.
mark(%) = attendance*10/classes + (9-assignments)*exam/10  +  assignments*10  + lab
The underlying logic is that exam only accounts for 70% of the final mark if you pass two assignments, 80% if you pass one assignment or 90% if you did not pass (or did not turn in) any assignment. Also note that failing on an assignment has not any negative effect on your score.

The same logic will be applied to the second term marking and then, both marks will be averaged to obtain your final grade.

Please remember the pass mark is 50%, so if you score less than this you will have to work harder on the second term to pass the subject.

Lab exam is still being marked so it has not yet been accounted for.

Third Update: Now the lab mark has been included. Go and check yours!

1st term exam

To be held January 30th, classroom B-5 at 10:00am laboratory exam.

For those of you who missed one or more laboratory sessions the exam will start at 10:30am. Duration two and a half hours.

Telegraphy vs. e-mail

It seems the fight is over.

Second assignment solution


It might not be the cleanest approach but I try to keep the line count low. You may download this server code that performs as required on the assignment#2 text.

What you may find weird is the fact that a timeout message is printed every 10 seconds when an upload is not taking place (therefore block number is zero). If you do not like this you can add an "if" sentence not to print that unless block number is larger than zero, but for me it serves as a sign that the server is up and running even when a file is not being received.

Second assignment marks

Ramazan, Anna, Manuel, Javier and Edgar have turned assignment#2 in. All of them have passed, though there are some comments, read on.

Some of them had the creative idea that a timeout event can stop the server. Let me tell you that "the show must go on" whatever it happens to the server. So you need to treat (catch) any exception that might cause the server to stop working.

On the other hand, I asked explicitly for the received files to be named in a certain way. Again some of you did not follow this part of the specification.

Edgar made the important observation that the performance when transmitting with this system is quite poor. And he also pointed out the cause: The use of a stop and wait protocol where the round trip time compared with the transmission time is quite significant.

Finally, to all of you that for any reason did not send me your work I want to encourage you to do it next time. I really think that assignment work can help you to improve your practical knowledge of network programming. Think of it like a little challenge and try not to follow the advice on this page.

Class attendance and assignments records

By following this link you can check a copy of the records I keep about both attendance and assignments so you can double check them. If you detect an error please contact me ASAP to get it fixed.

Please bookmark it on your browser so you can return to it easily.

Second assignment is out


As promised here you have the second assignment work that deals with UDP network programming. As in the first assignment, it is a client/server application. Again you have to program a small server that receives files from the client and writes them down to disk.

I have chosen an "invented" protocol as there are lots of Java code out there for many standard protocols (including TFTP). The good news is that I tried to keep it as simple as possible. The bad news is that my skills at writing the protocol specification are not on par with a good RFC. As usual, feel free to ask me any question you may have about the assignment.

Although I know you can copy and paste the client's source code from the PDF file, you can also find the source code file here.

First assignment results


I want you to know that Javier, Edgar, Aitor, Ana, Ramazan and Manuel turned in their work. Unfortunately, one of them failed to meet the problem requirements but the rest pass the test with flying colors.

Congratulations, not bad for your first networking problem.

Those of you that did not turn in anything please remember there are still three other assignments to come.

Network programming is like riding a bike: None of you learnt it by reading a manual, did you?

The many uses this blog


I was reviewing last year's posts and I realized that many of the posts are applicable now as we are going through the same chapters at the same time. So instead of reposting the same entries I invite you to check last year's entries along the whole course and there you'll find useful information, interesting links and related material.

Please note that assignments are different.

Class attendance record

These are the attendance numbers so far (out of 13 classes).





















Ayoub10

Aitor13

Martin9

Luis Manuel8

Edgar10

Carlos8

Erol1

Ramazan12

Jakub1

Roberto2

Ana6

Manuel6

Javier11

Taha9

Carlos S1


Please note that some of you are joining the class quite late. I understand that you may have other subjects too, but please note you'll need some effort to catch up with the class.

Sample IM server application

I've created a server application like the one you have to write for assignment #1.

You'll find it running on port 7777 on the IP address 158.42.53.17. If for some reason it is not accepting your connections, please let me now, as a power outage might have happened on my side and manual restart would be needed.

Please note that the messages about a new client entering the server or a client leaving the server are not required on your code. I've just added them to give users a bit more of information.

News and reminders

Since Nov 16th we will be back to the "Seminari Nord" room. I've just posted the text of the first assignment, and I want to remind you that --although it is optional work-- doing it right will be worth 5 out of 100 points.

You do the four scheduled assignments right and you already have 20% of the subject.

You come to all the classes and you have 10% more.

Still not enough to pass the subject (you need 50%) but closer ...

Just a word of warning: Assignments are personal work, not team work. Your code will be checked against all the other submitters. If a copy is found all the involved parties will score 0% no questions asked. It is in your best interest to keep your work for yourself.

As with any other doubts you may have about the subject, I'm available during office hours for helping you solving them.

Programming Assignment #1

Instant Messaging Server

Your job is to write a Java application that will act as a the server for an Instant Messaging application. Clients will connect to the server [using a TCP connection] to talk to each other. Clients will type messages that are composed of one or more lines of text. Each time a user types a new line of text at the keyboard, that line will be transmitted to the server.

Each time the server receives a new line from any client, it will send a copy to all the clients but the one who sent it (i.e. to prevent a confusing double echo on the sending-client side).

Any client that wants to abandon the service MUST type a line with the text QUIT. Whenever the server receives such a line of text it will interpret its meaning, closing the socket this client was using. From them on, no attempt to send any more data to that client will happen (note: trying to send data to an already closed socket would trigger an exception).

Still, a client could leave the service by just closing the connection without the mandatory QUIT command. You do not need to manage that case though.

Your Code

Your code has to conduct the following tasks:

  1. Accept any number of simultaneous clients, but it is safe to assume no more than one hundred simultaneous clients.

  2. Retransmit any text line, including empty lines, to any active client but the one typing that text line.

  3. Not to retransmit those lines which only contents is the QUIT command. Any combination of upper and lower case characters should be accepted and recognized (i.e: both QuiT and quit should work too).

  4. The server program prints “NEW CLIENT” whenever a new client connects to the server and it prints “CLIENT GONE” when any client quits the system.

Some tips

  • Server listens on port 7777

  • You may use several telnet windows as clients of your server (for testing purposes) by just typing;

telnet localhost 7777

Due date

Your Java source code has to be submitted by email (address available on the front page) by Nov 30th.

If you have any doubt about the assignment I strongly suggest you to stop by my office during office hours (posted on the web).

News


I mentioned in the class this sample server program.

Next class will be held on Aula Informática, on the ground level, see the plane (click on the image to get a larger view).

A bird's eye view of the Internet


There are several projects aimed to provide such a view. This is just one of them.

A tree is built connecting lower level networks. As you can see a huge hierarchical view is shown, and that is just part of how it was the Internet some time ago as it is evolving on a daily basis.

Changing location

During the two first weeks of November we will have our classes in the "Aula Informática" so all of you can try for yourself with a networked computer how things really work. This will be from November the 2nd till November 10th.

FYI: For Your Information

Any submission to the IETF intended by the Contributor for publication as all or part of an IETF Internet-Draft or RFC and any statement made within the context of an IETF activity is considered an "IETF Contribution". Such statements include oral statements in IETF sessions, as well as written and electronic communications made at any time or place, which are addressed to:
  • the IETF plenary session,
  • any IETF working group or portion thereof,
  • the IESG, or any member thereof on behalf of the IESG,
  • the IAB or any member thereof on behalf of the IAB,
  • any IETF mailing list, including the IETF list itself, any working group or design team list, or any other list functioning under IETF auspices,
  • the RFC Editor or the Internet-Drafts function

All IETF Contributions are subject to the rules of RFC 3978 and RFC 3979.

Statements made outside of an IETF session, mailing list or other function, that are clearly not intended to be input to an IETF activity, group or function, are not IETF Contributions in the context of this notice.

Please consult RFC 3978 for details.

Welcome to all of you

I've just returned from a trip to a Finish university and I've discovered there are thrity eight people enrolled on the subject this year. This is definitely our best score ever and I just hope most of you will actually stick to the English group (I'm afraid that some of you might have ended in this group because other groups are full).

I'll see you all on Thursday,

Miguel

September news

I am glad to inform you that Rami passed the subject.

Antonio:
I'm glad to see you again enrolled in the subject. You are welcome to come to the class too, work permiting.

Still reading this blog?

Well, maybe you failed the subject, sorry.

On the other hand, if you are planning joining us next course, please be welcome and feel free stoping by my office (I'll be out of town week 38th though).

There is just another opportunity for you to take an exam next September 14th, Thursday, at 16:00.

Best of luck (not that I think it has lots to do with the outcome),

Dr. Sanchez