1. include stdlib.h 2. add function prototypes at the top of the file for init, generate_next_arrival, and insertevent. 3. declared functions that don't return anything as void. 4. cast a bunch of constants to float. 5. removed a couple of unreferenced local variables. 6. set mmm to RAND_MAX in function jimsrand. 7. exit takes an argument under windows (i.e. exit(0) instead of exit()) 8. removed redefinitions of malloc (it is already declared in stdlib.h.)I'm impressed. You must have put a lot of time into this. I included the whole modified file in case you wanted to take a look.
Well, thanks. Here
is the modified code (modification to the code I handed out) that this
student turned in. I have not tried that code myself.
Change exit() to exit(0) if this is a problem.
Some compilers will do this. You can change the name of my emulator's
time variable to simtime or something like that.
My timer code is OK (hundreds of students have used it). The most
common timer problem I've seen is that students call my timer routine and
pass it an integer time value (wrong), instead of a float (as specified).
Yes.
To make jimsrand() work on the edlab Alphas, the variable mmm should
be set to RAND_MAX (it may be necessary to include stdlib.h to get this
constant).
This is there in case you want to implement bi-directional data
transfer, in which case you would want a timer for the B->A data path.
You can assume that the three way handshake has already taken place.
You can hard-code an initial sequence number into your sender and receiver.
A hack would be to use negative numbers for NAKs. I probably should
have included an explicit ACK/NAK bit in the packet definition.
The would be no need to use the sequence number (or you could set
it to a default value like -1) if there is no data in the packet.
Offhand I'm not sure whether this applies to your code, but it seems
most of the problems with seg. faults on this lab stemmed from programs
that printed out char *'s without ensuring those pointed to null- terminated
strings. (For example, the messages -- packet payloads -- supplied by the
network emulator were not null-terminated) This is a classic difficulty
that trips up many programmers who've recently moved to C from a more safe
langauge.