Due by 11:59pm, Thursday, October 23.
struct message { int size; char *data; };
message.size
indicates the size of message.data
measured in bytes. The reliable data transport protocol requires the data in the
receiving node being delivered in order. It does not, however, require the
preservation of message boundaries.
The unit of data passed between the RDT layer and the lower layer is the packet, which is declared as:
#define RDT_PKTSIZE 64 struct packet { char data[RDT_PKTSIZE]; };This means that the lower layer always delivers packets in 64-byte chunks. Therefore, fragmentation may be necessary if the message passed from the upper layer is too big to fit into a packet.
The routines you need to implement are detailed below. Such routines in real-life would be part of the operating system.
void Sender_Init();
- sender initialization, called once at the
very beginning. This routine is here to help you. Leave it blank if you don't
need it.
Sender_Final();
- sender finalization, called once at the very end.
This routine is here to help you. Leave it blank if you don't need it.
void Sender_FromUpperLayer(struct message*);
- called when a message
is passed from the upper layer at the sender.
void Sender_FromLowerLayer(struct packet*);
- called when a packet
is passed from the lower layer at the sender.
void Sender_Timeout();
- called when the timer expires at the
sender.
void Receiver_Init();
- receiver initialization, called once at the
very beginning. This routine is here to help you. Leave it blank if you don't
need it.
void Receiver_Final();
- receiver finalization, called once at the
very end. This routine is here to help you. Leave it blank if you don't need it.
void Receiver_FromLowerLayer(struct packet *pkt);
- called when a
packet is passed from the lower layer at the receiver.
void Sender_StartTimer(double timeout);
- start the sender timer
with a specified timeout
(in seconds). This timer is canceled when
Sender_StopTimer()
is called or a new
Sender_StartTimer()
is called before the current timer expires.
Sender_Timeout()
will be called when the timer expires.
void Sender_StopTimer();
- stop the sender timer.
bool Sender_isTimerSet();
- check whether the sender timer is being
set, return true if the timer is set, return false otherwise.
double GetSimulationTime();
- return the local simulation time,
which may be useful in timer management. You should not assume that the time is
synchronized between the sender and receiver side.
void Sender_ToLowerLayer(struct packet*);
- pass a packet to the
lower layer at the sender for delivery.
void Receiver_ToLowerLayer(struct packet*);
- pass a packet to
the lower layer at the receiver for delivery.
void Receiver_ToUpperLayer(struct message*);
- deliver a message to
the upper layer at the receiver.
sim_time
- total simulation time, the simulation will end at this
time (in seconds).
mean_msg_arrivalint
- average intervals between consecutive messages
passed from the upper layer at the sender (in seconds). The actual interval
varies between zero and twice the average.
mean_msg_size
- average size of messages (in bytes). The actual size
varies between one and twice the average.
outoforder_rate
- the probability that a packet is not delivered
with the normal latency - 100ms. A value of 0.1 means that one in ten packets
are not delivered with the normal latency. When this occurs, the latency varies
between zero and 200ms.
loss_rate
- packet loss probability: a value of 0.1 means that one
in ten packets are lost on average.
corrupt_rate
- packet corruption probability: a value of 0.1 means
that one in ten packets (excluding those lost) are corrupted on average. Note
that any part of a packet can be corrupted.
tracing_level
- levels of trace printouts (higher level always
prints out more information): a tracing level of 0 turns off all traces, a
tracing level of 1 turns on regular traces, a tracing level of 2 prints out the
delivered message. Most likely you want to use level 1 for debugging and use
level 0 for final testing.
/u/cs257/Resources/assignment3/
on the csug network or at
/u/cs457/Resources/assignment3/
on the research/grad network.
The simulator is in
C++ so your code should be in C/C++ to work with my simulator. The RDT
layer is implemented in rdt_sender.cc
and rdt_receiver.cc
.
The current implementation assumes there is no packet loss, corruption, or
reordering in the underlying link medium. You will need to enhance them to deal
with all these situations. In general, you are not supposed to change
rdt_receiver.h
, rdt_sender.h
, rdt_struct.h
,
and rdt_sim.cc
. For debugging purpose, you may want to add more
printouts in rdt_sim.cc
. If you do so, definitely remember to test
your program with the original rdt_sim.cc
before turn-in.
As you can see, the main complexity of the simulator is enclosed in
rdt_sim.cc
. My intention is that you don't have to read and understand
this file to complete the assignment. You can ask for my assistance if you need
to understand it for some reason.
You should turn in a README file, the new rdt_sender.cc
,
rdt_receiver.cc
, and any new source files you added for your
implementation.
If the default makefile doesn't work for you, you should also turn in a new
makefile
. You should NOT turn in
rdt_receiver.h
, rdt_sender.h
, rdt_struct.h
,
and rdt_sim.cc
because we will use the original versions of those
files in grading. Make necessary explanation in your README file for your
turn-in.
rdt_sim 1000 0.1 100 0 0 0 0
to see what
happens. (Running rdt_sim
without parameters will tell you the usage of this program.)
In summary, the following are a few test cases you may want to use.
rdt_sim 1000 0.1 100 0 0 0 0
- there is no packet loss, corruption,
or reordering in the underlying link medium.
rdt_sim 1000 0.1 100 0.02 0 0 0
- there is no packet loss or
corruption, but there is reordering in the underlying link medium.
rdt_sim 1000 0.1 100 0 0.02 0 0
- there is no packet corruption or
reordering, but there is packet loss in the underlying link medium.
rdt_sim 1000 0.1 100 0 0 0.02 0
- there is no packet loss or
reordering, but there is packet corruption in the underlying link medium.
rdt_sim 1000 0.1 100 0.02 0.02 0.02 0
- there could be packet loss,
corruption, or reordering in the underlying link medium.