コード例 #1
0
ファイル: wrapper.py プロジェクト: morphheus/distrib-synch
def dec_wrap2():
    """Declaration function. It initializes all the relevant parameters to the simulatiions """

    # Broadcast parameters
    p = lib.SyncParams()
    p.zc_len = 31 # Length of the ZC sequence to use
    p.f_symb = 30.72e6 # "true" sampling rate
    p.f_samp = p.f_symb*4 # oversampling rate. SHould be an integer factor of p.f_samp. This factor is the oversampling factor
    p.repeat = 1 # Repeat the synchronization signal
    p.spacing_factor = 1 # Spacing between the raisedcosines. A factor of 1 uses the standard definition, where 
                         # one symbol is placed every 
    p.power_weight = 2 # Exponent \gamma 
    p.full_sim = True # Leave true
    p.bias_removal = False # Utilization of the bias removal algorithm
    p.ma_window = 1 # If bigger than 1, applies a moving average on the crosscorrelation R_yz
    p.train_type = 'chain' # 'single': only one ZC sequence makes up the synchronization systemm
                           # 'chain' : pair of ZC sequence with opposite root parameter
    p.crosscorr_type = 'match_decimate' # don't touch
    p.match_decimate_fct = lib.downsample # lib.downsample corresponds to a standard idealized analog-digital sampler
    p.peak_detect = 'wavg'  # 'wavg':   Performs a weighted average on the crosscorrelation to determine the location of the
                            #           synchronization signal
                            # 'argmax': Takes the max of the crosscorrelation instead of a weighted average
    p.pulse_type = 'rootraisedcosine' # Analog shaping pulse
    p.plen = 31   # Length of the raisedcosine pulseshape
    p.rolloff = 0.2 # Raisedcosine rolloff factor. A value of 0 corresponds to a normalized sinc
    p.central_padding = 0 # Pad zeros between the pair of ZC sequences. As a fraction of zpos length
    p.scfdma_precode = True # Apply SCFDMA?
    p.scfdma_L = 4  # SC-FDMA factor
    p.scfdma_sinc_len_factor = p.scfdma_L # Used for the demodulation of SC-FDMA in a decentralized setting

    #------------------------
    # Simulation parameters
    ctrl = SimControls()
    ctrl.steps = 40 # Approximately how many T_0 synchronization steps will be executed
    ctrl.basephi = 40000 # How many oversamples per period T_0? T_0 = basephi*p.f_samp 
    ctrl.nodecount = 35 # Number of nodes to simulate
    ctrl.display = True # Display stuff for a single simulation
    ctrl.static_nodes = 0 # Nodes that broadcast but do not synchronize
    ctrl.quiet_nodes = 0 # Nodes that synchronize but do not broadcast
    ctrl.quiet_selection = 'random' # How are quiet nodes assigned
    #ctrl.quiet_selection = 'kmeans' 

    # Parameters specific to the contention method (sensing)
    ctrl.qc_threshold = 5 # As a factor of the outage threshold
    ctrl.qc_steps = 3

    # Initialization parameters
    ctrl.CFO_step_wait = float('inf') # Use float('inf') to never correct for CFO. CFO CORRECTION DEPRECATED!
    ctrl.TO_step_wait = 4 # How many synchronization steps to wait before broadcasting. In factors of T_0
    ctrl.max_start_delay = 7 # nodes are onlined between t \in [0, max_start_delay]. In factor of T_0
    ctrl.use_ringarr = True # Use True unless you want to blow up your RAM
    ctrl.theta_bounds = [0,1] # bounds for the uniform distribution of \theta
    ctrl.deltaf_bound = 3e-2 # bounds for the uniform distribution of \delta f between the nodes. 
    ctrl.rand_init = False # Randomly initiate values?
    ctrl.non_rand_seed = 1238819 # If rand_init = False, the 'random' values in the simulation will be initiated with this seed
    ctrl.epsilon_TO = 0.5
    ctrl.noise_power = -101 + 9 # Reception thermal noise. -101 + 9 : thermal noise + receiver noise amplification.
    #ctrl.noise_power = float('-inf') # Use if you want a noiseless simulation

    # Multipath parameters
    ctrl.delay_params = lib.DelayParams(lib.delay_pdf_3gpp_exp) # corresponds to 3gpp specifications
    ctrl.delay_params.taps = 50 # How many multipath taps?

    # The next variable is badly named. it correponds to half the side of a square area
    # ctrl.max_dist_from_origin = 500 corresponds to an area of (1000m)^2
    ctrl.max_dist_from_origin = 500 # (in meters)

    # Half-duplexing method. Use at your own risk
    ctrl.half_duplex = False
    ctrl.hd_slot0 = 0.3 # in terms of phi
    ctrl.hd_slot1 = 0.7 # in terms of phi
    ctrl.hd_block_during_emit = True
    ctrl.hd_block_extrawidth = 0 # as a factor of offset (see runsim to know what is offset)

    # Variable adjustement window size. Use at your own risk
    ctrl.var_winlen = False
    ctrl.vw_minsize = 5 # as a factor of len(p.analog_sig)
    ctrl.vw_lothreshold = 0.1 # winlen reduction threshold
    ctrl.vw_hithreshold = 0.1 # winlen increase threshold
    ctrl.vw_lofactor = 1.5 # winlen reduction factor
    ctrl.vw_hifactor = 2 # winlen increase factor

    # Outage detection. Only broadcast of "near" outage. E-mail [email protected] for more 
    # explanation on how it works
    ctrl.outage_detect = False # thesis
    #ctrl.outage_detect = True # INTERD
    ctrl.outage_threshold_noisefactor = 1/(p.zc_len)*2

    # COrrect propagation delay by applying some filter.
    # lib.highpass_avg(6) corresponds to a filter of length Q=6, as described in my thesis
    ctrl.prop_correction = True
    ctrl.pc_step_wait = 0
    ctrl.pc_b, ctrl.pc_a = lib.hipass_avg(6) #THESIS
    ctrl.pc_avg_thresh = float('inf') # If std of N previous TOx samples is above this value, then
    ctrl.pc_std_thresh = float(80) # If std of N previous TOx samples is above this value, then
                                   # no PC is applied (but TOy is still calculated)
    
    # Save values to disk?
    ctrl.saveall = True

    #-------------
    # To run multiple simulations in bulk, a dictionary of modification to ctrl (cdict) and modifications to p
    # (pdict) can be used to iterate over multiple configurations
    # Note that any parameter to p or ctrl can be iterated this way

    # For example, this will iterate over 5 configurations, from right to left. Each iteration assigns 
    # the value to the property and runs the simulations. See SimWrap for more details
    cdict = {
        'prop_correction':[False, True , True , True , True ],
    }
    pdict = {
        'scfdma_precode': [False, False, False, True , True ],
        'bias_removal':   [False, False, True , False, True]
    }


    #cdict = {
    #    'noise_power':[x for x in range(-120,-91,2)]
    #    }
    #pdict = {}

    #cdict = {
    #}
    #pdict = {}

    return ctrl, p, cdict, pdict
コード例 #2
0
ファイル: thygraphs.py プロジェクト: morphheus/distrib-synch
def dec_r12():
    """Single ZC sequence with Decimation"""
    p = lib.SyncParams()
    p.zc_len = 31
    p.plen = 31

    p.rolloff = 0.2
    p.f_symb = 30.72e6
    p.f_samp = p.f_symb*4
    p.repeat = 1
    p.spacing_factor = 1

    p.power_weight = 2
    p.full_sim = True
    p.bias_removal = False
    p.ma_window = 1 # number of samples to average in the crosscorr i.e. after analog modulation
    p.train_type = 'single' # Type of training sequence
    p.crosscorr_type = 'match_decimate' 
    p.match_decimate_fct = lib.downsample
    p.peak_detect = 'argmax' 
    p.pulse_type = 'rootraisedcosine'
    p.central_padding = 0 # As a fraction of zpos length
    p.scfdma_precode = False
    p.scfdma_L = 4 
    p.scfdma_sinc_len_factor = p.scfdma_L

    ctrl = SimControls()
    ctrl.steps = 20
    ctrl.basephi = 6000 #Thesis
    #ctrl.basephi = 122880 #Interd
    ctrl.nodecount = 15
    ctrl.display = True
    ctrl.static_nodes = 2
    ctrl.quiet_nodes = 0
    #ctrl.quiet_selection = 'kmeans'
    ctrl.quiet_selection = 'random'
    #ctrl.quiet_selection = 'contention' # Note this renders ctrl.quiet_nodes uiseless, and requires the use of outage detectection
    ctrl.qc_threshold = 5 # As a factor of the outage threshold
    ctrl.qc_steps = 3

    ctrl.CFO_step_wait = float('inf') # Use float('inf') to never correct for CFO
    ctrl.TO_step_wait = ctrl.steps*2
    ctrl.max_start_delay = 7 # In factor of basephi

    ctrl.use_ringarr = True

    ctrl.theta_bounds = [0,1] # In units of phi
    ctrl.deltaf_bound = 3e-2
    #ctrl.deltaf_bound = 0
    ctrl.rand_init = False
    ctrl.epsilon_TO = 1
    #ctrl.non_rand_seed = 2810438 # Only used if rand_init is False
    ctrl.non_rand_seed = 12819 # Only used if rand_init is False
    #ctrl.noise_power = float('-inf')
    ctrl.noise_power = -101 + 9 # in dbm

    ctrl.delay_params = lib.DelayParams(lib.delay_pdf_3gpp_exp)
    ctrl.delay_params.taps = 5
    #ctrl.delay_params.shadowing_fct = lambda : 0
    ctrl.max_dist_from_origin = 500 # (in meters)
    #ctrl.max_dist_from_origin = 1000 # (in meters)
    #ctrl.max_dist_from_origin = 1000 # (in meters)
    #ctrl.max_dist_from_origin = 2000 # (in meters)

    ctrl.half_duplex = False
    ctrl.hd_slot0 = 0.3 # in terms of phi
    ctrl.hd_slot1 = 0.7 # in terms of phi
    ctrl.hd_block_during_emit = True
    ctrl.hd_block_extrawidth = 0 # as a factor of offset (see runsim to know what is offset)

    ctrl.var_winlen = False
    ctrl.vw_minsize = 5 # as a factor of len(p.analog_sig)
    ctrl.vw_lothreshold = 0.1 # winlen reduction threshold
    ctrl.vw_hithreshold = 0.1 # winlen increase threshold
    ctrl.vw_lofactor = 1.5 # winlen reduction factor
    ctrl.vw_hifactor = 2 # winlen increase factor


    #ctrl.outage_detect = False # thesis
    ctrl.outage_detect = True # INTERD
    ctrl.outage_threshold_noisefactor = 1/(p.zc_len)*2

    ctrl.prop_correction = False
    ctrl.pc_step_wait = 0
    ctrl.pc_b, ctrl.pc_a = lib.hipass_avg(6) #THESIS
    #ctrl.pc_b, ctrl.pc_a = lib.hipass_avg(10) #INTERD
    ctrl.pc_avg_thresh = float('inf') # If std of N previous TOx samples is above this value, then\
    ctrl.pc_std_thresh = float(80) # If std of N previous TOx samples is above this value, then\
                     # no PC is applied (but TOy is still calculated)
    
    ctrl.saveall = True


    cdict = {}
    pdict = {}

    return ctrl, p, cdict, pdict
コード例 #3
0
ファイル: thygraphs.py プロジェクト: morphheus/distrib-synch
def dec_regimes():
    """Single ZC sequence with Decimation"""
    p = lib.SyncParams()
    p.zc_len = 73
    p.plen = 61

    p.rolloff = 0.2
    #p.f_samp = 4e6
    #p.f_symb = 1e6
    p.f_symb = 30.72e6
    p.f_samp = p.f_symb*4
    p.repeat = 1
    p.spacing_factor = 1 # CHANGE TO TWO!

    p.power_weight = 2
    p.full_sim = True
    p.bias_removal = True
    p.ma_window = 1 # number of samples to average in the crosscorr i.e. after analog modulation
    p.train_type = 'chain' # Type of training sequence
    p.crosscorr_type = 'match_decimate' 
    p.match_decimate_fct = lib.md_clkphase
    p.peak_detect = 'wavg' 
    p.pulse_type = 'rootraisedcosine'
    p.central_padding = 0 # As a fraction of zpos length


    ctrl = SimControls()
    ctrl.steps = 40 # Approx number of emissions per node
    ctrl.basephi = 6000 # How many samples between emission
    ctrl.display = True # Show stuff in the console
    ctrl.keep_intermediate_values = False # Needed to draw graphs
    ctrl.nodecount = 20 # Number of nodes
    ctrl.static_nodes = 0
    ctrl.CFO_step_wait = float('inf') # Use float('inf') to never correct for CFO
    ctrl.TO_step_wait = 3
    ctrl.max_start_delay = 8 # In factor of basephi

    ctrl.theta_bounds = [0.2,0.8] # In units of phi
    #ctrl.theta_bounds = [0.48,0.52] # In units of phi
    #ctrl.theta_bounds = [0.5,0.5] # In units of phi
    #ctrl.theta_bounds = [0,1] # In units of phi
    ctrl.deltaf_bound = 3e-2
    #ctrl.deltaf_bound = 0
    ctrl.rand_init = False
    ctrl.epsilon_TO = 0.5
    ctrl.non_rand_seed = 11231231 # Only used if rand_init is False
    ctrl.noise_power = float('-inf')
    #ctrl.noise_power = -101 + 9 # in dbm

    ctrl.delay_params = lib.DelayParams(lib.delay_pdf_3gpp_exp)
    ctrl.delay_params.taps = 5
    ctrl.max_dist_from_origin = 250 # (in meters)
    ctrl.delay_params.max_dist_from_origin = 250 # (in meters)
    ctrl.delay_params.p_sigma = 500 # Paths sigma

    ctrl.half_duplex = False
    ctrl.hd_slot0 = 0.3 # in terms of phi
    ctrl.hd_slot1 = 0.7 # in terms of phi
    ctrl.hd_block_during_emit = True
    ctrl.hd_block_extrawidth = 0 # as a factor of offset (see runsim to know what is offset)

    ctrl.var_winlen = False
    ctrl.vw_minsize = 5 # as a factor of len(p.analog_sig)
    ctrl.vw_lothreshold = 0.1 # winlen reduction threshold
    ctrl.vw_hithreshold = 0.1 # winlen increase threshold
    ctrl.vw_lofactor = 1.5 # winlen reduction factor
    ctrl.vw_hifactor = 2 # winlen increase factor
    

    ctrl.prop_correction = False
    ctrl.pc_step_wait = 0
    #ctrl.pc_b, ctrl.pc_a = lib.hipass_filter4(11, pi/1000, 0.5)
    #ctrl.pc_b, ctrl.pc_a = lib.hipass_semicirc_zeros(11, pi/4, 0.1)
    #ctrl.pc_b, ctrl.pc_a = lib.hipass_filter4(11, pi/4, 1)
    #ctrl.pc_b, ctrl.pc_a = lib.hipass_remez(20)
    #ctrl.pc_b, ctrl.pc_a = lib.hipass_butter(8)
    #ctrl.pc_b, ctrl.pc_a = lib.hipass_cheby(8)
    ctrl.pc_b, ctrl.pc_a = lib.hipass_avg(10)
    ctrl.pc_avg_thresh = float('inf') # If std of N previous TOx samples is above this value, then\
    ctrl.pc_std_thresh = float(30) # If std of N previous TOx samples is above this value, then\
                     # no PC is applied (but TOy is still calculated)
    
    ctrl.saveall = True


    cdict = {
        'nodecount':[x for x in range(10,61,1)]
        #'nodecou
        }

    pdict = {}
    #pdict = {'match_decimate_fct':[lib.md_clkphase, lib.md_energy]}

    return ctrl, p, cdict, pdict
コード例 #4
0
ファイル: thygraphs.py プロジェクト: morphheus/distrib-synch
def dec_sample_theta():
    p = lib.SyncParams()
    p.zc_len = 32
    p.plen = 31

    p.rolloff = 0.2
    p.f_symb = 30.72e6
    p.f_samp = p.f_symb*4
    p.repeat = 1
    p.spacing_factor = 1

    p.power_weight = 2
    p.full_sim = True
    p.bias_removal = False
    p.ma_window = 1 # number of samples to average in the crosscorr i.e. after analog modulation
    p.train_type = 'single' # Type of training sequence
    p.crosscorr_type = 'match_decimate' 
    p.match_decimate_fct = lib.downsample
    p.peak_detect = 'wavg' 
    p.pulse_type = 'rootraisedcosine'
    p.central_padding = 0 # As a fraction of zpos length
    p.scfdma_precode = True
    p.scfdma_L = 8
    p.scfdma_M = p.zc_len*p.scfdma_L
    p.scfdma_sinc_len_factor = p.scfdma_L


    ctrl = SimControls()
    ctrl.steps = 40 # Approx number of emissions per node
    ctrl.basephi = 6000 # How many samples between emission
    ctrl.display = True # Show stuff in the console
    ctrl.keep_intermediate_values = False # Needed to draw graphs
    ctrl.nodecount = 15 # Number of nodes
    ctrl.static_nodes = 0
    ctrl.CFO_step_wait = float('inf') # Use float('inf') to never correct for CFO
    ctrl.TO_step_wait = 5
    ctrl.max_start_delay = 10 # In factor of basephi

    #ctrl.theta_bounds = [0.3,0.7] # In units of phi
    #ctrl.theta_bounds = [0.48,0.52] # In units of phi
    #ctrl.theta_bounds = [0.5,0.5] # In units of phi
    #ctrl.theta_bounds = [0,1] # In units of phi
    ctrl.theta_bounds = [0,0.6] # In units of phi
    ctrl.deltaf_bound = 3e-2
    #ctrl.deltaf_bound = 0
    ctrl.rand_init = False
    ctrl.epsilon_TO = 0.5

    #seed = int(np.random.rand()*1e8); print(seed)
    seed = 2596829
    ctrl.non_rand_seed = seed # Only used if rand_init is False

    #ctrl.non_rand_seed = 57276545 # Only used if rand_init is False
    #ctrl.noise_power = float('-inf')
    ctrl.noise_power = -101 + 9 # in dbm

    ctrl.delay_params = lib.DelayParams(lib.delay_pdf_3gpp_exp)
    ctrl.delay_params.taps = 5
    ctrl.max_dist_from_origin = 250 # (in meters)
    ctrl.delay_params.max_dist_from_origin = 250 # (in meters)

    ctrl.half_duplex = False
    ctrl.hd_slot0 = 0.3 # in terms of phi
    ctrl.hd_slot1 = 0.7 # in terms of phi
    ctrl.hd_block_during_emit = True
    ctrl.hd_block_extrawidth = 0 # as a factor of offset (see runsim to know what is offset)

    ctrl.var_winlen = False
    ctrl.vw_minsize = 5 # as a factor of len(p.analog_sig)
    ctrl.vw_lothreshold = 0.1 # winlen reduction threshold
    ctrl.vw_hithreshold = 0.1 # winlen increase threshold
    ctrl.vw_lofactor = 1.5 # winlen reduction factor
    ctrl.vw_hifactor = 2 # winlen increase factor
    

    ctrl.prop_correction = False
    ctrl.pc_step_wait = 0
    ctrl.pc_b, ctrl.pc_a = lib.hipass_avg(7)
    ctrl.pc_avg_thresh = float('inf') # If std of N previous TOx samples is above this value, then\
    ctrl.pc_std_thresh = float(80) # If std of N previous TOx samples is above this value, then\
                     # no PC is applied (but TOy is still calculated)
    
    ctrl.saveall = True


    cdict = {'rand_init':[True]}
    #cdict = {
    #    'nodecount':[x for x in range(ncount_lo, ncount_hi,step)]*3
    #    }

    pdict = {}
    #pdict = {'match_decimate_fct':[lib.md_clkphase]*ntot+[lib.md_energy]*ntot+[lib.md_static]*ntot}

    return ctrl, p, cdict, pdict