These are answers to questions I've received about the assignment from students.
clientOutput()
set_pkt_data()
torch: ~/CS3171/A4$ make simABP torch: ~/CS3171/A4$ gcc -ansi -pedantic -g -Wall -I. -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -c KRnet.c timer.c:127: warning: `checktimer' defined but not used gcc -ansi -pedantic -g -Wall -I. -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -c packet.c gcc -ansi -pedantic -g -Wall -I. -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -c message.c gcc -ansi -pedantic -g -Wall -I. -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -c queue.c gcc -ansi -pedantic -g -Wall -I. -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -c -o ABP/client.o ABP/client.c ABP/client.c:47: warning: `startTimer' defined but not used ABP/client.c:52: warning: `cancelTimer' defined but not used ABP/client.c:38: warning: `sendToNWSlayer' defined but not used ABP/client.c:42: warning: `deliverToAppLayer' defined but not used gcc -ansi -pedantic -g -Wall -I. -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -c -o ABP/server.o ABP/server.c ABP/server.c:47: warning: `startTimer' defined but not used ABP/server.c:52: warning: `cancelTimer' defined but not used ABP/server.c:38: warning: `sendToNWSlayer' defined but not used ABP/server.c:42: warning: `deliverToAppLayer' defined but not used gcc -ansi -pedantic -g -Wall -I. -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes KRnet.o packet.o message.o queue.o ABP/client.o ABP/server.o -o simABP -lm torch: ~/CS3171/A4$
clientOutput()
clientOutput()
receives type
message_t
messages. Do we have to create multiple
packets of this message or do we assume that each message can be
stuffed in one packet.
set_pkt_data()
set_pkt_data()
takes a char*
for
its last argument. But what we are getting is
message_t
type. How can this be?msg_data()
to access the field, andstrncpy()
(from
<string.h>
) to copy the
char*
variable.set_pkt_data()
has a field for
ack_num
, but in unidirectional flow a client does
not need to send any ACK to server. Is it appropriate to set this value to a
constant or should we just ignore this value?message_t
and
packet_t
are opaque types, i.e. your code can only use them through the interface
that is provided. This happens often in real world
programming.
You must use set_pkt_data()
to set the values and
the pkt_*()
functions to read
the values. A simple way to set only the checksum field of
packet_t packet
to a
value x
, for example, would be:
set_pkt_data(packet, pkt_seq(packet), pkt_ack(packet), x, pkt_data(packet));
If you are (overly) worried about the efficency of this method then remember that the compiler has access to all of the information and could optimize away the function calls.
Reliable data transfer over a Lossy Channel with Bit Errors).
TRACE==4
. What's wrong?
clientCanSendMorePkt()
function is called by the
simulation to make sure that the client is ready to send
another packet. If that function is not working then your
data will not leave the client.
KRtime
?
extern float KRtime;
clientEnd()
and serverEnd()
to print them.
You will need to compute the division manually because no part of the simulation code has access to all of the variables. Include the answer for a typical run of your program (with the parameters you used, and so on) in a comment at the top of your client.c file.
data sent divided by total data transmittedwhat exactly do you mean?
bytes sent (successfully or unsuccessfully) divided by bytes sent (successfully or unsuccessfully) + acknowledgments sent (successfully or unsuccessfully)