Sunday, December 27, 2009

NS2 trace file format

I was recently working on my NS2 simulation project. When I first wrote the sim script, I needed to visualize it using NAM (the network animator, see http://www.isi.edu/nsnam/nam/). Now I need to measure throughput and packet latency. So I found this website http://hpds.ee.ncku.edu.tw/~smallko/ns2/tool_en.htm with an example script to do just that. But when testing it after a few modifications I realized that it expects a different NS2 trace file format than the one my scripts have. What the hell?

A little bit more reading led to me to realize that a parameter I set in order to use my tracefiles with NAM changes the trace format. The nam trace format is described in http://www.cubinlab.ee.unimelb.edu.au/~jrid/Docs/Manuel-NS2/node506.html


Thursday, December 24, 2009

Apache basic authentication:

Say you are using apache web server (tested on version 2.2) to publish a website hosted under a given directory (say /home/eortega/public_html/limesurvey_server7/) and you want to protect access to it by using basic authentication (i.e. a username and password must be provided by the client browser to access the contents, and the user names and passwords are stored on a text file). You need to do the following:

1. Create a .htaccess file on the directory, namely:

/home/eortega/public_html/limesurvey_server7/.htaccess

with the following content:

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /home/eortega/public_html/limesurvey_server7/.htpasswd
Require user eortega

2. Create a password file as specified in the .htaccess file. In this example, it is /home/eortega/public_html/limesurvey_server7/.htpasswd
To create this file, you must use apache´s htpasswd utility as follows:

htpasswd -c /home/eortega/public_html/limesurvey_server7/.htpasswd eortega

This means "create .htpasswd file under /home/eortega/public_html/limesurvey_server7/ and add password for user eortega" (password is prompted on the console).

I hope this helps.

oh, yeah, and merry christmas.


Sunday, December 6, 2009

PostGIS - Error about using two geometries with different SRIDs

Hi:

This term for my master's degree I took a class on GIS. It disappointed given the lack of theoretical background taught by the professor, but I liked the applications very much. Roughly, these were the main interesting topics (for me, anyway):

1. Using GvSIG with layers from SHP files.
2. Using QGis with layers from SHP files.
3. Using GvSIG with layers from Web Map Services (WMS).
4. Using PostGIS (install, basic querying, importing layers form SHP, etc.).
5. Using QGis with layers from PostGIS database.

While working on the final project, I was trying to write a query to create a new layer from the intersection of two preexisting layers (tables in the DB). So I was using calls like ST_intersection(table_a.the_geom, table_b.the_geom) on the query, but Postgres refused to work telling me I was doing operations on geometries with different SRIDs. I went to the the geometry_columns table (where postgis stores the references to all geometry columns on the database, along with their SRID, column name, table name, etc.), and found that one of the tables had the wrong SRID associated. I thought it would be enough to just update it to the right value. WRONG. It did not work, postgis still complained about the different SRIDs. SO I googled around a little and found a fix for this.

First, you need to update the SRID of the geometry you want to fix to the correct value. This is basically what I tried to do, but the correct way to do it is not by updating values on the table. PostGIS provides a nice function for this:

select updategeometrysrid('cultivos_ilicitos', 'the_geom', 21897);

Here, cultivos_ilicitos is the table I want to fix, the_geom is the name of the column that has the geometries, and 21897 is the EPSG code of the SRID. This is the first part of the fix. Now, you have to tell postgis to modify any geometries that are stored on the_geom column of the cultivos_ilicitos table, so that they are referenced to the correct SRID. You can do this by running the following:

select setsrid(the_geom, 21897) from cultivos_ilicitos;

So basically, the first instruction fixed the geometry_columns table, while the second one fixes the actual geometries stored on the table with the layer of interest.

I hope this is useful for someone out there.



Tuesday, March 10, 2009

How to install NS 2.33 under Ubuntu (tested on 8.04)

Task: install ns2 2.33 on ubuntu using the install script of the all in one package.

Symptom: you get an error about not having X includes even after you have installed build-essential and libx11-dev.

Solution: do the following:

sudo apt-get install build-essential autoconf automake libxmu-dev xlibs-static-dev xlibs-data x-dev xorg-dev

Then run install script.