Faculty of Engineering and Mathematical Sciences 
Not logged in (login)

help3002


This forum is provided to promote discussion amongst students enrolled in Computer Networks (CITS3002).
 
Before posting a question here, you may like to read the article How To Ask Questions The Smart Way.
 
Options:
RSS cloud
Jump to:

Pseudo Code Marking Guide

13 of 768 articles shown, currently no other people reading this forum.
photo
From: ANONYMOUS
Date: Sun 7th Jun, 11:40pm
Actions: 
        Login-to-reply

 

Below is my answer for 2017 exam, question 1b) that I did under exam conditions

Class –Node
{
  SLOT_TIME = 52 // microseconds
  Messages_sent = 0
  Messages_received = 0

  Constructor - Node ()
  { 
    main_loop() 
  }
	
  Function - main_loop()
  {
    While (True)
      {
	// Ready to send returns a boolean
	If (Ready_To_Send())
	{
	  While (True)
            {
		Send_Message()
		Messages_sent++

		// Listen for a collision for 1 slot time
		// Returns true if collision, else false

		If (Listen_for_collision(SLOT_TIME))
		{
					
			// Determine random wait time
			Wait_time = random() * SLOT_TIME
			Sleep(wait_time)

                }
                Else 
                {
			Break
                }	
		
        }
        Else if (Messaged_Received())
        {
		Messages_received++
        }
      }
   }
}



To determine the maximum utilisation of the channel, the total number of messages 
received of all the nodes should be divided by the total number of sent messages of 
all the nodes

I was just wondering, what mark would an answer like this get and what improvements 
can be made?

Pseudo Code Marking Guide

photo
From: ANONYMOUS
Date: Mon 8th Jun, 10:08am
Actions: 
        Login-to-reply

 

Hi there, 

 From reading question 1b from 2017, it looks like Chris is asking us to create pseudo-code 
for a simulation (emphasis on simulation) and not pseudo-code for how the algorithm works 
(which is what you've written).

If that is right, then it'll be slightly more challenging and would look something like 
the SlottedAloha.c code that Chris wrote: 
https://teaching.csse.uwa.edu.au/units/CITS3002/labs/lab4/slottedaloha-soln.c

Pseudo Code Marking Guide

photo
From: ANONYMOUS
Date: Mon 8th Jun, 10:39am
Actions: 
        Login-to-reply

 

Hi Chris, 

Would something like this be correct for 2017 Q1b? 

def csma_one_persistent(nNode, nSlotTime, probNew):
  # set each node to true as all nodes want to transmit 
  transmit = [False] * nNode  # will produce an array of False for the num of nodes 
  
  # for each time slot 
  For slot in range(nSlotTime):
    nAttempting = 0 # set num attempting to transmit to zero 
    successfulNode = -1 # set -1 to indicate that no node was successful yet 
    
    # determine what nodes need to transmit or re-transmit during this time slot 
    For node in range(nNodes): 
      
      # does the node have a new transmission? 
      If not transmitting[node] and rand(0,1) < probNew:
        transmitting[n] = true # the node is attempting to transmit 
        successfulNode = n
        nAttempting = nAttempting + 1
      # does the node need to transmit (i.e. it waited for the next timeslot)? 
      Elif transmitting[n]:  
        successfulNode = n
        nAttempting = nAttempting + 1 
        
      If nAttempting == 1: # if I am the first node transmitting in this timeslot, then I 
have succeeded 
        nSuccess = nSuccess + 1
        transmitting[successfulNode] = false # set the node back to not needing to 
transmit (false)
        # All subsequent nodes will hear that there is already a transmission and NOT 
transmit, but wait for the next timeslot to transmit (i.e. it is one-persistent) 
    

nNodes = 10 # number of nodes wishing to transmit (arbitrarily assigned for this example) 
nSlotTime= 10000 # num of slots times for the simulation(arbitrarily assigned for this 
example). Each slot time represents 52 miliseconds  
probNew = 0.5 # probablility that a new message is to be sent 
csma_one_persistent(nNodes, nSlotTime, probNew)

Pseudo Code Marking Guide

photo
From: ANONYMOUS
Date: Mon 8th Jun, 10:41am
Actions: 
        Login-to-reply

 

Ignore the first comment # set each node to true as all nodes want to transmit  

Pseudo Code Marking Guide

photo
From: ANONYMOUS  O.P.
Date: Mon 8th Jun, 10:46am
Actions: 
        Login-to-reply

 

ANONYMOUS wrote:

> Hi there, 
> 
>  From reading question 1b from 2017, it looks like Chris is asking us to create pseudo-code 
> for a simulation (emphasis on simulation) and not pseudo-code for how the algorithm works 
> (which is what you've written).
> 
> If that is right, then it'll be slightly more challenging and would look something like 
> the SlottedAloha.c code that Chris wrote: 
> https://teaching.csse.uwa.edu.au/units/CITS3002/labs/lab4/slottedaloha-soln.c

Hi there,

I thought that initially but at the end of the question it says 'You are not being asked to 
develop a protocol using the cnet framework'

It is true though that it'll be a bit more challenging if it was

Pseudo Code Marking Guide

photo
From: ANONYMOUS
Date: Mon 8th Jun, 10:49am
Actions: 
        Login-to-reply

 

Hi there, 

Yes, but in the python pseudo code I posted above, that was just a simulation and doesn't have any 
relation to the cnet framework. 

Hopefully Chris clarifies soon! 

Pseudo Code Marking Guide

photo
From: Christopher M.
Date: Mon 8th Jun, 4:34pm
Actions: 
        Login-to-reply

 

ANONYMOUS wrote:

> Below is my answer for 2017 exam, question 1b) that I did under exam conditions
> .....

> To determine the maximum utilisation of the channel, the total number of messages 
> received of all the nodes should be divided by the total number of sent messages of 
> all the nodes
> 
> I was just wondering, what mark would an answer like this get and what improvements 
> can be made?


About 7or8 / 10 on the generous scale.
Important things to consider/add:

- it's based on Ethernet, so you need binary-exponential backoff, not just a random backoff.

- nodes can detect collisions that even they are not involved in (they did not cause), and that 
affects their determination of how long to backoff for.

- (trivial) don't forget to start/instantiate each of your Node()s.

Hope that helps.

Pseudo Code Marking Guide

photo
From: ANONYMOUS  O.P.
Date: Mon 8th Jun, 4:42pm
Actions: 
        Login-to-reply

 

"Christopher McDonald" <ch*i*.*c*o*a*[email protected]*a*e*u*a*> wrote:

> ANONYMOUS wrote:
> 
> > Below is my answer for 2017 exam, question 1b) that I did under exam conditions
> > .....
> 
> > To determine the maximum utilisation of the channel, the total number of messages 
> > received of all the nodes should be divided by the total number of sent messages of 
> > all the nodes
> > 
> > I was just wondering, what mark would an answer like this get and what improvements 
> > can be made?
> 
> 
> About 7or8 / 10 on the generous scale.
> Important things to consider/add:
> 
> - it's based on Ethernet, so you need binary-exponential backoff, not just a random backoff.
> 
> - nodes can detect collisions that even they are not involved in (they did not cause), and that 
> affects their determination of how long to backoff for.
> 
> - (trivial) don't forget to start/instantiate each of your Node()s.
> 
> Hope that helps.

Thanks Chris

That does help. I was going to add the code to construct the nodes but I though that was trivial. 
I'll add that in my answers if a similar question is in the exam

Pseudo Code Marking Guide

photo
From: ANONYMOUS
Date: Mon 8th Jun, 5:25pm
Actions: 
        Login-to-reply

 

Hi Chris, 

Just to clarify, if a question in the exam asks us to write pseudo code for a simulation of an 
algorithm, we shouldn't just provide the pseudo code for the algorithm itself right? Because that is 
what I think the OP of this post wrote. Whereas the pseudocode for the simulation would look something 
more like the 3rd post in this thread, correct? 

The question they were answering relates to 2017 Q1B: 

"Develop some pseudo-code, with a syntax similar to either Java or C, that simulates the behaviour of 
the 1-persistent CSMA/CD protocol over 10Mbps Ethernet.

The simulation should support N identical nodes, each wishing to transmit a frame to other nodes at 
random intervals. Assume that the Ethernet’s slot-time is 52 microseconds, and that collision detection 
and resolution takes exactly one slot-time." 

Pseudo Code Marking Guide

photo
From: Christopher M.
Date: Mon 8th Jun, 6:16pm
Actions: 
        Login-to-reply

 

ANONYMOUS wrote:

> Hi Chris, 
> 
> Just to clarify, if a question in the exam asks us to write pseudo code for a simulation of an 
> algorithm, we shouldn't just provide the pseudo code for the algorithm itself right? Because that is 
> what I think the OP of this post wrote. Whereas the pseudocode for the simulation would look something 
> more like the 3rd post in this thread, correct? 

Hi,

It depends how the question is worded.  If it just asks for pseudo-code, that's all it's asking for, and you're 
answering the question through the use of well chosen identifiers, variables/data structures, and control flow. And 
you can further support your answer with comments.

If the question asks "With the aid of some pseudo-code, explain how....."
then you should provide both some pseudo-code and written text to explain it and the concept being 'implemented'.

Pseudo Code Marking Guide

photo
From: ANONYMOUS
Date: Mon 8th Jun, 6:32pm
Actions: 
        Login-to-reply

 

Hi Chris, 

I was referring to the word "simulation" in the question. If it is a simulation, then we would need to set up timeslots and 
iterate through each one so that we can simulate collisions/success. 

If we're just asked to write pseudocode for an algorithm e.g. CSMA/CD 1-persistent, then the code that the OP wrote would be 
the answer. 

Pseudo Code Marking Guide

photo
From: Christopher M.
Date: Mon 8th Jun, 6:36pm
Actions: 
        Login-to-reply

 

ANONYMOUS wrote:

> Hi Chris, 
> 
> I was referring to the word "simulation" in the question. If it is a simulation, then we would need to set up timeslots and 
> iterate through each one so that we can simulate collisions/success.

There are many types of simulation - they do not all just involve time slots and packet collisions.
Although you won't be asked to produce any answers using the cnet code/API,  that was a form of simulation that didn't require you to set 
up time slots, etc.


 
> If we're just asked to write pseudocode for an algorithm e.g. CSMA/CD 1-persistent, then the code that the OP wrote would be 
> the answer.

Their answer providing just pseudo-code, without providing any additional written text, would be the correct/sufficient *form* of answer, 
but it was not a full answer.

Pseudo Code Marking Guide

photo
From: ANONYMOUS
Date: Mon 8th Jun, 6:39pm
Actions: 
        Login-to-reply

 

Ah, I understand now. Thanks for clarifying Chris :) 
This Page


Program written by: [email protected]
Feedback welcome
Last modified:  5:31am Aug 04 2020