vod


Information

Created with NetLogo version NetLogo 3.1.3
Running with NetLogoLite.jar version 314.


WHAT IS IT?


-------
This section could give a general understanding of what the model is trying to show or explain.

HOW IT WORKS


--------
This section could explain what rules the agents use to create the overall behavior of the model.

HOW TO USE IT


---------
This section could explain how to use the model, including a description of each of the items in the interface tab.

THINGS TO NOTICE


------------
This section could give some ideas of things for the user to notice while running the model.

THINGS TO TRY


---------
This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.

EXTENDING THE MODEL


---------------
This section could give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc.

NETLOGO FEATURES


------------
This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.

RELATED MODELS


----------
This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.

CREDITS AND REFERENCES


------------------
This section could contain a reference to the model's URL on the web if it has one, as well as any other necessary credits or references.

Procedures

NetLogo Version: NetLogo 3.1.3

Globals[
         client_id 
         program_id
         dest_id 
         who_list
         request
         time
         next_arrival
         value1
         value2
         value3
         q_times
         cum_q_size 
         packets_waiting 
         Average_Q_Size 
         Average_Q_Time
         i
         j
         k
         l
         m
          ]
          
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
breed [ 
      packets packet 
      ] ;; packet turtles
      
breed [ 
      servers server 
      ] ;; VoD server 
      
breed [ 
     clients client 
      ] ;; VoD client
      
breed [
     links link
      ] ;; network links
      
breed [
     programs program
      ] ;; VoD program
      
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
packets-own [
    lable
    program_num
    q_start_time
    seq_num 
    complete?
    destination
    process_end_time 
            ]
            
programs-own [
    
    number_of_fram
    average_bit_rate 
             ]
             
clients-own [
    shown_program
        
            ]
            
servers-own  [
    list_of_program 
    current_packets
    busy? 
    start_time
           ]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to setup
ca
set value1 num_of_frames
set value2 num_of_programs
set value3 num_of_clients
set dest_id []
set who_list[]

while [ value2 < value3][
                          user-message " you must increase the number of programs "      
                           stop ]
                           
ask patches [set pcolor (black + 4) + (pycor mod 2) ]

ask patch-at 0 0 [sprout 1 
        [set breed servers
        set shape "computer server" set color blue set size 2]]
        

set i 1 
set client_id []
repeat value3 [ set i (i + 4)
    ask patch-at  -14 (i + 1)
         [sprout 1 
         [set breed clients
         set shape "computer workstation" 
         set color random(green + 7) 
         set client_id lput who client_id]]  ] 

  set j 0
  set program_id []
  repeat value2 [ ask patch-at (0 + j)(max-pycor) [sprout 1
         [set breed programs  
          set j (j + 2)
          set number_of_fram value1
          set shape "letter opened" 
          set color random(red + 3) 
          set program_id lput who program_id ]  ]] 
                       
    ;;set q_times []
    set Time 0.0
    set next_arrival 0.0
    ;;set cum_q_size 0
    ;;set Average_Q_Size 0
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to go
client_show
move_packet
stop
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to go_once
repeat 1[
client_show
;;move_packet
]

end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to stop1
stop
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to create_packet
       set i value2
       set l 1
       ;;while [Time >= next_arrival] [
        set k 0
        repeat i[ 
            set j 1
            repeat (value1)[
            ask patch-at (k) (max-pycor - j) [
            sprout 1 
            [set breed packets
            set shape "letter sealed"
            set lable "packet"
            set color random(yellow + 9)
            set seq_num j
            set program_num l
            set j (j + 1)
            set complete? false
            set q_start_time 0.0
            ]]]
            set k (k + 2)
            set l (l + 1)
            ;;]
            set next_arrival Time + random-poisson 0.5]
        
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to client_show
set i 1
set l  1
set j 0
set m [] 

repeat value2 [ set m lput l m 
                   set l (l + 1)]
repeat value3  [ set j one-of m
                  set m remove j m 
                  ask client i [
                  set shown_program j
                  set dest_id lput j dest_id]
                  set i (i + 1) ]
set_destination                
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to set_destination
set l 0
set i 1
set j 0

while [j < (length dest_id)][ repeat value1 [     ask packets with [(seq_num = i) and (program_num = (item j dest_id)) ]
                                    [set destination  (j + 1)]
                                     set i ( i + 1)]
                                     set i 1
                                     set j ( j + 1)]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to move_packet    ;jobs move down the screen unless they are queueing or being processed
    set i 1
    set j 1
    set l 0
    set k 0
 while[i <= value3][ while [j <= value1][  ask packet j [
      if (any? packets with [destination = myself ])
      [ set k xcor
      set l ycor
      receive_packets]
     set j (j + 1)]]
      set i (i + 1)]

end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to receive_packets

ask packets with [(seq_num = j) and (program_num = i) ]
                                    [set xcor  k
                                     set ycor l]
end

                    


Download Link

View or download the complete model file (to download: right-click, save-link-as):
-- Download vod --