NetRun Help
Logging In
If you don't yet have an account, or lost or don't trust
your randomly generated password, you can
reset your NetRun password here. NetRun passwords are long randomly generated strings.
The password reset script mails your randomly generated password
to your UAF email address. If you need to reset your UAF email
password, call the helpdesk at 474-6564. Once you have your NetRun
password,
you can log in to netrun.
How your Code Runs
NetRun's default mode is "Subroutine fragment". In this
mode, the code you write becomes the center of a function named "foo";
like this:
int foo(void) {
YOUR CODE HERE
}
If you want to declare your own new functions, switch the Mode popup to
"Whole subroutine (file)". NetRun's main program will still try
to call a function named "foo", so you have to name your top-level
routine foo.
If you want to write your own complete main program, switch the Mode
popup to "Whole program (main)". None of the builtin NetRun code
will be included, and you can define any routines you like.
You'll need to #include "lib/inc.c" to get the builtin NetRunroutines like print_int.
Saved Files
NetRun automatically saves everything you run under the "Run name:"
you enter. You can then go back to the saved version by clicking the
"Saved files:" link at the bottom of the page. If you use the same "Run
name" twice, it overwites the previous version. Be careful--this makes
debugging easier, but it also allows you to overwrite work!
Saved files with the same "prefix" are displayed together on one
line. NetRun defines a "prefix" as the whole run name up to the
first space, underscore or dot. So runs named "foo.bar",
"foo_you", and "foo is my name" will all show up under the line "foo:";
while "foobar" will get listed on its own line.
Header Files
A selection of useful header files are automatically included by NetRun. Currently, NetRun automatically includes:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <string>
#include "lib/inc.h"
The only NetRun-specific header is "lib/inc.h". The routines in lib/inc.h are documented below.
If you need to include additional headers, just switch to Whole
Subroutine or Whole Program mode, and write the appropriate #include.
Builtin NetRun Functions
There are a bunch of handy functions built in to NetRun. You
can see how they work if you check the project/lib/inc.c file inside
"Download this file as a .tar archive". In no particular order,
the routines are:
- int read_input(void);
Reads one integer from the standard input. Hit the "Enabled"
checkbox under "Input data", and type integers into this box.
This routine accepts any C/C++ formatted integer, so 0x10 is actually
treated as hex. The routine will complain if it can't parse an
integer.
Example: int i=read_input(); // i now contains value read from "Input data" box.
- int read_string(const char *dest);
Read a C string of up to 100 characters from standard input.
Example: char str[100]; read_string(str);
- void print_int(int i);
Print out an integer, in both decimal and hexadecimal.
Example: print_int(0xff); // Prints 255 and 0xff.
- double time_in_seconds(void);
Returns the current wall-clock time, in seconds. The timer
resolution is milliseconds on UNIX machines, but only 60ms on Windows.
Example: double t=time_in_seconds(); // t now contains the wall-clock time
- double time_function(timeable_fn fn);
Returns the number of seconds taken by one execution of this user
function. The function is run many times, in order to stay
accurate even with coarse timers. A "timeable_fn" is just a
function that takes no arguments and returns an int.
Example: double t=time_function(bar); // bar takes t seconds per call
- void print_time(const char *fnName,timeable_fn fn);
Prints
out the speed of this function, in time per call. "fnName" is
just used for the printout. The "Time" checkbox (under "Actions")
actually calls print_time on the central foo routine, although it
always prints foo's time in nanoseconds.
Example: print_time("Bar routine takes",bar); // Prints time taken by bar function
- int iarray_print(int *arr,int n);
Print out the entries in this n-element int array. Will only
print selected values for arrays with more than 10 elements.
Always returns n.
Example: int arr[7]=...; iarray_print(arr,7);
- void farray_fill(float *f,int n,float tol);
Fills up this array with more or less random floating-point
values. Always puts a fixed value in f[n]. The values will
range from 0 to 255*tol.
Example: float f[11]; farray_fill(f,10,1.0); // Fills up f[0..10] with random values.
- int farray_checksum(float *f,int n,float tol);
Computes the checksum of the floating-point values in this array. Checks the fixed value in f[n] put there by farray_fill.
Example: return farray_checksum(f,10,1.0); // Returns a 16-bit checksum of the values in the array.
All these routines are accessible from both C and C++, and they work the same way in both languages.
Debugging in Assembly Language
The main program prints out the value returned from the "foo"
subroutine you write, and x86 subroutines return their value in register eax,
so you can see what's in register eax by just returning--it'll get printed out.
At the moment, there's no easy way to see what's in all the registers
other than intentionally crashing, like doing a read-from-NULL:
mov eax,[0]
You get an informative printout when you
crash because NetRun registers a whole set of signal handlers (for
segmentation fault, floating point exception, illegal instruction,
etc.). If you're interested in how this works, use the "Download
this file as a .tar archive" link and read project/lib/signal.c.
Reading Input in Assembly
- Say "extern read_input" and "call read_input" as the FIRST TWO LINES in your assembly
program.
This routine may trash (i.e., change) all other registers, so be sure
to call it before doing anything else! read_input, like any
subroutine, returns its value in the eax register.
- Use eax as input to whatever computation you need to do.
- In the NetRun GUI, click "Input Data": "Enabled" to display the input
data edit box.
- Enter the program's input data--just numbers--in the input data edit
box.
- Hit "Run!". The program will read the input you've typed
in.
You can call "read_input" from C or C++, too--it takes no parameters, and
returns the integer read in.
NetRun Hardware
The NetRun machine is an Intel Pentium 4 running at 2.8GHz. Hyperthreading is enabled, with
two CPU frontends sharing the same arithmetic backend. The L2 cache is 1024KB.
Security in NetRun
The main NetRun CGI is a Perl script. You're welcome to download that Perl script, using the "Download all saved files as a big .tar.gz archive"
link. This Perl script runs in taint mode, and uses regular
expressions to check for dangerous characters in the input data.
It has extensive logging, and everything you run is marked with your
username. This means you should not expect to get away with
attempting to hack into NetRun itself.
Your executable programs run with a variety of restrictions, enforced by the kernel:
- You cannot run for more than 2 seconds, or NetRun will print "Killing program--ran too long!".
- You cannot use more than 100 MB of memory, or further allocations just fail.
- Your program is running in a "chroot" jail, so you can't access any files on the machine.
- Your program runs as a nobody user. You have no rights.
To avoid these restrictions, download a tar file of your project, and run it on your machine.
O.
Lawlor, ffosl@uaf.edu
CS, UAF