0
$\begingroup$

what will happen if we change "to_physical_layer(&s)" to "to_physical_layer(&r)" in the following code(marked in the code where)?

does it make the protocol fail? if so, show a scenario it will fail. if not - explain if there's an advantage or disadvantage in the change.

the code:

(simplex stop and wait protocol from tanenbaum's book):

typedef enum {frame-arrival} event_type;
#include "protocol.h"

void sender2(void){
  frame s;           // buffer for frame
  packet buffer;   // buffer for packet
  event_type event;  // frame_arrival only
  while (true) {
    from_network_layer(&buffer); // get packet
    s.info = buffer;        // copy it into frame
    to_physical_layer(&s);  // send it
    wait_for_event(&event); // wait for ack
  }
}

void receiver2(void) {
  frame r, s;        // buffers for frames
  event_type event;  // frame-arrival only
  while (true) {
    wait_for_event(&event);  // wait for frame
    from_physical_layer(&r);  // get frame
    to_network_layer(&r.info); // pass data
    question is regarding this line--> to_physical_layer(&s);
      // send a dummy frame to awake sender
  }
}

The question is not about programming in c, but about protocol Stop and Wait and the effects of changing a certain parameter in the marked line.

$\endgroup$
  • $\begingroup$ You'll probably need to make your question self-contained by showing the protocol, and by defining what '"stop and wait" (no noises)' means, and explain what r and s represent. It might also be helpful to include a reference for where you have written about this. You should also tell us what you mean by 'good', as that is ambiguous. Finally, I encourage you to share your thoughts. If you edit your question to clarify what you are asking, the question can be considered for re-opening at that time. $\endgroup$ – D.W. Apr 14 at 21:04
  • $\begingroup$ @D.W.L i forgot to include the code. now it is included and i really need help with that $\endgroup$ – Network Apr 15 at 21:07
  • $\begingroup$ I'm afraid that questions about code are typically off-topic here, and I suspect not everyone here reads C. Is it possible to specify the protocol using concise pseudocode, rather than C code? It looks like the protocol is merely that the sender sends something, and the receiver sends back a dummy packet as an ACK. Is that all there is to it? Are you really asking about what needs to be in the dummy packet? Also, I'm still looking for what you consider "good", or what properties you want the protocol to have; "good" sounds like it might be a matter of opinion. $\endgroup$ – D.W. Apr 15 at 22:12
  • $\begingroup$ @D.W: please check my edit now, i am hoping it makes more sense to you as i would really appreciate knowing how to solve this problem. $\endgroup$ – Network Apr 18 at 8:40
  • $\begingroup$ I've re-opened this, but some my comments haven't been addressed and I'm not entirely sure whether this complies with our expectations, as I have the impression that not everyone here reads C code. $\endgroup$ – D.W. Apr 18 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.