Commit c2ce0467 authored by wangdong's avatar wangdong

dynamic Slicing And Matlab Codes

parent e533a8c0
......@@ -14,7 +14,7 @@ eNBs =
// Tracking area code, 0x0000 and 0xfffe are reserved values
tracking_area_code = 1;
plmn_list = ( { mcc = 208; mnc = 92; mnc_length = 2; } );
plmn_list = ( { mcc = 208; mnc = 95; mnc_length = 2; } );
tr_s_preference = "local_mac"
......@@ -32,9 +32,9 @@ eNBs =
tdd_config = 3;
tdd_config_s = 0;
prefix_type = "NORMAL";
eutra_band = 7;
downlink_frequency = 2680000000L;
uplink_frequency_offset = -120000000;
eutra_band = 8;
downlink_frequency = 930000000L;
uplink_frequency_offset = -20000000;
Nid_cell = 0;
N_RB_DL = 25;
Nid_cell_mbsfn = 0;
......@@ -174,7 +174,7 @@ eNBs =
////////// MME parameters:
mme_ip_address = ( { ipv4 = "127.0.0.20";
mme_ip_address = ( { ipv4 = "127.0.1.1";
ipv6 = "192:168:30::17";
active = "yes";
preference = "ipv4";
......@@ -193,12 +193,12 @@ eNBs =
NETWORK_INTERFACES :
{
ENB_INTERFACE_NAME_FOR_S1_MME = "lo";
ENB_IPV4_ADDRESS_FOR_S1_MME = "127.0.0.10";
ENB_IPV4_ADDRESS_FOR_S1_MME = "127.0.14.3";
ENB_INTERFACE_NAME_FOR_S1U = "lo";
ENB_IPV4_ADDRESS_FOR_S1U = "127.0.0.10";
ENB_IPV4_ADDRESS_FOR_S1U = "127.0.14.3";
ENB_PORT_FOR_S1U = 2152; # Spec 2152
ENB_IPV4_ADDRESS_FOR_X2C = "127.0.0.10";
ENB_IPV4_ADDRESS_FOR_X2C = "127.0.14.3";
ENB_PORT_FOR_X2C = 36422; # Spec 36422
};
}
......@@ -210,8 +210,8 @@ MACRLCs = (
tr_s_preference = "local_L1";
tr_n_preference = "local_RRC";
phy_test_mode = 0;
puSch10xSnr = 160;
puCch10xSnr = 160;
puSch10xSnr = 200;
puCch10xSnr = 200;
}
);
......@@ -229,7 +229,7 @@ RUs = (
nb_rx = 1
att_tx = 0
att_rx = 0;
bands = [7];
bands = [8];
max_pdschReferenceSignalPower = -27;
max_rxgain = 125;
eNB_instances = [0];
......@@ -248,9 +248,9 @@ THREAD_STRUCT = (
NETWORK_CONTROLLER :
{
FLEXRAN_ENABLED = "no";
FLEXRAN_INTERFACE_NAME = "lo";
FLEXRAN_IPV4_ADDRESS = "127.0.0.1";
FLEXRAN_ENABLED = "yes";
FLEXRAN_INTERFACE_NAME = "enp1s0";
FLEXRAN_IPV4_ADDRESS = "192.168.1.112";
FLEXRAN_PORT = 2210;
FLEXRAN_CACHE = "/mnt/oai_agent_cache";
FLEXRAN_AWAIT_RECONF = "no";
......
......@@ -14,10 +14,13 @@ eNBs =
// Tracking area code, 0x0000 and 0xfffe are reserved values
tracking_area_code = 1;
plmn_list = ( { mcc = 208; mnc = 92; mnc_length = 2; } );
plmn_list = ( { mcc = 208; mnc = 95; mnc_length = 2; } );
tr_s_preference = "local_mac"
// In seconds
rrc_inactivity_threshold = 30;
////////// Physical parameters:
component_carriers = (
......@@ -29,9 +32,9 @@ eNBs =
tdd_config = 3;
tdd_config_s = 0;
prefix_type = "NORMAL";
eutra_band = 7;
downlink_frequency = 2630000000L;
uplink_frequency_offset = -120000000;
eutra_band = 8;
downlink_frequency = 930000000L;
uplink_frequency_offset = -20000000;
Nid_cell = 0;
N_RB_DL = 25;
Nid_cell_mbsfn = 0;
......@@ -50,7 +53,7 @@ eNBs =
pucch_nRB_CQI = 0;
pucch_nCS_AN = 0;
pucch_n1_AN = 0;
pdsch_referenceSignalPower = -27;
pdsch_referenceSignalPower = -25;
pdsch_p_b = 0;
pusch_n_SB = 1;
pusch_enable64QAM = "DISABLE";
......@@ -94,14 +97,6 @@ eNBs =
pcch_default_PagingCycle = 128;
pcch_nB = "oneT";
drx_Config_present = "prSetup"; //"prSetup" "prRelease"
drx_onDurationTimer = "psf1"; // "psfX": X=1,2,3,4,5,6,8,10,20,30,40,50,60,80,100
drx_InactivityTimer = "psf1"; // "psfX": X=1,2,3,4,5,6,8,10,20,30,40,50,60,80,100,200,300,500,750,1280,1920,2560
drx_RetransmissionTimer = "psf1"; // "psfX": X=1,2,4,6,8,16,24,33
drx_longDrx_CycleStartOffset_present = "prSf128"; // "psfX": X=10,20,32,40,64,80,128,160,256,320,512,640,1024,1280,2048,2560
drx_longDrx_CycleStartOffset = 0; // X >= 0 && X < drx_longDrx_CycleStartOffset_present
drx_shortDrx_Cycle = "sf16"; // "sfX": X=2,5,8,10,16,20,32,40,64,80,128,160,256,320,512,640
drx_shortDrx_ShortCycleTimer = 3; // 1..16 integer. Total duration in short cycle = drx_shortDrx_Cycle*drx_shortDrx_ShortCycleTimer [subframe]
bcch_modificationPeriodCoeff = 2;
ue_TimersAndConstants_t300 = 1000;
ue_TimersAndConstants_t301 = 1000;
......@@ -179,7 +174,7 @@ eNBs =
////////// MME parameters:
mme_ip_address = ( { ipv4 = "192.168.174.136";
mme_ip_address = ( { ipv4 = "192.168.1.36";
ipv6 = "192:168:30::17";
active = "yes";
preference = "ipv4";
......@@ -192,16 +187,18 @@ eNBs =
enable_x2 = "no";
t_reloc_prep = 1000; /* unit: millisecond */
tx2_reloc_overall = 2000; /* unit: millisecond */
t_dc_prep = 1000; /* unit: millisecond */
t_dc_overall = 2000; /* unit: millisecond */
NETWORK_INTERFACES :
NETWORK_INTERFACES :
{
ENB_INTERFACE_NAME_FOR_S1_MME = "ens192";
ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.174.131/24";
ENB_INTERFACE_NAME_FOR_S1_MME = "enp1s0";
ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.1.193";
ENB_INTERFACE_NAME_FOR_S1U = "ens192";
ENB_IPV4_ADDRESS_FOR_S1U = "192.168.174.131/24";
ENB_INTERFACE_NAME_FOR_S1U = "enp1s0";
ENB_IPV4_ADDRESS_FOR_S1U = "192.168.1.193";
ENB_PORT_FOR_S1U = 2152; # Spec 2152
ENB_IPV4_ADDRESS_FOR_X2C = "192.168.174.131/24";
ENB_IPV4_ADDRESS_FOR_X2C = "192.168.1.193";
ENB_PORT_FOR_X2C = 36422; # Spec 36422
};
}
......@@ -209,53 +206,41 @@ NETWORK_INTERFACES :
MACRLCs = (
{
# num_cc = 1;
# tr_s_preference = "local_L1";
# tr_n_preference = "local_RRC";
# phy_test_mode = 0;
# puSch10xSnr = 160;
# puCch10xSnr = 160;
num_cc = 1;
local_n_if_name = "ens192";
remote_n_address = "192.168.174.132";
local_n_address = "192.168.174.131";
local_s_portc = 50001;
remote_s_portc = 50000;
local_s_portd = 50011;
remote_s_portd = 50010;
tr_s_preference = "nfapi";
tr_s_preference = "local_L1";
tr_n_preference = "local_RRC";
phy_test_mode = 0;
puSch10xSnr = 200;
puCch10xSnr = 200;
}
);
L1s = (
{
num_cc = 1;
tr_n_preference = "local_mac";
}
);
# L1s = (
# {
# num_cc = 1;
# tr_n_preference = "local_mac";
# }
# );
# RUs = (
# {
# local_rf = "yes"
# nb_tx = 1
# nb_rx = 1
# att_tx = 0
# att_rx = 0;
# bands = [7];
# max_pdschReferenceSignalPower = -27;
# max_rxgain = 110;
# eNB_instances = [0];
# }
# );
RUs = (
{
local_rf = "yes"
nb_tx = 1
nb_rx = 1
att_tx = 0
att_rx = 0;
bands = [8];
max_pdschReferenceSignalPower = -27;
max_rxgain = 125;
eNB_instances = [0];
}
);
THREAD_STRUCT = (
{
#three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT"
parallel_config = "PARALLEL_RU_L1_SPLIT";
parallel_config = "PARALLEL_SINGLE_THREAD";
#two option for worker "WORKER_DISABLE" or "WORKER_ENABLE"
worker_config = "WORKER_ENABLE";
}
......@@ -264,15 +249,13 @@ THREAD_STRUCT = (
NETWORK_CONTROLLER :
{
FLEXRAN_ENABLED = "yes";
FLEXRAN_INTERFACE_NAME = "ens192";
FLEXRAN_IPV4_ADDRESS = "192.168.174.136";
FLEXRAN_INTERFACE_NAME = "enp1s0";
FLEXRAN_IPV4_ADDRESS = "192.168.1.36";
FLEXRAN_PORT = 2210;
FLEXRAN_CACHE = "/mnt/oai_agent_cache";
FLEXRAN_AWAIT_RECONF = "no";
};
log_config :
{
global_log_level ="info";
......
Active_eNBs = ( "eNB-Eurecom-LTEBox");
# Asn1_verbosity, choice in: none, info, annoying
Asn1_verbosity = "none";
eNBs =
(
{
# real_time choice in {hard, rt-preempt, no}
//real_time = "no";
////////// Identification parameters:
eNB_ID = 0xe00;
cell_type = "CELL_MACRO_ENB";
eNB_name = "eNB-Eurecom-LTEBox";
// Tracking area code, 0x0000 and 0xfffe are reserved values
tracking_area_code = 1;
plmn_list = ( { mcc = 208; mnc = 95; mnc_length = 2; } );
tr_s_preference = "local_mac"
////////// Physical parameters:
component_carriers = (
{
node_function = "NGFI_RCC_IF4p5";
node_timing = "synch_to_ext_device";
node_synch_ref = 0;
frame_type = "FDD";
tdd_config = 3;
tdd_config_s = 0;
prefix_type = "NORMAL";
eutra_band = 7;
downlink_frequency = 2685000000L;
uplink_frequency_offset = -120000000;
Nid_cell = 0;
N_RB_DL = 25;
Nid_cell_mbsfn = 0;
nb_antenna_ports = 1;
nb_antennas_tx = 1;
nb_antennas_rx = 1;
tx_gain = 90;
rx_gain = 115;
pbch_repetition = "FALSE";
prach_root = 0;
prach_config_index = 0;
prach_high_speed = "DISABLE";
prach_zero_correlation = 1;
prach_freq_offset = 2;
pucch_delta_shift = 1;
pucch_nRB_CQI = 0;
pucch_nCS_AN = 0;
pucch_n1_AN = 0;
pdsch_referenceSignalPower = -27;
pdsch_p_b = 0;
pusch_n_SB = 1;
pusch_enable64QAM = "DISABLE";
pusch_hoppingMode = "interSubFrame";
pusch_hoppingOffset = 0;
pusch_groupHoppingEnabled = "ENABLE";
pusch_groupAssignment = 0;
pusch_sequenceHoppingEnabled = "DISABLE";
pusch_nDMRS1 = 1;
phich_duration = "NORMAL";
phich_resource = "ONESIXTH";
srs_enable = "DISABLE";
/* srs_BandwidthConfig =;
srs_SubframeConfig =;
srs_ackNackST =;
srs_MaxUpPts =;*/
pusch_p0_Nominal = -96;
pusch_alpha = "AL1";
pucch_p0_Nominal = -104;
msg3_delta_Preamble = 6;
pucch_deltaF_Format1 = "deltaF2";
pucch_deltaF_Format1b = "deltaF3";
pucch_deltaF_Format2 = "deltaF0";
pucch_deltaF_Format2a = "deltaF0";
pucch_deltaF_Format2b = "deltaF0";
rach_numberOfRA_Preambles = 64;
rach_preamblesGroupAConfig = "DISABLE";
/*
rach_sizeOfRA_PreamblesGroupA = ;
rach_messageSizeGroupA = ;
rach_messagePowerOffsetGroupB = ;
*/
rach_powerRampingStep = 4;
rach_preambleInitialReceivedTargetPower = -108;
rach_preambleTransMax = 10;
rach_raResponseWindowSize = 10;
rach_macContentionResolutionTimer = 48;
rach_maxHARQ_Msg3Tx = 4;
pcch_default_PagingCycle = 128;
pcch_nB = "oneT";
bcch_modificationPeriodCoeff = 2;
ue_TimersAndConstants_t300 = 1000;
ue_TimersAndConstants_t301 = 1000;
ue_TimersAndConstants_t310 = 1000;
ue_TimersAndConstants_t311 = 10000;
ue_TimersAndConstants_n310 = 20;
ue_TimersAndConstants_n311 = 1;
ue_TransmissionMode = 1;
//Parameters for SIB18
rxPool_sc_CP_Len = "normal";
rxPool_sc_Period = "sf40";
rxPool_data_CP_Len = "normal";
rxPool_ResourceConfig_prb_Num = 20;
rxPool_ResourceConfig_prb_Start = 5;
rxPool_ResourceConfig_prb_End = 44;
rxPool_ResourceConfig_offsetIndicator_present = "prSmall";
rxPool_ResourceConfig_offsetIndicator_choice = 0;
rxPool_ResourceConfig_subframeBitmap_present = "prBs40";
rxPool_ResourceConfig_subframeBitmap_choice_bs_buf = "00000000000000000000";
rxPool_ResourceConfig_subframeBitmap_choice_bs_size = 5;
rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0;
/* rxPool_dataHoppingConfig_hoppingParameter = 0;
rxPool_dataHoppingConfig_numSubbands = "ns1";
rxPool_dataHoppingConfig_rbOffset = 0;
rxPool_commTxResourceUC-ReqAllowed = "TRUE";
*/
// Parameters for SIB19
discRxPool_cp_Len = "normal"
discRxPool_discPeriod = "rf32"
discRxPool_numRetx = 1;
discRxPool_numRepetition = 2;
discRxPool_ResourceConfig_prb_Num = 5;
discRxPool_ResourceConfig_prb_Start = 3;
discRxPool_ResourceConfig_prb_End = 21;
discRxPool_ResourceConfig_offsetIndicator_present = "prSmall";
discRxPool_ResourceConfig_offsetIndicator_choice = 0;
discRxPool_ResourceConfig_subframeBitmap_present = "prBs40";
discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf = "f0ffffffff";
discRxPool_ResourceConfig_subframeBitmap_choice_bs_size = 5;
discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0;
}
);
srb1_parameters :
{
# timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500]
timer_poll_retransmit = 80;
# timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200]
timer_reordering = 35;
# timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500]
timer_status_prohibit = 0;
# poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)]
poll_pdu = 4;
# poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)]
poll_byte = 99999;
# max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32]
max_retx_threshold = 4;
}
# ------- SCTP definitions
SCTP :
{
# Number of streams to use in input/output
SCTP_INSTREAMS = 2;
SCTP_OUTSTREAMS = 2;
};
////////// MME parameters:
mme_ip_address = (
{
ipv4 = "192.168.1.36";
ipv6 = "192:168:30::17";
active = "yes";
preference = "ipv4";
}
);
NETWORK_INTERFACES :
{
ENB_INTERFACE_NAME_FOR_S1_MME = "enp1s0";
ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.1.193/24";
ENB_INTERFACE_NAME_FOR_S1U = "enp1s0";
ENB_IPV4_ADDRESS_FOR_S1U = "192.168.1.193/24";
ENB_PORT_FOR_S1U = 2152; # Spec 2152
ENB_IPV4_ADDRESS_FOR_X2C = "127.0.16.3/24";
ENB_PORT_FOR_X2C = 36422; # Spec 36422
};
}
);
MACRLCs = ({
num_cc = 1;
local_s_if_name = "enp1s0";
remote_s_address = "192.168.1.214";
local_s_address = "192.168.1.193";
local_s_portc = 50001;
remote_s_portc = 50000;
local_s_portd = 50011;
remote_s_portd = 50010;
tr_s_preference = "nfapi";
tr_n_preference = "local_RRC";
});
THREAD_STRUCT = (
{
#three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT"
parallel_config = "PARALLEL_RU_L1_SPLIT";
#two option for worker "WORKER_DISABLE" or "WORKER_ENABLE"
worker_config = "WORKER_ENABLE";
}
);
NETWORK_CONTROLLER :
{
FLEXRAN_ENABLED = "yes";
FLEXRAN_INTERFACE_NAME = "enp1s0";
FLEXRAN_IPV4_ADDRESS = "192.168.1.36";
FLEXRAN_PORT = 2210;
FLEXRAN_CACHE = "/tmp";
FLEXRAN_AWAIT_RECONF = "no";
};
log_config : {
global_log_level = "info";
global_log_verbosity = "medium";
hw_log_level = "info";
hw_log_verbosity = "medium";
phy_log_level = "info";
phy_log_verbosity = "medium";
mac_log_level = "info";
mac_log_verbosity = "high";
rlc_log_level = "info";
rlc_log_verbosity = "medium";
pdcp_log_level = "info";
pdcp_log_verbosity = "medium";
rrc_log_level = "info";
rrc_log_verbosity = "medium";
flexran_log_level = "trace";
flexran_log_verbosity = "high";
osa_log_level = "debug";
osa_log_verbosity = "high";
};
sudo virt-install --name=ue-server1 --description="ue-server1" --memory=4096,maxmemory=4096 --vcpus=6,maxvcpus=6 --hvm --cpu=host --disk path=/var/lib/libvirt/images/ues.img,bus=virtio,size=40 --network bridge:br0 --graphics=vnc,listen=0.0.0.0,keymap=en-us --noautoconsole --cdrom=/home/u.iso
\ No newline at end of file
......@@ -79,8 +79,8 @@ message flex_slice_scn19 {
optional uint32 kpsReference = 2;
optional uint32 posLow = 3;
optional uint32 posHigh = 4;
optional uint32 tmax = 5;
optional uint32 logdelta = 6;
optional float tmax = 5;
optional float logdelta = 6;
optional uint32 tau = 7;
optional uint32 delay = 8;
optional string type = 9;
......
......@@ -3148,15 +3148,15 @@ int flexran_create_dl_slice(mid_t mod_id, const Protocol__FlexSlice *s) {
((scn19_slice_param_t *)params)->posLow = s->scn19->poslow;
((scn19_slice_param_t *)params)->posHigh = s->scn19->poshigh;
}else{
((scn19_slice_param_t *)params)->posLow = NULL;
((scn19_slice_param_t *)params)->posHigh = NULL;
((scn19_slice_param_t *)params)->posLow = 0;
((scn19_slice_param_t *)params)->posHigh = 0;
}
if(s->scn19->kpsreference){
((scn19_slice_param_t *)params)->kpsRequired = s->scn19->kpsrequired;
((scn19_slice_param_t *)params)->kpsReference = s->scn19->kpsreference;
}else{
((scn19_slice_param_t *)params)->kpsRequired = NULL;
((scn19_slice_param_t *)params)->kpsReference = NULL;
((scn19_slice_param_t *)params)->kpsRequired = 0;
((scn19_slice_param_t *)params)->kpsReference = 0;
}
if(s->scn19->has_tau){
((scn19_slice_param_t *)params)->kpsRequired = s->scn19->kpsrequired;
......@@ -3165,10 +3165,10 @@ int flexran_create_dl_slice(mid_t mod_id, const Protocol__FlexSlice *s) {
((scn19_slice_param_t *)params)->tau = s->scn19->tau;
((scn19_slice_param_t *)params)->delay = s->scn19->delay;
}else{
((scn19_slice_param_t *)params)->tmax = NULL;
((scn19_slice_param_t *)params)->logdelta = NULL;
((scn19_slice_param_t *)params)->tau = NULL;
((scn19_slice_param_t *)params)->delay = NULL;
((scn19_slice_param_t *)params)->tmax = 0;
((scn19_slice_param_t *)params)->logdelta = 0;
((scn19_slice_param_t *)params)->tau = 0;
((scn19_slice_param_t *)params)->delay = 0;
}
break;
......
addpath("tests")
addpath("exps")
classdef SliceStrategy
methods(Static)
function t = Static()
t = 1;
end
function t = NVS()
t = 2;
end
function t = Concurrent()
t = 3;
end
end
end
classdef SliceType
methods(Static)
function t = PRB()
t = 11;
end
function t = vRB()
t = 12;
end
function t = Rate()
t = 13;
end
function t = Delay()
t = 14;
end
function t = Fixed()
t = 21;
end
function t = Dynamic()
t = 22;
end
function t = OnDemand()
t = 23;
end
end
end
function avg = average(a)
avg = sum(a) / length(a);
endfunction
function slice_RBs = concurrent(time, num_RBs, p, sx)
num_slices = length(p);
assert(num_slices == length(sx));
persistent stats = [struct()]
if time == 0 % first access, no previous for effective and exp rates
for k = 1:num_slices
stats(k).fexp = p(k).reserved; % exponential moving average for weight calc
stats(k).rbs = 0; % indicator: how many RBs in last round?
if p(k).type == SliceType.Dynamic
stats(k).eff = p(k).option.reference / num_RBs;
end
if p(k).type == SliceType.OnDemand
stats(k).texp = p(k).option.tmax;
stats(k).fexp = p(k).option.tmax * 5000; % artifical rate
end
end
end
weights(1:num_slices) = 0;
dweights(1:num_slices) = 0;
rsv(1:num_slices) = 0;
beta = 0.01;
for k = 1:num_slices
switch p(k).type
case SliceType.vRB
if not(sx(k).active)
continue
end
% rbs/num_RBs: percentage of allocated RBs in last round and indicator at
% the same time (is zero if not allocated)
stats(k).fexp = (1 - beta) * stats(k).fexp + beta * (stats(k).rbs / num_RBs);
weights(k) = p(k).reserved / stats(k).fexp;
case SliceType.Dynamic
if not(sx(k).active)
continue
end
inst = 0;
if stats(k).rbs > 0 % was scheduled last time
inst = sx(k).thrpt(length(sx(k).thrpt));
% effective rate when slice sched, per RB
stats(k).eff = (1 - beta) * stats(k).eff + beta * inst / stats(k).rbs;
end
stats(k).fexp = (1 - beta) * stats(k).fexp + beta * inst;
rsv(k) = p(k).reserved * min(1, stats(k).eff * num_RBs/p(k).option.reference);
weights(k) = rsv(k) / stats(k).fexp;
case SliceType.OnDemand
% the same as rate, but also update weights for OnDemand
inst = 0;
if stats(k).rbs > 0 % was scheduled last time
inst = sx(k).thrpt(length(sx(k).thrpt));
end
stats(k).fexp = (1 - beta) * stats(k).fexp + beta * inst;
%disp([num2str(stats(k).eff) " " num2str(stats(k).eff*num_RBs) " " num2str(p(k).option.reference)]);
weights(k) = sx(k).rate / stats(k).fexp;
dweights(k) = p(k).option.logdelta / p(k).option.tau * sx(k).delay * weights(k);
% update moving average of consumed resources
stats(k).texp = (1 - 1/p(k).option.tau) * stats(k).texp + 1/p(k).option.tau * stats(k).rbs / num_RBs;
%disp(['texp slice ' num2str(k) ': ' num2str(stats(k).texp)']);
% calculate next maximum resource share
tmax = p(k).option.tau * p(k).option.tmax + (1 - p(k).option.tau) * stats(k).texp;
assert(tmax >= 0);
% limit weight (=number of attempted RBs) to tmax
if (weights(k) > tmax)
weights(k) = tmax;
end
end
stats(k).rbs = 0;
end
slice_RBs(1:num_RBs) = 0;
% Step 1: allocate all Fixed Slices
idxs = find([p(:).type] == SliceType.Fixed);
for i = [idxs]
sstart = round(p(i).option.position * num_RBs + 1); % + 1 because of 1-indexing
send = round(sstart + p(i).reserved * num_RBs - 1); % do not include last one
slice_RBs(sstart:send) = i;
stats(i).rbs = send - sstart;
end
% Step 2: allocate all OnDemand slices that requested service
ri = 1;
[~, idxs] = sort(dweights, 'descend');
for i = idxs
if dweights(i) <= 0.0001
break
end
slen = round(weights(k) * num_RBs);
%disp(['time ' num2str(time) ' slice ' num2str(i) ' slen ' num2str(slen)]);
while slen > 0 && ri <= num_RBs
if slice_RBs(ri) == 0
slice_RBs(ri) = i;
slen -= 1;
stats(i).rbs += 1;
end
ri += 1;
end
weights(i) = 0; % has been served, do not consider anymore
end
weights([p(:).type] == SliceType.OnDemand) = 0; % remove all weights of OnDemand slices
[~, idx] = max(weights);
% Step 3: allocate remaining RBs to Dynamic slice with heighest weight
slice_RBs(slice_RBs == 0) = idx;
stats(idx).rbs = sum(slice_RBs == idx);
%output
%disp(["time = " num2str(time)]);
%disp(["s_exp = " num2str(s_exp(1)) ", " num2str(s_exp(2))]);
%disp(["weights = " num2str(weights(1)) ", " num2str(weights(2))]);
%disp(["RBs = " num2str(slice_RBs(1)) ", " num2str(slice_RBs(2))]);
endfunction
function concurrent_adm(num_RBs, p)
sum_reqs = 0;
fpl = [];
for i = 1:length(p)
switch p(i).type
case SliceType.PRB
error('PRB type not allowed');
case SliceType.vRB
error('vRB type not allowed');
sum_reqs += p(i).reserved;
case SliceType.Rate
error('Rate type not allowed');
case SliceType.Delay
error('Delay type not allowed');
case SliceType.Fixed
sum_reqs += p(i).reserved;
sstart = p(i).option.position * num_RBs;
assert(not(mod(sstart, 1) > 0.001), ['slice ' num2str(i) ' Fixed start is not on boundary: ' num2str(sstart)]);
send = sstart + p(i).reserved * num_RBs;
assert(not(mod(send, 1) > 0.001), ['slice ' num2str(i) ' Fixed end is not on boundary: ' num2str(send)]);
fpl = [fpl; sstart send];
case SliceType.Dynamic
assert(p(i).reserved <= p(i).option.reference);
sum_reqs += p(i).reserved / p(i).option.reference;
case SliceType.OnDemand
sum_reqs += p(i).option.tmax;
assert(not(mod(p(i).option.tmax * num_RBs, 1) > 0.001), 'tmax of OnDemand slice not on RB boundary');
end
end
assert(sum_reqs <= 1, ["resource usage is " num2str(sum_reqs)]);
% check that there are no overlapping Fixed boundaries
if length(fpl) > 0 && length(fpl(:,1)) > 1
for i = 1:length(fpl)-1
for j = i+1:length(fpl)
a = max(min(fpl(i,:)), min(fpl(j,:)));
b = min(max(fpl(i,:)), max(fpl(j,:)));
assert(a >= b, ["ranges " num2str(fpl(i,:)) " and " num2str(fpl(j,:)) " are overlapping"]);
end
end
end
endfunction
function b = crush(a,n)
xx=reshape(a,n,[]);
yy = sum(xx,1)./size(xx,1);
b = reshape(yy,1,[]);
endfunction
addpath("..");
num_frames = 1000;
num_RBs = 25; % maximum of 14.4Mpbs
slices = {"schedule_pf", "schedule_bet"};
slice_strat = SliceStrategy.Concurrent;
conc_parameters(1) = struct("type", SliceType.Dynamic, "reserved", 7200, "option",
struct("reference", 14400));
conc_parameters(2) = struct("type", SliceType.Dynamic, "reserved", 7200, "option",
struct("reference", 14400));
slice_parameters = struct("strategy", slice_strat, "parameters", conc_parameters);
user_slice_mask = [1 1 1 2 2 2];
num_users = length(user_slice_mask);
% packet delay budget for each Network Slice based on their QCI in LTE (70% of
% the time can be spent in buffer queue)
slice_max_packet_delay = [50 50]*0.7;
% bitrate for user: avg*8/IDT kbps per user!!
user_packet_size_funcs{1} = @() (700);
user_packet_size_funcs{2} = @() (700);
user_packet_size_funcs{3} = @() (700);
user_packet_size_funcs{4} = @() (700);
user_packet_size_funcs{5} = @() (700);
user_packet_size_funcs{6} = @() (700);
user_idt_funcs{1} = @(time) (time + 1);
user_idt_funcs{2} = @(time) (time + 1);
user_idt_funcs{3} = @(time) (time + 1);
user_idt_funcs{4} = @(time) (time + 1);
user_idt_funcs{5} = @(time) (time + 1);
user_idt_funcs{6} = @(time) (time + 1);
clear CQI
CQI(1:num_users,1:num_frames*10) = 0;
CQI( 1,1:num_frames*10) = 18;
CQI( 2,1:num_frames*10) = 23;
CQI( 3,1:num_frames*10) = 28;
CQI( 4,1:num_frames*10) = 18;
CQI( 5,1:num_frames*10) = 23;
CQI( 6,1:num_frames*10) = 28;
[ux_cust, ~] = usf(num_RBs,
num_frames,
slice_parameters,
slices,
user_slice_mask,
CQI,
slice_max_packet_delay,
user_packet_size_funcs,
user_idt_funcs,
false); % graphs?
thrpt = [average(ux_cust(1).thrpt), average(ux_cust(2).thrpt), average(ux_cust(3).thrpt); average(ux_cust(4).thrpt), average(ux_cust(5).thrpt) average(ux_cust(6).thrpt)] / 1000;
figure
bar(thrpt);
grid on;
ylim([0 inf]);
xlabel('Slice');
ylabel('DL Throughput (Mbps)');
print('customisation.png', '-dpng', '-F:20');
save('customisation-save.m');
addpath("..");
num_frames = 3000;
num_RBs = 25;
slices = {"schedule_rr", "schedule_rr", "schedule_rr", "schedule_delay"};
slice_strat = SliceStrategy.Concurrent;
conc_parameters(1) = struct("type", SliceType.Dynamic, "reserved", 4000, "option",
struct("reference", 14400));
conc_parameters(2) = struct("type", SliceType.Dynamic, "reserved", 4000, "option",
struct("reference", 14400));
conc_parameters(3) = struct("type", SliceType.Dynamic, "reserved", 4000, "option",
struct("reference", 14400));
conc_parameters(4) = struct("type", SliceType.OnDemand, "reserved", 0, "option",
struct("tmax", 0.16,
"logdelta", -log10(1e-3),
"tau", 25));
slice_parameters = struct("strategy", slice_strat, "parameters", conc_parameters);
user_slice_mask = [1 1 2 2 3 3 4 4 4 4];
num_users = length(user_slice_mask);
% packet delay budget for each Network Slice based on their QCI in LTE (70% of
% the time can be spent in buffer queue)
slice_max_packet_delay = [50 50 50 9];
% bitrate for user: avg*8/IDT kbps per user!!
user_packet_size_funcs{ 1} = @() (2000);
user_packet_size_funcs{ 2} = @() (2000);
user_packet_size_funcs{ 3} = @() (2000);
user_packet_size_funcs{ 4} = @() (2000);
user_packet_size_funcs{ 5} = @() (2000);
user_packet_size_funcs{ 6} = @() (2000);
user_packet_size_funcs{ 7} = @() (255);
user_packet_size_funcs{ 8} = @() (255);
user_packet_size_funcs{ 9} = @() (255);
user_packet_size_funcs{10} = @() (255);
user_idt_funcs{ 1} = @(time) (time + 1);
user_idt_funcs{ 2} = @(time) (time + 1);
user_idt_funcs{ 3} = @(time) (time + 1);
user_idt_funcs{ 4} = @(time) (time + 1);
user_idt_funcs{ 5} = @(time) (time + 1);
user_idt_funcs{ 6} = @(time) (time + 1);
function t = time_offset(time, offset, inc)
if time == 0
t = offset;
else
t = time + inc;
end
end
user_idt_funcs{ 7} = @(time) time_offset(time, 2, 10);
user_idt_funcs{ 8} = @(time) time_offset(time, 4, 10);
user_idt_funcs{ 9} = @(time) time_offset(time, 6, 10);
user_idt_funcs{10} = @(time) time_offset(time, 8, 10);
clear CQI
CQI(1:num_users,1:num_frames*10) = 0;
CQI( 1,1:num_frames*10) = 28;
CQI( 2,1:num_frames*10) = 28;
CQI( 3,1:num_frames*10) = 28;
CQI( 4,1:num_frames*10) = 28;
CQI( 5,1:num_frames*10) = 28;
CQI( 6,1:num_frames*10) = 28;
CQI( 7,1:num_frames*10) = 20;
CQI( 8,1:num_frames*10) = 20;
CQI( 9,1:num_frames*10) = 20;
CQI(10,1:num_frames*10) = 20;
%CQI( 8,1:num_frames*10) = 28;
%CQI( 8,1:num_frames*10) = 28;
%CQI( 9,1:num_frames*10) = 28;
%CQI(10,1:num_frames*10) = 6;
%CQI(11,1:num_frames*10) = 6;
%CQI(12,1:num_frames*10) = 6;
[ux_conc, sx_conc] = usf(num_RBs,
num_frames,
slice_parameters,
slices,
user_slice_mask,
CQI,
slice_max_packet_delay,
user_packet_size_funcs,
user_idt_funcs,
false); % graphs?
%assert(length(ux_conc(8).packet_delay) == 100);
sum(ux_conc(7).packet_delay)/length(ux_conc(7).packet_delay)
sum(ux_conc(8).packet_delay)/length(ux_conc(8).packet_delay)
sum(ux_conc(9).packet_delay)/length(ux_conc(9).packet_delay)
sum(ux_conc(10).packet_delay)/length(ux_conc(10).packet_delay)
rande('state', 1);
user_idt_funcs{ 7} = @(time) time + exprnd(10) + 1;
user_idt_funcs{ 8} = @(time) time + exprnd(10) + 1;
user_idt_funcs{ 9} = @(time) time + exprnd(10) + 1;
user_idt_funcs{10} = @(time) time + exprnd(10) + 1;
[ux_conc_pn, sx_conc_pn] = usf(num_RBs,
num_frames,
slice_parameters,
slices,
user_slice_mask,
CQI,
slice_max_packet_delay,
user_packet_size_funcs,
user_idt_funcs,
false); % graphs?
save('delay_response_concurrent-save.m');
addpath("..");
num_frames = 3000;
num_RBs = 25;
slices = {"schedule_rr", "schedule_rr", "schedule_rr", "schedule_delay"};
slice_strat = SliceStrategy.Concurrent;
conc_parameters(1) = struct("type", SliceType.Dynamic, "reserved", 4000, "option",
struct("reference", 14400));
conc_parameters(2) = struct("type", SliceType.Dynamic, "reserved", 4000, "option",
struct("reference", 14400));
conc_parameters(3) = struct("type", SliceType.Dynamic, "reserved", 4000, "option",
struct("reference", 14400));
conc_parameters(4) = struct("type", SliceType.Dynamic, "reserved", 1600, "option",
struct("reference", 10000));
slice_parameters = struct("strategy", slice_strat, "parameters", conc_parameters);
user_slice_mask = [1 1 2 2 3 3 4 4 4 4];
num_users = length(user_slice_mask);
% packet delay budget for each Network Slice based on their QCI in LTE (70% of
% the time can be spent in buffer queue)
slice_max_packet_delay = [50 50 50 9];
% bitrate for user: avg*8/IDT kbps per user!!
user_packet_size_funcs{ 1} = @() (2000);
user_packet_size_funcs{ 2} = @() (2000);
user_packet_size_funcs{ 3} = @() (2000);
user_packet_size_funcs{ 4} = @() (2000);
user_packet_size_funcs{ 5} = @() (2000);
user_packet_size_funcs{ 6} = @() (2000);
user_packet_size_funcs{ 7} = @() (255);
user_packet_size_funcs{ 8} = @() (255);
user_packet_size_funcs{ 9} = @() (255);
user_packet_size_funcs{10} = @() (255);
user_idt_funcs{ 1} = @(time) (time + 1);
user_idt_funcs{ 2} = @(time) (time + 1);
user_idt_funcs{ 3} = @(time) (time + 1);
user_idt_funcs{ 4} = @(time) (time + 1);
user_idt_funcs{ 5} = @(time) (time + 1);
user_idt_funcs{ 6} = @(time) (time + 1);
function t = time_offset(time, offset, inc)
if time == 0
t = offset;
else
t = time + inc;
end
end
user_idt_funcs{ 7} = @(time) time_offset(time, 2, 10);
user_idt_funcs{ 8} = @(time) time_offset(time, 4, 10);
user_idt_funcs{ 9} = @(time) time_offset(time, 6, 10);
user_idt_funcs{10} = @(time) time_offset(time, 8, 10);
clear CQI
CQI(1:num_users,1:num_frames*10) = 0;
CQI( 1,1:num_frames*10) = 28;
CQI( 2,1:num_frames*10) = 28;
CQI( 3,1:num_frames*10) = 28;
CQI( 4,1:num_frames*10) = 28;
CQI( 5,1:num_frames*10) = 28;
CQI( 6,1:num_frames*10) = 28;
CQI( 7,1:num_frames*10) = 20;
CQI( 8,1:num_frames*10) = 20;
CQI( 9,1:num_frames*10) = 20;
CQI(10,1:num_frames*10) = 20;
%CQI( 8,1:num_frames*10) = 28;
%CQI( 8,1:num_frames*10) = 28;
%CQI( 9,1:num_frames*10) = 28;
%CQI(10,1:num_frames*10) = 6;
%CQI(11,1:num_frames*10) = 6;
%CQI(12,1:num_frames*10) = 6;
[ux_nvs, sx_nvs] = usf(num_RBs,
num_frames,
slice_parameters,
slices,
user_slice_mask,
CQI,
slice_max_packet_delay,
user_packet_size_funcs,
user_idt_funcs,
false); % graphs?
%assert(length(ux_nvs(8).packet_delay) == 100);
sum(ux_nvs(7).packet_delay)/length(ux_nvs(7).packet_delay)
sum(ux_nvs(8).packet_delay)/length(ux_nvs(8).packet_delay)
sum(ux_nvs(9).packet_delay)/length(ux_nvs(9).packet_delay)
sum(ux_nvs(10).packet_delay)/length(ux_nvs(10).packet_delay)
rande('state', 1);
user_idt_funcs{ 7} = @(time) time + exprnd(10) + 1;
user_idt_funcs{ 8} = @(time) time + exprnd(10) + 1;
user_idt_funcs{ 9} = @(time) time + exprnd(10) + 1;
user_idt_funcs{10} = @(time) time + exprnd(10) + 1;
[ux_nvs_pn, sx_nvs_pn] = usf(num_RBs,
num_frames,
slice_parameters,
slices,
user_slice_mask,
CQI,
slice_max_packet_delay,
user_packet_size_funcs,
user_idt_funcs,
false); % graphs?
save('delay_response_nvs_like-save.m');
lb = 2000;
ub = 3000;
load('delay_response_nvs_like-save.m');
assert(length(ux_nvs) > 0);
assert(length(ux_nvs_pn) > 0);
used_res_nvs = sum(sx_nvs(4).alloc_RBs) / (num_RBs * 10 * num_frames)
lost_packets_nvs = sum([ux_nvs(7:10).lost_packets])
delays_nvs = [ux_nvs(7).packet_delay ux_nvs(8).packet_delay ux_nvs(9).packet_delay ux_nvs(10).packet_delay];
delay_cdf_nvs = [];
for n = 0:10
delay_cdf_nvs(end+1) = sum(delays_nvs <= n) / length(delays_nvs);
end
used_res_nvs_pn = sum(sx_nvs_pn(4).alloc_RBs) / (num_RBs * 10 * num_frames)
lost_packets_nvs_pn = sum([ux_nvs_pn(7:10).lost_packets])
delays_nvs_pn = [ux_nvs_pn(7).packet_delay ux_nvs_pn(8).packet_delay ux_nvs_pn(9).packet_delay ux_nvs_pn(10).packet_delay];
delay_cdf_nvs_pn = [];
for n = 0:0.1:10
delay_cdf_nvs_pn(end+1) = sum(delays_nvs_pn <= n) / length(delays_nvs_pn);
end
packet_delay_delivered_nvs = [];
packet_delay_nvs = [];
for u = 7:10
idxsu = ux_nvs_pn(u).packet_delay_delivered <= ub;
lower = ux_nvs_pn(u).packet_delay_delivered(idxsu);
idxsl = lb <= lower;
packet_delay_delivered_nvs = [packet_delay_delivered_nvs lower(idxsl)];
lower = ux_nvs_pn(u).packet_delay(idxsu);
packet_delay_nvs = [packet_delay_nvs lower(idxsl)];
end
load('delay_response_concurrent-save.m');
assert(length(ux_conc) > 0);
assert(length(ux_conc_pn) > 0);
%num_delays(1) = length([ux_conc(7).packet_delay]);
%num_delays(2) = length([ux_conc(8).packet_delay]);
%num_delays(3) = length([ux_conc(9).packet_delay]);
%num_delays(4) = length([ux_conc(10).packet_delay]);
%average_delay_conc(1) = sum([ux_conc( 7).packet_delay])/num_delays(1);
%average_delay_conc(2) = sum([ux_conc( 8).packet_delay])/num_delays(2);
%average_delay_conc(3) = sum([ux_conc( 9).packet_delay])/num_delays(3);
%average_delay_conc(4) = sum([ux_conc(10).packet_delay])/num_delays(4);
%delay_conc = sum(average_delay_conc) / length(average_delay_conc)
used_res_conc = sum(sx_conc(4).alloc_RBs) / (num_RBs * 10 * num_frames)
lost_packets_conc = sum([ux_conc(7:10).lost_packets])
delays_conc = [ux_conc(7).packet_delay ux_conc(8).packet_delay ux_conc(9).packet_delay ux_conc(10).packet_delay];
delay_cdf_conc = [];
for n = 0:10
delay_cdf_conc(end+1) = sum(delays_conc <= n) / length(delays_conc);
end
used_res_conc_pn = sum(sx_conc_pn(4).alloc_RBs) / (num_RBs * 10 * num_frames)
lost_packets_conc_pn = sum([ux_conc_pn(7:10).lost_packets])
delays_conc_pn = [ux_conc_pn(7).packet_delay ux_conc_pn(8).packet_delay ux_conc_pn(9).packet_delay ux_conc_pn(10).packet_delay];
delay_cdf_conc_pn = [];
for n = 0:0.1:10
delay_cdf_conc_pn(end+1) = sum(delays_conc_pn <= n) / length(delays_conc_pn);
end
packet_delay_delivered_conc = [];
packet_delay_conc = [];
for u = 7:10
idxsu = ux_conc_pn(u).packet_delay_delivered <= ub;
lower = ux_conc_pn(u).packet_delay_delivered(idxsu);
idxsl = lb <= lower;
packet_delay_delivered_conc = [packet_delay_delivered_conc lower(idxsl)];
lower = ux_conc_pn(u).packet_delay(idxsu);
packet_delay_conc = [packet_delay_conc lower(idxsl)];
end
%lost = [lost_packets_nvs; lost_packets_conc];
%figure
%bar(lost);
%grid on;
%ylim([0 16]);
%xlim([600 8000]);
%leg = legend(['nvs-like'; 'framework']);
%print(f1, 'utilisation-ineff.png', '-dpng', '-S900,450', '-F:12');
%figure
%plot([0:10], delay_cdf_conc, 'color', 'r');
%hold on
%plot([0:10], delay_cdf_conc_pn, 'color', 'g');
%hold on
%plot([0:10], delay_cdf_nvs, 'color', 'b');
%hold on
%plot([0:10], delay_cdf_nvs_pn, 'color', 'k');
%grid on;
%xlabel('Delay (ms)');
%ylabel('CDF (non-discarded packets)');
%leg = legend(['Framework (constant traffic)'; 'Framework (Poisson)'; 'NVS-like (constant traffic)'; 'NVS-like (Poisson)'], 'location', 'southeast');
%print('delay-cdf.png', '-dpng', '-F:12');
addpath("..");
num_frames = 1000;
num_RBs = 25; % maximum of 14.4Mpbs
slices = {"schedule_pf", "schedule_pf"};
slice_strat = SliceStrategy.Concurrent;
conc_parameters(1) = struct("type", SliceType.Dynamic, "reserved", 7200, "option",
struct("reference", 14400));
conc_parameters(2) = struct("type", SliceType.Dynamic, "reserved", 7200, "option",
struct("reference", 14400));
slice_parameters = struct("strategy", slice_strat, "parameters", conc_parameters);
user_slice_mask = [1 1 1 2 2]; %first two users are in slice 1, the other two in slice 2
num_users = length(user_slice_mask);
% packet delay budget for each Network Slice based on their QCI in LTE (70% of
% the time can be spent in buffer queue)
slice_max_packet_delay = [50 50]*0.7;
% bitrate for user: avg*8/IDT kbps per user!!
user_packet_size_funcs{1} = @() (700);
user_packet_size_funcs{2} = @() (700);
user_packet_size_funcs{3} = @() (700);
user_packet_size_funcs{4} = @() (1000);
user_packet_size_funcs{5} = @() (1000);
user_idt_funcs{1} = @(time) (time + 1);
user_idt_funcs{2} = @(time) (time + 1);
user_idt_funcs{3} = @(time) (time + 1);
user_idt_funcs{4} = @(time) (time + 1);
user_idt_funcs{5} = @(time) (time + 1);
clear CQI
CQI(1:num_users,1:num_frames*10) = 0;
CQI( 1,1:num_frames*10) = 28;
CQI( 2,1:num_frames*10) = 28;
CQI( 3,1:num_frames*10) = 28;
CQI( 4,1:num_frames*10) = 28;
CQI( 5,1:num_frames*10) = 28;
[ux1, ~] = usf(num_RBs,
num_frames,
slice_parameters,
slices,
user_slice_mask,
CQI,
slice_max_packet_delay,
user_packet_size_funcs,
user_idt_funcs,
false); % graphs?
thrpt = [average(ux1(1).thrpt), average(ux1(2).thrpt), average(ux1(3).thrpt); average(ux1(4).thrpt), average(ux1(5).thrpt) 0] / 1000
figure;
bar(thrpt);
grid on;
ylim([0 inf]);
xlabel('Slice');
ylabel('DL Throughput (Mbps)');
print('isolation32.png', '-dpng', '-F:20');
user_slice_mask = [1 1 1 2 2 2]; % add sixth user
user_packet_size_funcs{6} = @() (1000);
user_idt_funcs{6} = @(time) (time + 1);
num_users = length(user_slice_mask);
CQI( 6,1:num_frames*10) = 28;
[ux2, ~] = usf(num_RBs,
num_frames,
slice_parameters,
slices,
user_slice_mask,
CQI,
slice_max_packet_delay,
user_packet_size_funcs,
user_idt_funcs,
false); % graphs?
thrpt = [average(ux2(1).thrpt), average(ux2(2).thrpt), average(ux2(3).thrpt); average(ux2(4).thrpt), average(ux2(5).thrpt) average(ux2(6).thrpt)] / 1000;
figure;
bar(thrpt);
ylim([0 inf]);
grid on;
xlabel('Slice');
ylabel('DL Throughput (Mbps)');
print('isolation33.png', '-dpng', '-F:20');
save('isolation-save.m');
addpath("..");
num_frames = 3500;
num_RBs = 25;
slices = {"schedule_rr", "schedule_rr", "schedule_delay"};
slice_strat = SliceStrategy.Concurrent;
conc_parameters(1) = struct("type", SliceType.Dynamic, "reserved", 5000, "option",
struct("reference", 12500));
conc_parameters(2) = struct("type", SliceType.Dynamic, "reserved", 5000, "option",
struct("reference", 12500));
conc_parameters(3) = struct("type", SliceType.OnDemand, "reserved", 0, "option",
struct("tmax", 0.20,
"logdelta", -log10(1e-3),
"tau", 10));
slice_parameters = struct("strategy", slice_strat, "parameters", conc_parameters);
user_slice_mask = [1 1 2 2 3 3 3 3];
num_users = length(user_slice_mask);
slice_max_packet_delay = [50 50 9];
% bitrate for user: avg*8/IDT kbps per user!!
user_packet_size_funcs{ 1} = @() (1250); % 2.5Mbps
user_packet_size_funcs{ 2} = @() (1250);
user_packet_size_funcs{ 3} = @() (1250);
user_packet_size_funcs{ 4} = @() (1250);
user_packet_size_funcs{ 5} = @() (255);
user_packet_size_funcs{ 6} = @() (255);
user_packet_size_funcs{ 7} = @() (255);
user_packet_size_funcs{ 8} = @() (255);
user_idt_funcs{ 1} = @(time) (time + 4);
user_idt_funcs{ 2} = @(time) (time + 4);
user_idt_funcs{ 3} = @(time) (time + 4);
user_idt_funcs{ 4} = @(time) (time + 4);
user_idt_funcs{ 5} = @(time) time + exprnd(10) + 1;
user_idt_funcs{ 6} = @(time) time + exprnd(10) + 1;
user_idt_funcs{ 7} = @(time) time + exprnd(10) + 1;
user_idt_funcs{ 8} = @(time) time + exprnd(10) + 1;
clear CQI
CQI(1:num_users,1:num_frames*10) = 0;
CQI( 1, 1:35000) = 28;
CQI( 2, 1:35000) = 28;
CQI( 3, 1:35000) = 28;
CQI( 4, 1:35000) = 28;
CQI( 5, 1:35000) = 28;
CQI( 6, 1:35000) = 28;
CQI( 7, 1:35000) = 28;
CQI( 8, 1:35000) = 28;
% first drop at subframe 5000
CQI( 3, 5000: 9999) = 25;
CQI( 4, 5000: 9999) = 25;
CQI( 5, 5000: 9999) = 23;
CQI( 6, 5000: 9999) = 23;
CQI( 7, 5000: 9999) = 23;
CQI( 8, 5000: 9999) = 23;
% second drop at subframe 10000
CQI( 3,10000:14999) = 22;
CQI( 4,10000:14999) = 22;
CQI( 5,10000:14999) = 18;
CQI( 6,10000:14999) = 18;
CQI( 7,10000:14999) = 18;
CQI( 8,10000:14999) = 18;
% re-establishment is implicit for dynamic at subframe 15000
CQI( 5,15000:19999) = 18;
CQI( 6,15000:19999) = 18;
CQI( 7,15000:19999) = 18;
CQI( 8,15000:19999) = 18;
% drop for on-demand at 20000
CQI( 5,20000:24999) = 17;
CQI( 6,20000:24999) = 17;
CQI( 7,20000:24999) = 17;
CQI( 8,20000:24999) = 17;
% drop for on-demand at 25000
CQI( 5,25000:29999) = 16;
CQI( 6,25000:29999) = 16;
CQI( 7,25000:29999) = 16;
CQI( 8,25000:29999) = 16;
% re-stabblishment is implicit for on-demand at subframe 30000
rande('state', 1);
[ux_conc, sx_conc] = usf(num_RBs,
num_frames,
slice_parameters,
slices,
user_slice_mask,
CQI,
slice_max_packet_delay,
user_packet_size_funcs,
user_idt_funcs,
false); % graphs?
%sum(ux_conc(7).packet_delay)/length(ux_conc(7).packet_delay)
%sum(ux_conc(8).packet_delay)/length(ux_conc(8).packet_delay)
%sum(ux_conc(9).packet_delay)/length(ux_conc(9).packet_delay)
%sum(ux_conc(10).packet_delay)/length(ux_conc(10).packet_delay)
save('mcs_drop-save.m');
load('mcs_drop-save.m');
slice1thr = crush((ux_conc(1).thrpt+ux_conc(2).thrpt)/1000, 100);
length(slice1thr)
slice2thr = crush((ux_conc(3).thrpt+ux_conc(4).thrpt)/1000, 100);
length(slice2thr)
avg_delays = [];
for i = 1:350 % every 0.1s in 35s
avg_packet_delay = [];
ub = i * 100;
lb = ub - 100;
for u = 5:8
% get all packets delivered before ub
idxsu = ux_conc(u).packet_delay_delivered < ub;
lower = ux_conc(u).packet_delay_delivered(idxsu);
% get all packets delivered after lb within the delivered packets
idxsl = lb <= lower;
lower = ux_conc(u).packet_delay(idxsu);
% save these delays
avg_packet_delay = [avg_packet_delay lower(idxsl)];
end
avg_delays(end+1) = average(avg_packet_delay);
end
length(avg_delays)
lost_packets = sum([ux_conc(5:8).lost_packets])
all_packets = length([ux_conc(5:8).packet_delay]) + lost_packets
packet_delay_delivered = [ux_conc(5:8).packet_delay_delivered];
packet_delay = [ux_conc(5:8).packet_delay];
for range = 1:6
endtime = range * 5000;
starttime = endtime - 5000;
%min(packet_delay_delivered)
%max(packet_delay_delivered)
% Get indices of all packet arrivals between starttime and endtime
idxu = packet_delay_delivered < endtime;
delivered = packet_delay_delivered(idxu);
idxl = starttime <= delivered;
%delivered = delivered(idxl);
%min(delays);
%max(delays);
% Get the delay for packets arrived between starttime and endtime
delays = packet_delay(idxu);
delays = delays(idxl);
% Calculate the CDF for these delays
delay_cdf{range} = [];
for n = 0:0.1:10
delay_cdf{range}(end+1) = sum(delays <= n) / length(delays);
end
end
addpath('..');
num_frames = 100;
num_RBs = 25;
slices = {'schedule_rr', 'schedule_rr', 'schedule_rr', 'schedule_delay'};
slice_strat = SliceStrategy.Concurrent;
conc_parameters(1) = struct('type', SliceType.Fixed, 'reserved', 0.24, 'option',
struct('position', 0.52));
conc_parameters(2) = struct('type', SliceType.Dynamic, 'reserved', 3800, 'option',
struct('reference', 14400));
conc_parameters(3) = struct('type', SliceType.Dynamic, 'reserved', 3800, 'option',
struct('reference', 14400));
conc_parameters(4) = struct('type', SliceType.OnDemand, 'reserved', 1000, 'option',
struct('tmax', 0.20,
'logdelta', -log10(1e-3),
'tau', 10));
slice_parameters = struct('strategy', slice_strat, 'parameters', conc_parameters);
user_slice_mask = [1 1 2 2 3 3 4 4];
num_users = length(user_slice_mask);
% packet delay budget for each Network Slice based on their QCI in LTE (70% of
% the time can be spent in buffer queue)
slice_max_packet_delay = [50 50 50 3];
% bitrate for user: avg*8/IDT kbps per user!!
user_packet_size_funcs{ 1} = @() (2000);
user_packet_size_funcs{ 2} = @() (2000);
user_packet_size_funcs{ 3} = @() (2000);
user_packet_size_funcs{ 4} = @() (2000);
user_packet_size_funcs{ 5} = @() (2000);
user_packet_size_funcs{ 6} = @() (2000);
user_packet_size_funcs{ 7} = @() (255);
user_packet_size_funcs{ 8} = @() (255);
user_idt_funcs{ 1} = @(time) (time + 1);
user_idt_funcs{ 2} = @(time) (time + 1);
user_idt_funcs{ 3} = @(time) (time + 1);
user_idt_funcs{ 4} = @(time) (time + 1);
user_idt_funcs{ 5} = @(time) (time + 1);
user_idt_funcs{ 6} = @(time) (time + 1);
randp('state', 1); % reset poisson random number generator
% poisson-shaped packet arrivals: E[X]= Var(X)=lambda=10(s)
function t = attack(time, offset)
if time < offset;
t = time + poissrnd(10);
else
t = time + 1;
end
end
user_idt_funcs{ 7} = @(time) attack(time, 50);
user_idt_funcs{ 8} = @(time) attack(time, 50);
clear CQI
CQI(1:num_users,1:num_frames*10) = 0;
CQI( 1,1:num_frames*10) = 28;
CQI( 2,1:num_frames*10) = 28;
CQI( 3,1:num_frames*10) = 28;
CQI( 4,1:num_frames*10) = 28;
CQI( 5,1:num_frames*10) = 28;
CQI( 6,1:num_frames*10) = 28;
CQI( 7,1:num_frames*10) = 28;
CQI( 8,1:num_frames*10) = 28;
[ux_conc, sx_conc, rb_alloc] = usf(num_RBs,
num_frames,
slice_parameters,
slices,
user_slice_mask,
CQI,
slice_max_packet_delay,
user_packet_size_funcs,
user_idt_funcs,
false); % graphs?
save('multi-slice-save.m');
load('multi-slice-save.m')
clear x
clear y
clear rb_alloc1
clear s1
rb_alloc1 = rb_alloc(20:80,:);
x = [];
y = [];
s1 = rb_alloc1 == 4;
for i = 1:61
for j = 1:25
if s1(i,j) == 1
x = [x i];
y = [y j];
end
end
end
addpath('..');
num_frames = 30*100;
num_RBs = 25; % maximum of 14.4Mpbs at MCS 28
slices = {'schedule_rr', 'schedule_rr', 'schedule_rr'};
slice_strat = SliceStrategy.Concurrent;
conc_parameters(1) = struct('type', SliceType.Fixed, 'reserved', 0.28, 'option',
struct('position', 0.00));
conc_parameters(2) = struct('type', SliceType.Fixed, 'reserved', 0.32, 'option',
struct('position', 0.28));
conc_parameters(3) = struct('type', SliceType.Fixed, 'reserved', 0.40, 'option',
struct('position', 0.60));
slice_parameters = struct('strategy', slice_strat, 'parameters', conc_parameters);
user_slice_mask = [1 2 3];
num_users = length(user_slice_mask);
% packet delay budget for each Network Slice based on their QCI in LTE (70% of
% the time can be spent in buffer queue)
slice_max_packet_delay = [60000 60000 60000]*0.7;
% bitrate for user: avg*8/IDT kbps per user!!
slice_avg_pckt_size = [504000 1152000 2160000];
user_packet_size_funcs{1} = @() (504000);
user_packet_size_funcs{2} = @() (1152000);
user_packet_size_funcs{3} = @() (2160000);
function next = periodic_traffic(time, period)
if time == 0; next = 1; else next = time + period; end
end
user_idt_funcs{1} = @(time) periodic_traffic(time, 2000);
user_idt_funcs{2} = @(time) periodic_traffic(time, 3000);
user_idt_funcs{3} = @(time) periodic_traffic(time, 4000);
clear CQI
CQI(1:num_users,1:num_frames*10) = 0;
CQI( 1,1:num_frames*10) = 28;
CQI( 2,1:num_frames*10) = 28;
CQI( 3,1:num_frames*10) = 28;
[ux1, ~] = usf(num_RBs,
num_frames,
slice_parameters,
slices,
user_slice_mask,
CQI,
slice_max_packet_delay,
user_packet_size_funcs,
user_idt_funcs,
false); % graphs?
clear thrpt
thrpt(1,:) = smooth(ux1(1).thrpt, 201);
thrpt(2,:) = smooth(ux1(2).thrpt, 201);
thrpt(3,:) = smooth(ux1(3).thrpt, 201);
cc = 'brkgmc';
figure
for k=1:num_users
hold on
plot (1:length(thrpt(k,:)), thrpt(k,:), 'color', cc(k))
end
ylim([0 inf]);
xlim([100 num_frames*10-100]);
leg = legend(['slice 1'; 'slice 2'; 'slice 3']);
set(leg, 'interpreter', 'none');
title('throughput for slices for PRB (static)')
clear conc_parameters
conc_parameters(1) = struct('type', SliceType.Dynamic, 'reserved', 4032,
'option', struct('reference', 14400));
conc_parameters(2) = struct('type', SliceType.Dynamic, 'reserved', 4608,
'option', struct('reference', 14400));
conc_parameters(3) = struct('type', SliceType.Dynamic, 'reserved', 5760,
'option', struct('reference', 14400));
slice_parameters = struct('strategy', slice_strat, 'parameters', conc_parameters);
[ux2, ~] = usf(num_RBs,
num_frames,
slice_parameters,
slices,
user_slice_mask,
CQI,
slice_max_packet_delay,
user_packet_size_funcs,
user_idt_funcs,
false); % graphs?
clear thrpt
thrpt(1,:) = smooth(ux2(1).thrpt, 201);
thrpt(2,:) = smooth(ux2(2).thrpt, 201);
thrpt(3,:) = smooth(ux2(3).thrpt, 201);
cc = 'brkgmc';
figure
for k=1:num_users
hold on
plot (1:length(thrpt(k,:)), thrpt(k,:), 'color', cc(k))
end
xlim([100 num_frames*10-100]);
ylim([0 inf]);
leg = legend(['slice 1', 'slice 2', 'slice 3']);
set(leg, 'interpreter', 'none');
title('throughput for slices with rate (dynamic)')
save('utilisation-save.m');
addpath('..');
num_frames = 10*100;
num_RBs = 25; % maximum of 14.4Mpbs at MCS 28
slices = {'schedule_rr', 'schedule_rr', 'schedule_rr'};
slice_strat = SliceStrategy.Concurrent;
conc_parameters(1) = struct('type', SliceType.Fixed, 'reserved', 0.28, 'option',
struct('position', 0.00));
conc_parameters(2) = struct('type', SliceType.Fixed, 'reserved', 0.32, 'option',
struct('position', 0.28));
conc_parameters(3) = struct('type', SliceType.Fixed, 'reserved', 0.40, 'option',
struct('position', 0.60));
slice_parameters = struct('strategy', slice_strat, 'parameters', conc_parameters);
user_slice_mask = [1 2 3];
num_users = length(user_slice_mask);
% packet delay budget for each Network Slice based on their QCI in LTE (70% of
% the time can be spent in buffer queue)
slice_max_packet_delay = [60000 60000 60000]*0.7;
% bitrate for user: avg*8/IDT kbps per user!!
user_packet_size_funcs{1} = @() (504000); % 28% of 14.4Mbps=4.032Mbps=504kB/s, takes 1s
user_packet_size_funcs{2} = @() (1152000); % 32% of 14.4Mbps=576kB/s, takes 2s
user_packet_size_funcs{3} = @() (2160000); % 720kB/s, takes 3s
user_idt_funcs{1} = @(time) (time + 1500);
user_idt_funcs{2} = @(time) (time + 2500);
user_idt_funcs{3} = @(time) (time + 3500);
clear CQI
CQI(1:num_users,1:num_frames*10) = 0;
CQI( 1,1:num_frames*10) = 28;
CQI( 2,1:num_frames*10) = 28;
CQI( 3,1:num_frames*10) = 28;
[ux_util1, ~] = usf(num_RBs,
num_frames,
slice_parameters,
slices,
user_slice_mask,
CQI,
slice_max_packet_delay,
user_packet_size_funcs,
user_idt_funcs,
false); % graphs?
clear thrpt1
thrpt1(1,:) = smooth(ux_util1(1).thrpt, 201);
thrpt1(2,:) = smooth(ux_util1(2).thrpt, 201);
thrpt1(3,:) = smooth(ux_util1(3).thrpt, 201);
tot_thrpt1 = smooth(ux_util1(1).thrpt+ux_util1(2).thrpt+ux_util1(3).thrpt,201);
cc = 'brgkmc';
f2 = figure
for k=1:num_users
hold on
plot (1:length(thrpt1(k,:)), thrpt1(k,:)/1000, 'color', cc(k))
end
hold on
plot(1:length(tot_thrpt1), tot_thrpt1/1000, 'color', cc(k+1));
grid on;
ylim([0 16]);
xlim([600 8000]);
leg = legend(['slice 1'; 'slice 2'; 'slice 3'; 'cell']);
print(f2, 'utilisation-ineff.png', '-dpng', '-S900,450', '-F:12');
%set(leg, 'interpreter', 'none');
%title('throughput for slices for Fixed (static)')
clear conc_parameters
conc_parameters(1) = struct('type', SliceType.Dynamic, 'reserved', 4032,
'option', struct('reference', 14400));
conc_parameters(2) = struct('type', SliceType.Dynamic, 'reserved', 4608,
'option', struct('reference', 14400));
conc_parameters(3) = struct('type', SliceType.Dynamic, 'reserved', 5760,
'option', struct('reference', 14400));
slice_parameters = struct('strategy', slice_strat, 'parameters', conc_parameters);
[ux_util2, ~] = usf(num_RBs,
num_frames,
slice_parameters,
slices,
user_slice_mask,
CQI,
slice_max_packet_delay,
user_packet_size_funcs,
user_idt_funcs,
false); % graphs?
clear thrpt2
thrpt2(1,:) = smooth(ux_util2(1).thrpt, 201);
thrpt2(2,:) = smooth(ux_util2(2).thrpt, 201);
thrpt2(3,:) = smooth(ux_util2(3).thrpt, 201);
tot_thrpt2 = smooth(ux_util2(1).thrpt+ux_util2(2).thrpt+ux_util2(3).thrpt,201);
cc = 'brgkmc';
f1 = figure
for k=1:num_users
hold on
plot (1:length(thrpt2(k,:)), thrpt2(k,:)/1000, 'color', cc(k))
end
hold on
plot(1:length(tot_thrpt), tot_thrpt/1000, 'color', cc(k+1));
grid on;
ylim([0 16]);
xlim([600 8000]);
leg = legend(['slice 1'; 'slice 2'; 'slice 3'; 'cell']);
print(f1, 'utilisation-ineff.png', '-dpng', '-S900,450', '-F:12');
%set(leg, 'interpreter', 'none');
%title('throughput for slices with rate (dynamic)')
save('utilisation-save.m');
function I_TBS = MCS_func(I_MCS)
MCStable = [0 1 2 3 4 5 6 7 8 9 9 10 11 12 13 14 15 15 16 17 18 19 20 21 22 23 24 25 26];
I_TBS = MCStable(I_MCS);
% I_TBS = 13;
function TBS = TBS_func(I_TBS,RBs)
TBStable = floor([16 32 56 88 120 152 176 208 224 256 288 328 344 376 392 424 456 488 504 536 568 600 616 648 680 712 744 776 776 808 840 872 904 936 968 1000 1032 1032 1064 1096 1128 1160 1192 1224 1256 1256 1288 1320 1352 1384 1416 1416 1480 1480 1544 1544 1608 1608 1608 1672 1672 1736 1736 1800 1800 1800 1864 1864 1928 1928 1992 1992 2024 2088 2088 2088 2152 2152 2216 2216 2280 2280 2280 2344 2344 2408 2408 2472 2472 2536 2536 2536 2600 2600 2664 2664 2728 2728 2728 2792 2792 2856 2856 2856 2984 2984 2984 2984 2984 3112;
24 56 88 144 176 208 224 256 328 344 376 424 456 488 520 568 600 632 680 712 744 776 808 872 904 936 968 1000 1032 1064 1128 1160 1192 1224 1256 1288 1352 1384 1416 1416 1480 1544 1544 1608 1608 1672 1736 1736 1800 1800 1864 1864 1928 1992 1992 2024 2088 2088 2152 2152 2216 2280 2280 2344 2344 2408 2472 2472 2536 2536 2600 2600 2664 2728 2728 2792 2792 2856 2856 2856 2984 2984 2984 3112 3112 3112 3240 3240 3240 3240 3368 3368 3368 3496 3496 3496 3496 3624 3624 3624 3752 3752 3752 3752 3880 3880 3880 4008 4008 4008;
32 72 144 176 208 256 296 328 376 424 472 520 568 616 648 696 744 776 840 872 936 968 1000 1064 1096 1160 1192 1256 1288 1320 1384 1416 1480 1544 1544 1608 1672 1672 1736 1800 1800 1864 1928 1992 2024 2088 2088 2152 2216 2216 2280 2344 2344 2408 2472 2536 2536 2600 2664 2664 2728 2792 2856 2856 2856 2984 2984 3112 3112 3112 3240 3240 3240 3368 3368 3368 3496 3496 3496 3624 3624 3624 3752 3752 3880 3880 3880 4008 4008 4008 4136 4136 4136 4264 4264 4264 4392 4392 4392 4584 4584 4584 4584 4584 4776 4776 4776 4776 4968 4968;
40 104 176 208 256 328 392 440 504 568 616 680 744 808 872 904 968 1032 1096 1160 1224 1256 1320 1384 1416 1480 1544 1608 1672 1736 1800 1864 1928 1992 2024 2088 2152 2216 2280 2344 2408 2472 2536 2536 2600 2664 2728 2792 2856 2856 2984 2984 3112 3112 3240 3240 3368 3368 3496 3496 3624 3624 3624 3752 3752 3880 3880 4008 4008 4136 4136 4264 4264 4392 4392 4392 4584 4584 4584 4776 4776 4776 4776 4968 4968 4968 5160 5160 5160 5352 5352 5352 5352 5544 5544 5544 5736 5736 5736 5736 5992 5992 5992 5992 6200 6200 6200 6200 6456 6456;
56 120 208 256 328 408 488 552 632 696 776 840 904 1000 1064 1128 1192 1288 1352 1416 1480 1544 1608 1736 1800 1864 1928 1992 2088 2152 2216 2280 2344 2408 2472 2600 2664 2728 2792 2856 2984 2984 3112 3112 3240 3240 3368 3496 3496 3624 3624 3752 3752 3880 4008 4008 4136 4136 4264 4264 4392 4392 4584 4584 4584 4776 4776 4968 4968 4968 5160 5160 5160 5352 5352 5544 5544 5544 5736 5736 5736 5992 5992 5992 5992 6200 6200 6200 6456 6456 6456 6456 6712 6712 6712 6968 6968 6968 6968 7224 7224 7224 7480 7480 7480 7480 7736 7736 7736 7992;
72 144 224 328 424 504 600 680 776 872 968 1032 1128 1224 1320 1384 1480 1544 1672 1736 1864 1928 2024 2088 2216 2280 2344 2472 2536 2664 2728 2792 2856 2984 3112 3112 3240 3368 3496 3496 3624 3752 3752 3880 4008 4008 4136 4264 4392 4392 4584 4584 4776 4776 4776 4968 4968 5160 5160 5352 5352 5544 5544 5736 5736 5736 5992 5992 5992 6200 6200 6200 6456 6456 6712 6712 6712 6968 6968 6968 7224 7224 7224 7480 7480 7480 7736 7736 7736 7992 7992 7992 8248 8248 8248 8504 8504 8760 8760 8760 8760 9144 9144 9144 9144 9528 9528 9528 9528 9528;
328 176 256 392 504 600 712 808 936 1032 1128 1224 1352 1480 1544 1672 1736 1864 1992 2088 2216 2280 2408 2472 2600 2728 2792 2984 2984 3112 3240 3368 3496 3496 3624 3752 3880 4008 4136 4136 4264 4392 4584 4584 4776 4776 4968 4968 5160 5160 5352 5352 5544 5736 5736 5992 5992 5992 6200 6200 6456 6456 6456 6712 6712 6968 6968 6968 7224 7224 7480 7480 7736 7736 7736 7992 7992 8248 8248 8248 8504 8504 8760 8760 8760 9144 9144 9144 9144 9528 9528 9528 9528 9912 9912 9912 10296 10296 10296 10296 10680 10680 10680 10680 11064 11064 11064 11448 11448 11448;
104 224 328 472 584 712 840 968 1096 1224 1320 1480 1608 1672 1800 1928 2088 2216 2344 2472 2536 2664 2792 2984 3112 3240 3368 3368 3496 3624 3752 3880 4008 4136 4264 4392 4584 4584 4776 4968 4968 5160 5352 5352 5544 5736 5736 5992 5992 6200 6200 6456 6456 6712 6712 6712 6968 6968 7224 7224 7480 7480 7736 7736 7992 7992 8248 8248 8504 8504 8760 8760 8760 9144 9144 9144 9528 9528 9528 9912 9912 9912 10296 10296 10296 10680 10680 10680 11064 11064 11064 11448 11448 11448 11448 11832 11832 11832 12216 12216 12216 12576 12576 12576 12960 12960 12960 12960 13536 13536;
120 256 392 536 680 808 968 1096 1256 1384 1544 1672 1800 1928 2088 2216 2344 2536 2664 2792 2984 3112 3240 3368 3496 3624 3752 3880 4008 4264 4392 4584 4584 4776 4968 4968 5160 5352 5544 5544 5736 5992 5992 6200 6200 6456 6456 6712 6968 6968 7224 7224 7480 7480 7736 7736 7992 7992 8248 8504 8504 8760 8760 9144 9144 9144 9528 9528 9528 9912 9912 9912 10296 10296 10680 10680 10680 11064 11064 11064 11448 11448 11448 11832 11832 12216 12216 12216 12576 12576 12576 12960 12960 12960 13536 13536 13536 13536 14112 14112 14112 14112 14688 14688 14688 14688 15264 15264 15264 15264;
136 296 456 616 776 936 1096 1256 1416 1544 1736 1864 2024 2216 2344 2536 2664 2856 2984 3112 3368 3496 3624 3752 4008 4136 4264 4392 4584 4776 4968 5160 5160 5352 5544 5736 5736 5992 6200 6200 6456 6712 6712 6968 6968 7224 7480 7480 7736 7992 7992 8248 8248 8504 8760 8760 9144 9144 9144 9528 9528 9912 9912 10296 10296 10296 10680 10680 11064 11064 11064 11448 11448 11832 11832 11832 12216 12216 12576 12576 12960 12960 12960 13536 13536 13536 13536 14112 14112 14112 14112 14688 14688 14688 15264 15264 15264 15264 15840 15840 15840 16416 16416 16416 16416 16992 16992 16992 16992 17568;
144 328 504 680 872 1032 1224 1384 1544 1736 1928 2088 2280 2472 2664 2792 2984 3112 3368 3496 3752 3880 4008 4264 4392 4584 4776 4968 5160 5352 5544 5736 5736 5992 6200 6200 6456 6712 6712 6968 7224 7480 7480 7736 7992 7992 8248 8504 8504 8760 9144 9144 9144 9528 9528 9912 9912 10296 10296 10680 10680 11064 11064 11448 11448 11448 11832 11832 12216 12216 12576 12576 12960 12960 12960 13536 13536 13536 14112 14112 14112 14688 14688 14688 14688 15264 15264 15264 15840 15840 15840 16416 16416 16416 16992 16992 16992 16992 17568 17568 17568 18336 18336 18336 18336 18336 19080 19080 19080 19080;
176 376 584 776 1000 1192 1384 1608 1800 2024 2216 2408 2600 2792 2984 3240 3496 3624 3880 4008 4264 4392 4584 4776 4968 5352 5544 5736 5992 5992 6200 6456 6712 6968 6968 7224 7480 7736 7736 7992 8248 8504 8760 8760 9144 9144 9528 9528 9912 9912 10296 10680 10680 11064 11064 11448 11448 11832 11832 12216 12216 12576 12576 12960 12960 13536 13536 13536 14112 14112 14112 14688 14688 14688 15264 15264 15840 15840 15840 16416 16416 16416 16992 16992 16992 17568 17568 17568 18336 18336 18336 18336 19080 19080 19080 19080 19848 19848 19848 19848 20616 20616 20616 21384 21384 21384 21384 22152 22152 22152;
208 440 680 904 1128 1352 1608 1800 2024 2280 2472 2728 2984 3240 3368 3624 3880 4136 4392 4584 4776 4968 5352 5544 5736 5992 6200 6456 6712 6712 6968 7224 7480 7736 7992 8248 8504 8760 8760 9144 9528 9528 9912 9912 10296 10680 10680 11064 11064 11448 11832 11832 12216 12216 12576 12576 12960 12960 13536 13536 14112 14112 14112 14688 14688 15264 15264 15264 15840 15840 16416 16416 16416 16992 16992 17568 17568 17568 18336 18336 18336 19080 19080 19080 19080 19848 19848 19848 20616 20616 20616 21384 21384 21384 21384 22152 22152 22152 22920 22920 22920 23688 23688 23688 23688 24496 24496 24496 24496 25456;
224 488 744 1000 1256 1544 1800 2024 2280 2536 2856 3112 3368 3624 3880 4136 4392 4584 4968 5160 5352 5736 5992 6200 6456 6712 6968 7224 7480 7736 7992 8248 8504 8760 9144 9144 9528 9912 9912 10296 10680 10680 11064 11448 11448 11832 12216 12216 12576 12960 12960 13536 13536 14112 14112 14688 14688 14688 15264 15264 15840 15840 16416 16416 16992 16992 16992 17568 17568 18336 18336 18336 19080 19080 19080 19848 19848 19848 20616 20616 20616 21384 21384 21384 22152 22152 22152 22920 22920 22920 23688 23688 23688 24496 24496 24496 25456 25456 25456 25456 26416 26416 26416 26416 27376 27376 27376 27376 28336 28336;
256 552 840 1128 1416 1736 1992 2280 2600 2856 3112 3496 3752 4008 4264 4584 4968 5160 5544 5736 5992 6200 6456 6968 7224 7480 7736 7992 8248 8504 8760 9144 9528 9912 9912 10296 10680 11064 11064 11448 11832 12216 12216 12576 12960 12960 13536 13536 14112 14112 14688 14688 15264 15264 15840 15840 16416 16416 16992 16992 17568 17568 18336 18336 18336 19080 19080 19848 19848 19848 20616 20616 20616 21384 21384 22152 22152 22152 22920 22920 22920 23688 23688 24496 24496 24496 25456 25456 25456 25456 26416 26416 26416 27376 27376 27376 28336 28336 28336 28336 29296 29296 29296 29296 30576 30576 30576 30576 31704 31704;
280 600 904 1224 1544 1800 2152 2472 2728 3112 3368 3624 4008 4264 4584 4968 5160 5544 5736 6200 6456 6712 6968 7224 7736 7992 8248 8504 8760 9144 9528 9912 10296 10296 10680 11064 11448 11832 11832 12216 12576 12960 12960 13536 13536 14112 14688 14688 15264 15264 15840 15840 16416 16416 16992 16992 17568 17568 18336 18336 18336 19080 19080 19848 19848 20616 20616 20616 21384 21384 22152 22152 22152 22920 22920 23688 23688 23688 24496 24496 24496 25456 25456 25456 26416 26416 26416 27376 27376 27376 28336 28336 28336 29296 29296 29296 29296 30576 30576 30576 30576 31704 31704 31704 31704 32856 32856 32856 34008 34008;
328 632 968 1288 1608 1928 2280 2600 2984 3240 3624 3880 4264 4584 4968 5160 5544 5992 6200 6456 6712 7224 7480 7736 7992 8504 8760 9144 9528 9912 9912 10296 10680 11064 11448 11832 12216 12216 12576 12960 13536 13536 14112 14112 14688 14688 15264 15840 15840 16416 16416 16992 16992 17568 17568 18336 18336 19080 19080 19848 19848 19848 20616 20616 21384 21384 22152 22152 22152 22920 22920 23688 23688 24496 24496 24496 25456 25456 25456 26416 26416 26416 27376 27376 27376 28336 28336 28336 29296 29296 29296 30576 30576 30576 30576 31704 31704 31704 31704 32856 32856 32856 34008 34008 34008 34008 35160 35160 35160 35160;
336 696 1064 1416 1800 2152 2536 2856 3240 3624 4008 4392 4776 5160 5352 5736 6200 6456 6712 7224 7480 7992 8248 8760 9144 9528 9912 10296 10296 10680 11064 11448 11832 12216 12576 12960 13536 13536 14112 14688 14688 15264 15264 15840 16416 16416 16992 17568 17568 18336 18336 19080 19080 19848 19848 20616 20616 20616 21384 21384 22152 22152 22920 22920 23688 23688 24496 24496 24496 25456 25456 26416 26416 26416 27376 27376 27376 28336 28336 29296 29296 29296 30576 30576 30576 30576 31704 31704 31704 32856 32856 32856 34008 34008 34008 35160 35160 35160 35160 36696 36696 36696 36696 37888 37888 37888 39232 39232 39232 39232;
376 776 1160 1544 1992 2344 2792 3112 3624 4008 4392 4776 5160 5544 5992 6200 6712 7224 7480 7992 8248 8760 9144 9528 9912 10296 10680 11064 11448 11832 12216 12576 12960 13536 14112 14112 14688 15264 15264 15840 16416 16416 16992 17568 17568 18336 18336 19080 19080 19848 19848 20616 21384 21384 22152 22152 22920 22920 23688 23688 24496 24496 24496 25456 25456 26416 26416 27376 27376 27376 28336 28336 29296 29296 29296 30576 30576 30576 31704 31704 31704 32856 32856 32856 34008 34008 34008 35160 35160 35160 36696 36696 36696 37888 37888 37888 37888 39232 39232 39232 40576 40576 40576 40576 42368 42368 42368 42368 43816 43816;
408 840 1288 1736 2152 2600 2984 3496 3880 4264 4776 5160 5544 5992 6456 6968 7224 7736 8248 8504 9144 9528 9912 10296 10680 11064 11448 12216 12576 12960 13536 13536 14112 14688 15264 15264 15840 16416 16992 16992 17568 18336 18336 19080 19080 19848 20616 20616 21384 21384 22152 22152 22920 22920 23688 24496 24496 25456 25456 25456 26416 26416 27376 27376 28336 28336 29296 29296 29296 30576 30576 30576 31704 31704 32856 32856 32856 34008 34008 34008 35160 35160 35160 36696 36696 36696 37888 37888 37888 39232 39232 39232 40576 40576 40576 40576 42368 42368 42368 43816 43816 43816 43816 45352 45352 45352 46888 46888 46888 46888;
440 904 1384 1864 2344 2792 3240 3752 4136 4584 5160 5544 5992 6456 6968 7480 7992 8248 8760 9144 9912 10296 10680 11064 11448 12216 12576 12960 13536 14112 14688 14688 15264 15840 16416 16992 16992 17568 18336 18336 19080 19848 19848 20616 20616 21384 22152 22152 22920 22920 23688 24496 24496 25456 25456 26416 26416 27376 27376 28336 28336 29296 29296 29296 30576 30576 31704 31704 31704 32856 32856 34008 34008 34008 35160 35160 35160 36696 36696 36696 37888 37888 39232 39232 39232 40576 40576 40576 42368 42368 42368 42368 43816 43816 43816 45352 45352 45352 46888 46888 46888 46888 48936 48936 48936 48936 48936 51024 51024 51024;
488 1000 1480 1992 2472 2984 3496 4008 4584 4968 5544 5992 6456 6968 7480 7992 8504 9144 9528 9912 10680 11064 11448 12216 12576 12960 13536 14112 14688 15264 15840 15840 16416 16992 17568 18336 18336 19080 19848 19848 20616 21384 21384 22152 22920 22920 23688 24496 24496 25456 25456 26416 26416 27376 27376 28336 28336 29296 29296 30576 30576 31704 31704 31704 32856 32856 34008 34008 35160 35160 35160 36696 36696 36696 37888 37888 39232 39232 39232 40576 40576 40576 42368 42368 42368 43816 43816 43816 45352 45352 45352 46888 46888 46888 46888 48936 48936 48936 48936 51024 51024 51024 51024 52752 52752 52752 52752 55056 55056 55056;
520 1064 1608 2152 2664 3240 3752 4264 4776 5352 5992 6456 6968 7480 7992 8504 9144 9528 10296 10680 11448 11832 12576 12960 13536 14112 14688 15264 15840 16416 16992 16992 17568 18336 19080 19080 19848 20616 21384 21384 22152 22920 22920 23688 24496 24496 25456 25456 26416 27376 27376 28336 28336 29296 29296 30576 30576 31704 31704 32856 32856 34008 34008 34008 35160 35160 36696 36696 36696 37888 37888 39232 39232 40576 40576 40576 42368 42368 42368 43816 43816 43816 45352 45352 45352 46888 46888 46888 48936 48936 48936 48936 51024 51024 51024 51024 52752 52752 52752 55056 55056 55056 55056 57336 57336 57336 57336 59256 59256 59256;
552 1128 1736 2280 2856 3496 4008 4584 5160 5736 6200 6968 7480 7992 8504 9144 9912 10296 11064 11448 12216 12576 12960 13536 14112 14688 15264 15840 16416 16992 17568 18336 19080 19848 19848 20616 21384 22152 22152 22920 23688 24496 24496 25456 25456 26416 27376 27376 28336 28336 29296 29296 30576 30576 31704 31704 32856 32856 34008 34008 35160 35160 36696 36696 37888 37888 37888 39232 39232 40576 40576 40576 42368 42368 43816 43816 43816 45352 45352 45352 46888 46888 46888 48936 48936 48936 51024 51024 51024 51024 52752 52752 52752 55056 55056 55056 55056 57336 57336 57336 57336 59256 59256 59256 59256 61664 61664 61664 61664 63776;
584 1192 1800 2408 2984 3624 4264 4968 5544 5992 6712 7224 7992 8504 9144 9912 10296 11064 11448 12216 12960 13536 14112 14688 15264 15840 16416 16992 17568 18336 19080 19848 19848 20616 21384 22152 22920 22920 23688 24496 25456 25456 26416 26416 27376 28336 28336 29296 29296 30576 31704 31704 32856 32856 34008 34008 35160 35160 36696 36696 36696 37888 37888 39232 39232 40576 40576 42368 42368 42368 43816 43816 45352 45352 45352 46888 46888 46888 48936 48936 48936 51024 51024 51024 52752 52752 52752 52752 55056 55056 55056 57336 57336 57336 57336 59256 59256 59256 61664 61664 61664 61664 63776 63776 63776 63776 66592 66592 66592 66592;
616 1256 1864 2536 3112 3752 4392 5160 5736 6200 6968 7480 8248 8760 9528 10296 10680 11448 12216 12576 13536 14112 14688 15264 15840 16416 16992 17568 18336 19080 19848 20616 20616 21384 22152 22920 23688 24496 24496 25456 26416 26416 27376 28336 28336 29296 29296 30576 31704 31704 32856 32856 34008 34008 35160 35160 36696 36696 37888 37888 39232 39232 40576 40576 40576 42368 42368 43816 43816 43816 45352 45352 46888 46888 46888 48936 48936 48936 51024 51024 51024 52752 52752 52752 55056 55056 55056 55056 57336 57336 57336 59256 59256 59256 61664 61664 61664 61664 63776 63776 63776 63776 66592 66592 66592 66592 68808 68808 68808 71112;
712 1480 2216 2984 3752 4392 5160 5992 6712 7480 8248 8760 9528 10296 11064 11832 12576 13536 14112 14688 15264 16416 16992 17568 18336 19080 19848 20616 21384 22152 22920 23688 24496 25456 25456 26416 27376 28336 29296 29296 30576 30576 31704 32856 32856 34008 35160 35160 36696 36696 37888 37888 39232 40576 40576 40576 42368 42368 43816 43816 45352 45352 46888 46888 48936 48936 48936 51024 51024 52752 52752 52752 55056 55056 55056 55056 57336 57336 57336 59256 59256 59256 61664 61664 61664 63776 63776 63776 66592 66592 66592 68808 68808 68808 71112 71112 71112 73712 73712 75376 75376 75376 75376 75376 75376 75376 75376 75376 75376 75376]*0.8);
if(RBs == 1000)
TBS = TBStable(I_TBS,:);
else
TBS = TBStable(I_TBS,RBs);
end
\ No newline at end of file
function RBs = convert_MCS_to_RBs(MCS,throughput)
I_TBS = MCS_func(MCS+1);
TBS1 = TBS_func(I_TBS+1,1000); % 1000 is for indicating the entire row as input
TBS = throughput;
tmp = abs(TBS1-TBS);
[RBs RBs] = min(tmp); %index of closest value
function throughput = convert_MCS_to_throughput(MCS,RBs)
I_TBS = MCS_func(MCS+1);
TBS = TBS_func(I_TBS+1,RBs);
throughput = TBS;
function calculated_bytes = convert_RBs_to_bytes(MCS,RBs)
I_TBS = MCS_func(MCS+1);
TBS = TBS_func(I_TBS+1,RBs);
calculated_bytes = ceil(TBS/8);
function calculated_RBs = convert_bytes_to_RBs(MCS,bytes)
I_TBS = MCS_func(MCS+1);
TBS1 = TBS_func(I_TBS+1,1000); % 1000 is for indicating the entire row as input
TBS = bytes*8;
tmp = abs(TBS1-TBS);
[calculated_RBs calculated_RBs] = min(tmp); %index of closest value
function slice_RBs = nvs(time, num_RBs, parameters, sx)
num_slices = length(parameters);
assert(num_slices == length(sx));
persistent stats = [struct()]
if time == 0 % first access, no previous for effective and exp rates
for k = 1:num_slices
stats(k).fexp = parameters(k).reserved; % exponential moving average for weight calc
stats(k).ind = false; % indicator: has slice been scheduled last slot?
stats(k).eff = parameters(k).reference; % only for rate type
end
end
weights(1:num_slices) = 0;
beta = 0.1;
for k = 1:num_slices
switch parameters(k).type
case SliceType.Rate
inst = 0;
if stats(k).ind == true % was scheduled last time
inst = sx(k).thrpt(length(sx(k).thrpt));
stats(k).eff = (1 - beta) * stats(k).eff + beta * inst; % effective rate when slice sched
end
stats(k).fexp = (1 - beta) * stats(k).fexp + beta * inst;
rsv = parameters(k).reserved * min(1, stats(k).eff/parameters(k).reference);
weights(k) = rsv / stats(k).fexp;
case SliceType.vRB
stats(k).fexp = (1 - beta) * stats(k).fexp + beta * (stats(k).ind == true);
weights(k) = parameters(k).reserved / stats(k).fexp;
end
stats(k).ind = false;
end
[~, idx] = max(weights);
slice_RBs(1:num_RBs) = idx;
stats(idx).ind = true;
%output
%disp(["time = " num2str(time)]);
%disp(["s_exp = " num2str(s_exp(1)) ", " num2str(s_exp(2))]);
%disp(["weights = " num2str(weights(1)) ", " num2str(weights(2))]);
%disp(["RBs = " num2str(slice_RBs(1)) ", " num2str(slice_RBs(2))]);
endfunction
function traffic = rand_traffic_office(slice, user, num_users)
% Generating traffic pattern for each Network Slice for every user (1
% corresponds to continuous traffic flow and 0 corresponds to no traffic)
if k == 1 && i <= ceil(iii*0.05)
traffic = 0.3*rand(1,1);
else if k == 2 && i <= ceil(iii*0.2)
traffic = 0.5*rand(1,1);
else if k == 3 && i <= ceil(iii*0.05)
traffic = 0.3*rand(1,1);
else if k == 4 && i <= ceil(iii*0.15)
traffic = 0.5*rand(1,1);
else if k == 5 && i <= ceil(iii*0.5)
traffic = 0.8*rand(1,1);
else if k == 6 && i <= ceil(iii*0.8)
traffic = 0.9*rand(1,1);
else if k == 7 && i <= ceil(iii*0.1)
traffic = 0.5*rand(1,1);
else if k == 8 && i <= ceil(iii*0.6)
traffic = 0.8*rand(1,1);
else if k == 9 && i <= ceil(iii*0.9)
traffic = 1*rand(1,1);
end
end
end
end
end
end
end
end
end
function traffic = rand_traffic_residential(slice, user, num_users)
% Generating traffic pattern for each Network Slice for every user (1
% corresponds to continuous traffic flow and 0 corresponds to no traffic
if k == 1 && i <= ceil(iii*0.05)
traffic = 0.3*rand(1,1);
else if k == 2 && i <= ceil(iii*0.6)
traffic = 0.8*rand(1,1);
else if k == 3 && i <= ceil(iii*0.4)
traffic = 0.9*rand(1,1);
else if k == 4 && i <= ceil(iii*0.5)
traffic = 0.7*rand(1,1);
else if k == 5 && i <= ceil(iii*0.7)
traffic = 0.6*rand(1,1);
else if k == 6 && i <= ceil(iii*0.8)
traffic = 0.9*rand(1,1);
else if k == 7 && i <= ceil(iii*0.3)
traffic = 0.5*rand(1,1);
else if k == 8 && i <= ceil(iii*0.5)
traffic = 0.6*rand(1,1);
else if k == 9 && i <= ceil(iii*0.7)
traffic = 0.5*rand(1,1);
end
end
end
end
end
end
end
end
end
function [ret_hist, ret_sched_RBs, ret_sched_bytes] = schedule_bet(current_time, num_RB, ux, hist)
% users: {buffer_sizes, mcs}
ret_sched_bytes(1:num_RB) = 0;
ret_sched_RBs(1:num_RB) = 0;
num_users = length(ux);
if num_users == 0
return
end
if num_users != length(hist) % first access, because users can not be added/deleted
hist(1:num_users) = 1;
end
assert(length(hist) == num_users);
metric = 1 ./ hist;
[~,idxs] = sort(metric, 'descend');
nux = ux(idxs);
ui = 1;
for n=1:num_RB
while ui <= num_users && nux(ui).buffer_size == 0
ui += 1;
end
if ui > num_users % no UE has enough
break
end
% schedule one RB or remaining buffer of user
bytes = min(convert_RBs_to_bytes(nux(ui).mcs, 1), nux(ui).buffer_size);
nux(ui).buffer_size -= bytes;
ret_sched_bytes(n) = bytes;
ret_sched_RBs(n) = nux(ui).id;
end
% (1-beta) = alpha -> T_f = 1/(1-alpha)
% T_f = 20 -> beta = 0.05
beta = 0.05;
for u = 1:num_users
bytes = sum(ret_sched_bytes(ret_sched_RBs == ux(u).id));
hist(u) = (1 - beta) * hist(u) + beta * bytes;
end
ret_hist = hist;
function [ret_data, sched_RBs, sched_bytes, D, R] = schedule_delay(current_time, num_RB, ux, ~)
% uses: {first_pdu_arrival, latency, wbMCSs}
num_users = length(ux);
ret_data = 0;
sched_bytes(1:num_RB) = 0;
sched_RBs(1:num_RB) = 0;
D = 0;
R = 0;
if sum([ux(:).buffer_size]) == 0
return
end
for u = 1:num_users % if you know a shorter way, let me know
if length(ux(u).packet_queue) > 0
arrivals(u) = ux(u).packet_queue(1).arrival;
else
arrivals(u) = 0;
end
end
latencies = [ux.latency];
D = max(current_time - arrivals); % maximum of HOL
R = sum([ux.buffer_size]); % maximum rate we ideally would need
if num_RB == 0 % request to only update D parameter
return
end
if num_users == 0
return
end
weights = (current_time - arrivals) ./ latencies;
weights(weights > 1) = 0;
[~,idx] = sort(weights, 'descend');
ux = ux(idx);
ui = 1;
for i = 1:num_RB
while ui <= num_users && ux(ui).buffer_size == 0 % skip users without data
ui += 1;
end
if ui > num_users
break
end
% schedule one RB or remaining buffer of user
bytes = min(convert_RBs_to_bytes(ux(ui).mcs, 1), ux(ui).buffer_size);
ux(ui).buffer_size -= bytes;
sched_bytes(i) = bytes;
sched_RBs(i) = ux(ui).id;
end
function [ret_data, ret_sched_RBs, ret_sched_bytes] = schedule_mt(current_time, num_RB, ux, ~)
% users: {buffer_sizes, wbMCSs}
ret_data = 0;
sched_bytes(1:num_RB) = 0;
sched_RBs(1:num_RB) = 0;
num_users = length(ux);
if num_users == 0
return
end
max_throughput = convert_MCS_to_throughput([ux(:).mcs], num_RB);
[~,idx] = sort(max_throughput, 'descend');
ux = ux(idx);
ui = 1;
for i=1:num_RB
while (ui <= num_users && ux(ui).buffer_size == 0) % skip users without data
ui += 1;
end
if (ui > num_users)
break
end
% schedule one RB or remaining buffer of user
bytes = min(convert_RBs_to_bytes(ux(ui).mcs, 1), ux(ui).buffer_size);
ux(ui).buffer_size -= bytes;
sched_bytes(i) = bytes;
sched_RBs(i) = ux(ui).id;
end
ret_sched_RBs = sched_RBs;
ret_sched_bytes = sched_bytes;
function [ret_hist, ret_sched_RBs, ret_sched_bytes] = schedule_pf(current_time, num_RB, ux, hist)
% users: {buffer_sizes, mcs}
ret_hist = 0;
ret_sched_bytes(1:num_RB) = 0;
ret_sched_RBs(1:num_RB) = 0;
num_users = length(ux);
if num_users == 0
return
end
if num_users != length(hist) % first access, because users can not be added/deleted
hist(1:num_users) = 1;
end
% we consider only wbCQI -> we can for every user calculate the expected
% throughput for one RB once, then divide by the history
for u = 1 : num_users
thr(u) = min(convert_RBs_to_bytes(ux(u).mcs, 1), ux(u).buffer_size);
end
metric = thr ./ hist;
[~,idxs] = sort(metric, 'descend');
nux = ux(idxs);
ui = 1;
for n=1:num_RB
while (ui <= num_users && nux(ui).buffer_size == 0) % skip users without data
ui += 1;
end
if (ui > num_users)
break
end
% schedule one RB or remaining buffer of user
bytes = min(convert_RBs_to_bytes(nux(ui).mcs, 1), nux(ui).buffer_size);
nux(ui).buffer_size -= bytes;
ret_sched_bytes(n) = bytes;
ret_sched_RBs(n) = nux(ui).id;
end
% (1-beta) = alpha -> T_f = 1/(1-alpha)
% T_f = 20 -> beta = 0.05
beta = 0.05;
for u = 1:num_users
bytes = sum(ret_sched_bytes(ret_sched_RBs == ux(u).id));
hist(u) = (1 - beta) * hist(u) + beta * bytes;
end
ret_hist = hist;
function [ret_data, ret_sched_RBs, ret_sched_bytes] = schedule_rr(current_time, num_RB, ux, ~)
% users: {buffer_sizes, mcs}
ret_data = 0;
ret_sched_bytes(1:num_RB) = 0;
ret_sched_RBs(1:num_RB) = 0;
num_users = length(ux);
if num_users == 0
return
end
[~,idxs] = sort([ux(:).buffer_size], 'descend');
ux = ux(idxs);
ui = 1;
for i=1:num_RB
startui = ui;
while (ux(ui).buffer_size == 0) % skip users without data
ui = mod(ui, num_users) + 1;
if (startui == ui)
return % no user has any data anymore, exit
end
end
% schedule one RB or remaining buffer of user
bytes = min(convert_RBs_to_bytes(ux(ui).mcs, 1), ux(ui).buffer_size);
ux(ui).buffer_size -= bytes;
ret_sched_bytes(i) = bytes;
ret_sched_RBs(i) = ux(ui).id;
ui = mod(ui, num_users) + 1;
end
## Copyright (C) 2013 Erik Kjellson <erikiiofph7@users.sourceforge.net>
##
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation; either version 3 of the License, or (at your option) any later
## version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program; if not, see <http://www.gnu.org/licenses/>.
## -*- texinfo -*-
## @deftypefn {Function File} {@var{yy} =} smooth (@var{y})
## @deftypefnx {Function File} {@var{yy} =} smooth (@var{y}, @var{span})
## @deftypefnx {Function File} {@var{yy} =} smooth (@var{y}, @var{method})
## @deftypefnx {Function File} {@var{yy} =} smooth (@var{y}, @var{span}, @var{method})
## @deftypefnx {Function File} {@var{yy} =} smooth (@var{y}, "sgolay", @var{degree})
## @deftypefnx {Function File} {@var{yy} =} smooth (@var{y}, @var{span}, 'sgolay', @var{degree})
## @deftypefnx {Function File} {@var{yy} =} smooth (@var{x}, @var{y}, ...)
##
## This is an implementation of the functionality of the @code{smooth} function in
## Matlab's Curve Fitting Toolbox.
##
## Smooths the @var{y} data with the chosen method, see the table below for available
## methods.
##
## The @var{x} data does not need to have uniform spacing.
##
## For the methods "moving" and "sgolay" the @var{span} parameter defines how many data
## points to use for the smoothing of each data point. Default is 5, i.e. the
## center point and two neighbours on each side.
##
## Smoothing methods specified by @var{method}:
##
## @table @asis
## @item "moving"
## Moving average (default). For each data point, the average value of the span
## is used. Corresponds to lowpass filtering.
##
## @item "sgolay"
## Savitzky-Golay filter. For each data point a polynomial of degree @var{degree}
## is fitted (using a least-square regression) to the span and evaluated for the
## current @var{x} value. Also known as digital smoothing polynomial filter or
## least-squares smoothing filter. Default value of @var{degree} is 2.
##
## @item "lowess"
##
## @item "loess"
##
## @item "rlowess"
##
## @item "rloess"
##
## @end table
##
## Documentation of the Matlab smooth function:
## @url{http://www.mathworks.se/help/curvefit/smooth.html}
## @url{http://www.mathworks.se/help/curvefit/smoothing-data.html}
##
## @end deftypefn
function yy = smooth (varargin)
## Default values
span = 5;
method = 'moving';
degree = 2; ## for sgolay method
## Keep track of the order of the arguments
argidx_x = -1;
argidx_y = -1;
argidx_span = -1;
argidx_method = -1;
argidx_degree = -1;
## Check input arguments
if (nargin < 1)
print_usage ();
else
## 1 or more arguments
if (!isnumeric (varargin{1}))
error ('smooth: first argument must be a vector')
endif
if (nargin < 2)
## first argument is y
argidx_y = 1;
y = varargin{1};
else
## 2 or more arguments
if ((isnumeric (varargin{2})) && (length (varargin{2}) > 1))
## both x and y are provided
argidx_x = 1;
argidx_y = 2;
x = varargin{1};
y = varargin{2};
if (length (x) != length (y))
error ('smooth: x and y vectors must have the same length')
endif
else
## Only y provided, create an evenly spaced x vector
argidx_y = 1;
y = varargin{1};
x = 1:length (y);
if ((isnumeric (varargin{2})) && (length (varargin{2}) == 1))
## 2nd argument is span
argidx_span = 2;
span = varargin{2};
elseif (ischar (varargin{2}))
## 2nd argument is method
argidx_method = 2;
method = varargin{2};
else
error ('smooth: 2nd argument is of unexpected type')
endif
endif
if (nargin > 2)
if ((argidx_y == 2) && (isnumeric (varargin{3})))
## 3rd argument is span
argidx_span = 3;
span = varargin{3};
if (length (span) > 1)
error ('smooth: 3rd argument can''t be a vector')
endif
elseif (ischar (varargin{3}))
## 3rd argument is method
argidx_method = 3;
method = varargin{3};
elseif (strcmp (varargin{2}, 'sgolay') && (isnumeric (varargin{3})))
## 3rd argument is degree
argidx_degree = 3;
degree = varargin{3};
if (length (degree) > 1)
error ('smooth: 3rd argument is of unexpected type')
endif
else
error ('smooth: 3rd argument is of unexpected type')
endif
if (nargin > 3)
if (argidx_span == 3)
## 4th argument is method
argidx_mehod = 4;
method = varargin{4};
if (!ischar (method))
error ('smooth: 4th argument is of unexpected type')
endif
elseif (strcmp (varargin{3}, 'sgolay'))
## 4th argument is degree
argidx_degree = 4;
degree = varargin{4};
if ((!isnumeric (degree)) || (length (degree) > 1))
error ('smooth: 4th argument is of unexpected type')
endif
else
error ('smooth: based on the first 3 arguments, a 4th wasn''t expected')
endif
if (nargin > 4)
if (strcmp (varargin{4}, 'sgolay'))
## 5th argument is degree
argidx_degree = 5;
degree = varargin{5};
if ((!isnumeric (degree)) || (length (degree) > 1))
error ('smooth: 5th argument is of unexpected type')
endif
else
error ('smooth: based on the first 4 arguments, a 5th wasn''t expected')
endif
if (nargin > 5)
error ('smooth: too many input arguments')
endif
endif
endif
endif
endif
endif
## Perform smoothing
if (span > length (y))
error ('smooth: span cannot be greater than ''length (y)''.')
endif
yy = [];
switch method
## --- Moving average
case 'moving'
for i=1:length (y)
if (mod (span,2) == 0)
error ('smooth: span must be odd.')
endif
if (i <= (span-1)/2)
## We're in the beginning of the vector, use as many y values as
## possible and still having the index i in the center.
## Use 2*i-1 as the span.
idx1 = 1;
idx2 = 2*i-1;
elseif (i <= length (y) - (span-1)/2)
## We're somewhere in the middle of the vector.
## Use full span.
idx1 = i-(span-1)/2;
idx2 = i+(span-1)/2;
else
## We're near the end of the vector, reduce span.
## Use 2*(length (y) - i) + 1 as span
idx1 = i - (length (y) - i);
idx2 = i + (length (y) - i);
endif
yy(i) = mean (y(idx1:idx2));
endfor
## --- Savitzky-Golay filtering
case 'sgolay'
## FIXME: Check how Matlab takes care of the beginning and the end. Reduce polynomial degree?
for i=1:length (y)
if (mod (span,2) == 0)
error ('smooth: span must be odd.')
endif
if (i <= (span-1)/2)
## We're in the beginning of the vector, use as many y values as
## possible and still having the index i in the center.
## Use 2*i-1 as the span.
idx1 = 1;
idx2 = 2*i-1;
elseif (i <= length (y) - (span-1)/2)
## We're somewhere in the middle of the vector.
## Use full span.
idx1 = i-(span-1)/2;
idx2 = i+(span-1)/2;
else
## We're near the end of the vector, reduce span.
## Use 2*(length (y) - i) + 1 as span
idx1 = i - (length (y) - i);
idx2 = i + (length (y) - i);
endif
## Fit a polynomial to the span using least-square method.
p = polyfit(x(idx1:idx2), y(idx1:idx2), degree);
## Evaluate the polynomial in the center of the span.
yy(i) = polyval(p,x(i));
endfor
## ---
case 'lowess'
## FIXME: implement smoothing method 'lowess'
error ('smooth: method ''lowess'' not implemented yet')
## ---
case 'loess'
## FIXME: implement smoothing method 'loess'
error ('smooth: method ''loess'' not implemented yet')
## ---
case 'rlowess'
## FIXME: implement smoothing method 'rlowess'
error ('smooth: method ''rlowess'' not implemented yet')
## ---
case 'rloess'
## FIXME: implement smoothing method 'rloess'
error ('smooth: method ''rloess'' not implemented yet')
## ---
otherwise
error ('smooth: unknown method')
endswitch
endfunction
########################################
%!test
%! ## 5 y values (same as default span)
%! y = [42 7 34 5 9];
%! yy2 = y;
%! yy2(2) = (y(1) + y(2) + y(3))/3;
%! yy2(3) = (y(1) + y(2) + y(3) + y(4) + y(5))/5;
%! yy2(4) = (y(3) + y(4) + y(5))/3;
%! yy = smooth (y);
%! assert (yy, yy2);
%!test
%! ## x vector provided
%! x = 1:5;
%! y = [42 7 34 5 9];
%! yy2 = y;
%! yy2(2) = (y(1) + y(2) + y(3))/3;
%! yy2(3) = (y(1) + y(2) + y(3) + y(4) + y(5))/5;
%! yy2(4) = (y(3) + y(4) + y(5))/3;
%! yy = smooth (x, y);
%! assert (yy, yy2);
%!test
%! ## span provided
%! y = [42 7 34 5 9];
%! yy2 = y;
%! yy2(2) = (y(1) + y(2) + y(3))/3;
%! yy2(3) = (y(2) + y(3) + y(4))/3;
%! yy2(4) = (y(3) + y(4) + y(5))/3;
%! yy = smooth (y, 3);
%! assert (yy, yy2);
%!test
%! ## x vector & span provided
%! x = 1:5;
%! y = [42 7 34 5 9];
%! yy2 = y;
%! yy2(2) = (y(1) + y(2) + y(3))/3;
%! yy2(3) = (y(2) + y(3) + y(4))/3;
%! yy2(4) = (y(3) + y(4) + y(5))/3;
%! yy = smooth (x, y, 3);
%! assert (yy, yy2);
%!test
%! ## method 'moving' provided
%! y = [42 7 34 5 9];
%! yy2 = y;
%! yy2(2) = (y(1) + y(2) + y(3))/3;
%! yy2(3) = (y(1) + y(2) + y(3) + y(4) + y(5))/5;
%! yy2(4) = (y(3) + y(4) + y(5))/3;
%! yy = smooth (y, 'moving');
%! assert (yy, yy2);
%!test
%! ## x vector & method 'moving' provided
%! x = 1:5;
%! y = [42 7 34 5 9];
%! yy2 = y;
%! yy2(2) = (y(1) + y(2) + y(3))/3;
%! yy2(3) = (y(1) + y(2) + y(3) + y(4) + y(5))/5;
%! yy2(4) = (y(3) + y(4) + y(5))/3;
%! yy = smooth (x, y, 'moving');
%! assert (yy, yy2);
%!test
%! ## span & method 'moving' provided
%! y = [42 7 34 5 9];
%! yy2 = y;
%! yy2(2) = (y(1) + y(2) + y(3))/3;
%! yy2(3) = (y(2) + y(3) + y(4))/3;
%! yy2(4) = (y(3) + y(4) + y(5))/3;
%! yy = smooth (y, 3, 'moving');
%! assert (yy, yy2);
%!test
%! ## x vector, span & method 'moving' provided
%! x = 1:5;
%! y = [42 7 34 5 9];
%! yy2 = y;
%! yy2(2) = (y(1) + y(2) + y(3))/3;
%! yy2(3) = (y(2) + y(3) + y(4))/3;
%! yy2(4) = (y(3) + y(4) + y(5))/3;
%! yy = smooth (x, y, 3, 'moving');
%! assert (yy, yy2);
########################################
%!demo
%! ## Moving average & Savitzky-Golay
%! x = linspace (0, 4*pi, 150);
%! y = sin (x) + 1*(rand (1, length (x)) - 0.5);
%! y_ma = smooth (y, 21, 'moving');
%! y_sg = smooth (y, 21, 'sgolay', 2);
%! y_sg2 = smooth (y, 51, 'sgolay', 2);
%! figure
%! plot (x,y, x,y_ma, x,y_sg, x,y_sg2)
%! legend('Original', 'Moving Average (span 21)', 'Savitzky-Golay (span 21, degree 2)', 'Savitzky-Golay (span 51, degree 2)')
function z = spread(a, b)
assert(length(a) == sum(b));
z(1:length(b)) = 0;
ai = 1;
for i = 1:length(b)
if b(i) == 1
z(i) = a(ai);
ai += 1;
end
end
addpath("..");
num_frames = 10;
num_RBs = 15;
slices = {"schedule_rr"};
slice_strat = SliceStrategy.Static;
static_weights = [1];
slice_parameters = struct("strategy", slice_strat, "parameters", static_weights);
user_slice_mask = [1];
num_users = length(user_slice_mask);
slice_max_packet_delay = [1];
user_packet_size_funcs{1} = @() (1080);
user_idt_funcs{1} = @(time) (time + 1);
clear mcs
mcs(1:num_users,1:num_frames*10) = 0;
mcs( 1,1:num_frames*10) = 28;
[ux, sx] = usf(num_RBs,
num_frames,
slice_parameters,
slices,
user_slice_mask,
mcs,
slice_max_packet_delay,
user_packet_size_funcs,
user_idt_funcs,
false);
assert(ux(1).lost_packets == 0);
assert(ux(1).lost_bytes == 0);
user_packet_size_funcs{1} = @() (1081);
[ux, sx] = usf(num_RBs,
num_frames,
slice_parameters,
slices,
user_slice_mask,
mcs,
slice_max_packet_delay,
user_packet_size_funcs,
user_idt_funcs,
false);
assert(ux(1).lost_packets == 99);
assert(ux(1).lost_bytes == 99);
addpath("..");
num_frames = 50;
num_RBs = 25;
slices = {"schedule_rr", "schedule_delay"};
%slice_strat = SliceStrategy.NVS;
% normalize reserved/minimum to every TTI (i.e. val*1000 is bps)
%nvs_parameters(1) = struct("type", SliceType.Dynamic, "reserved", 2000, "reference", 12000);
%nvs_parameters(2) = struct("type", SliceType.Dynamic, "reserved", 3000, "reference", 12000);
% SliceType.vRB, 0.3*num_RBs*num_frames*10 = 1500 (should get 30% of all RBs)
%nvs_parameters(3) = struct("type", SliceType.vRB, "reserved", 0.3, "reference", 0);
%nvs_parameters(4) = struct("type", SliceType.vRB, "reserved", 0.2, "reference", 0);
%slice_parameters = struct("strategy", slice_strat, "parameters", nvs_parameters);
slice_strat = SliceStrategy.Concurrent;
conc_parameters(1) = struct("type", SliceType.Dynamic, "reserved", 8000, "option",
struct("reference", 12000));
conc_parameters(2) = struct("type", SliceType.OnDemand, "reserved", 200, "option",
struct("tmax", 1/6,
"logdelta", -log10(1e-3),
"tau", 3,
"delay", 0));
slice_parameters = struct("strategy", slice_strat, "parameters", conc_parameters);
user_slice_mask = [1 1 1 1 1 1 2]; %first two users are in slice 1, the other two in slice 2
num_users = length(user_slice_mask);
% packet delay budget for each Network Slice based on their QCI in LTE (70% of
% the time can be spent in buffer queue)
slice_max_packet_delay = [50 10]*0.7;
% bitrate for user: avg*8/IDT kbps per user!!
user_packet_size_funcs{1} = @() (2000);
user_idt_funcs{1} = @(time) (time + 1);
user_packet_size_funcs{2} = @() (2000);
user_idt_funcs{2} = @(time) (time + 1);
user_packet_size_funcs{3} = @() (2000);
user_idt_funcs{3} = @(time) (time + 1);
user_packet_size_funcs{4} = @() (2000);
user_idt_funcs{4} = @(time) (time + 1);
user_packet_size_funcs{5} = @() (2000);
user_idt_funcs{5} = @(time) (time + 1);
user_packet_size_funcs{6} = @() (2000);
user_idt_funcs{6} = @(time) (time + 1);
user_packet_size_funcs{7} = @() (1354);
user_idt_funcs{7} = @(time) (time + 10);
clear CQI
CQI(1:num_users,1:num_frames*10) = 0;
CQI( 1,1:num_frames*10) = 28;
CQI( 2,1:num_frames*10) = 28;
CQI( 3,1:num_frames*10) = 28;
CQI( 4,1:num_frames*10) = 28;
CQI( 5,1:num_frames*10) = 28;
CQI( 6,1:num_frames*10) = 28;
CQI( 7,1:num_frames*10) = 16;
%CQI( 8,1:num_frames*10) = 28;
%CQI( 9,1:num_frames*10) = 28;
%CQI(10,1:num_frames*10) = 6;
%CQI(11,1:num_frames*10) = 6;
%CQI(12,1:num_frames*10) = 6;
usf(num_RBs,
num_frames,
slice_parameters,
slices,
user_slice_mask,
CQI,
slice_max_packet_delay,
user_packet_size_funcs,
user_idt_funcs,
true); % graphs?
addpath("..");
num_frames = 100;
num_RBs = 25;
slices = {"schedule_rr", "schedule_rr", "schedule_rr", "schedule_rr"};
slice_strat = SliceStrategy.NVS;
% normalize reserved/minimum to every TTI (i.e. val*1000 is bps)
nvs_parameters(1) = struct("type", SliceType.Rate, "reserved", 2000, "reference", 12000);
nvs_parameters(2) = struct("type", SliceType.Rate, "reserved", 3000, "reference", 12000);
% SliceType.vRB, 0.3*num_RBs*num_frames*10 = 1500 (should get 30% of all RBs)
nvs_parameters(3) = struct("type", SliceType.vRB, "reserved", 0.3, "reference", 0);
nvs_parameters(4) = struct("type", SliceType.vRB, "reserved", 0.2, "reference", 0);
slice_parameters = struct("strategy", slice_strat, "parameters", nvs_parameters);
user_slice_mask = [1 1 1 2 2 2 3 3 3 4 4 4]; %first two users are in slice 1, the other two in slice 2
num_users = length(user_slice_mask);
% packet delay budget for each Network Slice based on their QCI in LTE (70% of
% the time can be spent in buffer queue)
slice_max_packet_delay = [50,50,50,50]*0.7;
% bitrate for user: avg*8/IDT kbps per user!!
for i = 1:num_users
% bitrate for user: avg*8/IDT kbps per user!!
user_packet_size_funcs{i} = @() (6000);
user_idt_funcs{i} = @(time) (time + 1);
end
clear CQI
CQI(1:num_users,1:num_frames*10) = 0;
CQI( 1,1:num_frames*10) = 2;
CQI( 2,1:num_frames*10) = 2;
CQI( 3,1:num_frames*10) = 2;
CQI( 4,1:num_frames*10) = 26;
CQI( 5,1:num_frames*10) = 28;
CQI( 6,1:num_frames*10) = 28;
CQI( 7,1:num_frames*10) = 28;
CQI( 8,1:num_frames*10) = 28;
CQI( 9,1:num_frames*10) = 28;
CQI(10,1:num_frames*10) = 6;
CQI(11,1:num_frames*10) = 6;
CQI(12,1:num_frames*10) = 6;
usf(num_RBs,
num_frames,
slice_parameters,
slices,
user_slice_mask,
CQI,
slice_max_packet_delay,
user_packet_size_funcs,
user_idt_funcs,
false); % graphs?
addpath("..");
num_frames = 100;
num_RBs = 25; % maximum of 14.4Mpbs
slices = {"schedule_rr"};
slice_parameters = struct("strategy", SliceStrategy.Static, "parameters", [1]);
user_slice_mask = [1 1 1]; %first two users are in slice 1, the other two in slice 2
num_users = length(user_slice_mask);
slice_max_packet_delay = [50];
for i = 1:num_users
% bitrate for user: avg*8/IDT kbps per user!!
user_packet_size_funcs{i} = @() (600);
user_idt_funcs{i} = @(time) (time + 1);
end
clear CQI
CQI(1:num_users,1:num_frames*10) = 28;
for f = 1 : num_frames*10
CQI( 1,f) = randi([12 28]);
CQI( 2,f) = randi([12 28]);
CQI( 3,f) = randi([12 28]);
end
[ux, ~] = usf(num_RBs,
num_frames,
slice_parameters,
slices,
user_slice_mask,
CQI,
slice_max_packet_delay,
user_packet_size_funcs,
user_idt_funcs,
false); % graphs?
addpath('mcs');
thrpt(1:6,1:29) = 0;
i=1;
for rb = [6,15,25,50,75,100]
for cqi = 0:28
thrpt(i,cqi+1) = convert_RBs_to_bytes(cqi, rb) * 8 / 1000;
end
i += 1;
end
r = 1:29;
plot (r, thrpt(1,r), r, thrpt(2,r), r, thrpt(3,r), r, thrpt(4,r), r, thrpt(5,r), r, thrpt(6,r))
legend("6 RBs", "15 RBs", "25 RBs", "50 RBs", "75 RBs", "100 RBs", "location", "northwest");
title("bits per subframe over CQI for different bandwidths");
function [ux, sx, RB_slice_alloc_save] = usf(
num_RBs, num_frames, slice_conf, slices, user_slice_mask, mcs,
slice_max_delay, user_packet_size_funcs, user_idt_funcs, graphs)
addpath("schedulers", "mcs");
num_users = length(user_slice_mask);
num_slices = length(slices);
assert(num_slices == length(slice_max_delay));
assert(num_users == length(user_packet_size_funcs));
assert(num_users == length(user_idt_funcs));
assert(size(mcs) == [num_users, num_frames*10]);
check_slice_assoc = 0;
for s = 1:num_slices
check_slice_assoc += sum(user_slice_mask == s);
end
assert(check_slice_assoc == num_users, "user_slice_mask defines more slices than slices configured");
assert(num_slices == length(slice_conf.parameters));
switch slice_conf.strategy
case SliceStrategy.Static
assert(sum(slice_conf.parameters) <= 1, "cannot give >1 of resources");
num_RB_slice_alloc = floor(slice_conf.parameters * num_RBs);
static_RB_slice_alloc = [];
for k = 1:length(slices)
static_RB_slice_alloc = [static_RB_slice_alloc (ones(1,num_RB_slice_alloc(k))*k)];
end
static_RB_slice_alloc = [static_RB_slice_alloc zeros(1, num_RBs-length(static_RB_slice_alloc))];
case SliceStrategy.NVS
nvs_sum_requested = 0; % NVS paper, eq. (5)
for p = 1:length(slice_conf.parameters)
if slice_conf.parameters(p).type == SliceType.Rate
assert(slice_conf.parameters(p).reserved <= slice_conf.parameters(p).reference);
nvs_sum_requested += slice_conf.parameters(p).reserved / slice_conf.parameters(p).reference;
elseif slice_conf.parameters(p).type == SliceType.vRB
nvs_sum_requested += slice_conf.parameters(p).reserved;
else
assert(0);
end
end
assert(nvs_sum_requested <= 1);
case SliceStrategy.Concurrent
concurrent_adm(num_RBs, slice_conf.parameters);
end
current_time = 0;
clear ux
ux(1:num_users) = struct(
'id', 0,
'IDT_func', 0,
'packet_size_func', 0,
'latency', 0,
'packet_queue', [], %struct('size', x, 'arrival', y)
'next_packet', 0,
'buffer_size', 0, % helper for schedulers, is sum of packet_queue packet's sizes
'mcs', 0,
'sched_bytes', 0,
'lost_bytes', 0,
'lost_packets', 0,
'thrpt', [],
'packet_delay', [],
'packet_delay_delivered', []);
%subscription_type(1:num_users) = 0;
%GBR(1:num_users) = 0;
for u=1:num_users
ux(u).id = u;
k = user_slice_mask(u);
ux(u).IDT_func = user_idt_funcs{u};
ux(u).packet_size_func = user_packet_size_funcs{u};
ux(u).latency = slice_max_delay(k);
%ux(u).packet_queue(end + 1) = struct('size', ux(u).packet_size_func(),
% 'arrival', 0);
ux(u).next_packet = ux(u).IDT_func(0);
end
clear sx
sx(1:num_slices) = struct(
'id', 0,
'func', 0,
'thrpt', [],
'alloc_RBs', [],
'active', true,
'delay', 0,
'rate', 0,
'slice_sched_data', 0);
for k=1:num_slices
sx(k).id = num2str(k);
sx(k).func = char(slices(k));
end
RB_slice_alloc_save(1:num_frames*10, num_RBs) = 0;
for f=1:num_frames
printf("%.2f%%\r", f/num_frames*100);
fflush(stdout);
for s=1:10
current_time = (s-1) + 10*(f-1);
for u=1:num_users
ux(u).mcs = mcs(u, current_time+1);
% removing the packets with queuing time more than latency constraint
if length(ux(u).packet_queue) > 0
remaining = ux(u).packet_queue(1).arrival + ux(u).latency - current_time;
while length(ux(u).packet_queue) > 0 && remaining <= 0
%disp([num2str(current_time) ': drop packet of user ' num2str(u) ' queue']);
ux(u).lost_bytes += ux(u).packet_queue(1).size;
ux(u).lost_packets += 1;
ux(u).packet_queue(1) = [];
if length(ux(u).packet_queue) > 0 % other packets remain in the queue
remaining = ux(u).packet_queue(1).arrival + ux(u).latency - current_time;
end
end
end
% adding the packets based on IDT for every network slice of a user
while current_time >= ux(u).next_packet
%disp([num2str(current_time) ': add packet to user ' num2str(u) ' queue']);
ux(u).packet_queue(end + 1) = struct('size', ux(u).packet_size_func(),
'arrival', ux(u).next_packet);
ux(u).next_packet = ux(u).IDT_func(current_time);
sx(user_slice_mask(u)).active = true;
end
if length(ux(u).packet_queue) > 0
ux(u).buffer_size = sum([[ux(u).packet_queue].size]);
else
ux(u).buffer_size = 0;
end
end
% inter-slice scheduling sets RBs for slices
% static:
switch slice_conf.strategy
case SliceStrategy.Static
RB_slice_alloc = static_RB_slice_alloc;
case SliceStrategy.NVS
RB_slice_alloc = nvs(current_time, num_RBs, slice_conf.parameters, sx);
case SliceStrategy.Concurrent
% let delay schedulers update their D parameter
for k = 1:num_slices
if slice_conf.parameters(k).type != SliceType.OnDemand
continue
end
su = find(user_slice_mask == k);
sf = str2func(sx(k).func);
[sx(k).slice_sched_data, ~, ~, sx(k).delay, sx(k).rate] = sf(current_time, 0, ux(su), sx(k).slice_sched_data);
end
RB_slice_alloc = concurrent(current_time, num_RBs, slice_conf.parameters, sx);
end
assert(num_RBs == length(RB_slice_alloc));
% run every slice independently
sched_RBs = zeros(1, num_RBs);
sched_bytes = zeros(1, num_RBs);
for k=1:num_slices
alloc_mask = RB_slice_alloc == k;
alloc_num_RB = sum(alloc_mask);
sx(k).thrpt = [sx(k).thrpt 0];
sx(k).alloc_RBs = [sx(k).alloc_RBs alloc_num_RB];
if (alloc_num_RB == 0)
continue
end
su = find(user_slice_mask == k); % users in slice k
sf = str2func(sx(k).func);
[sx(k).slice_sched_data, a, b] = sf(current_time, alloc_num_RB, ux(su), sx(k).slice_sched_data);
% since the allocation masks is orthogonal, we can directly add spreaded
% a, b on sched_RBs, sched_bytes
assert(length(a) == alloc_num_RB);
assert(length(b) == alloc_num_RB);
if sum(a>0) == 0 % nothing is scheduled
sx(k).active = false;
end
sched_RBs += spread(a, alloc_mask);
sched_bytes += spread(b, alloc_mask);
end
for u = 1:num_users
ux(u).thrpt(end+1) = 0;
end
% update user's data queue after scheduling
for j=1:length(sched_RBs)
u = sched_RBs(j);
if (u == 0) % no user scheduled
continue
end
k = user_slice_mask(u);
assert(length(ux(u).packet_queue) > 0);
sx(k).thrpt(end) += sched_bytes(j) * 8;
ux(u).thrpt(end) += sched_bytes(j) * 8;
ux(u).sched_bytes += sched_bytes(j);
diffsize = ux(u).packet_queue(1).size - sched_bytes(j);
% three cases: first_pdu and scheduled bytes exactly the same size:
% drop first, check next
if (diffsize == 0)
ux(u).packet_delay(end+1) = current_time-ux(u).packet_queue(1).arrival;
ux(u).packet_delay_delivered(end+1) = current_time;
ux(u).packet_queue(1) = [];
%disp([num2str(current_time) ': packet of user ' num2str(u) ' completely scheduled']);
% first_pdu smaller: there should be next (assert!)
elseif (diffsize < 0)
assert(length(ux(u).packet_queue) > 0, "not enough PDUs");
ux(u).packet_delay(end+1) = current_time - ux(u).packet_queue(1).arrival;
ux(u).packet_delay_delivered(end+1) = current_time;
ux(u).packet_queue(1) = [];
ux(u).packet_queue(1).size += diffsize; % diffsize is negative!
%disp([num2str(current_time) ': packet of user ' num2str(u) ' scheduled: next packet for ' num2str(-diffsize) 'B']);
else % first_pdu larger
ux(u).packet_queue(1).size -= sched_bytes(j);
%disp([num2str(current_time) ': packet of user ' num2str(u) ' scheduled for ' num2str(sched_bytes(j)) 'B']);
end
ux(u).buffer_size = sum([[ux(u).packet_queue].size]);
end
RB_slice_alloc_save(current_time+1,:) = RB_slice_alloc;
end
end
d = num_frames * 10;
total_num_RBs = num_RBs * d;
for k = 1:length(sx)
avg_thr_kbps(k) = sum(sx(k).thrpt) / d;
total_alloc_RBs(k) = sum(sx(k).alloc_RBs);
disp(["slice " num2str(k) " (" sx(k).func "): avg thrpt " num2str(avg_thr_kbps(k) / 1000) "Mbps, totalRBs " num2str(total_alloc_RBs(k)) " from " num2str(total_num_RBs) " (" num2str(total_alloc_RBs(k) / total_num_RBs * 100) "%)"]);
for u = find(user_slice_mask == k) % all users in this slice
disp([' user ' num2str(u) ' thrpt ' num2str(ux(u).sched_bytes * 8 / d / 1000) 'Mbps lost_bytes ' num2str(ux(u).lost_bytes) 'B packets ' num2str(ux(u).lost_packets) ' (total lost packet size might be higher)']);
end
end
if slice_conf.strategy == SliceStrategy.NVS
nvs_res_used(1:length(sx)) = 0;
for k = 1:length(sx)
if slice_conf.parameters(k).type == SliceType.Rate
nvs_res_used(k) += avg_thr_kbps(k) / slice_conf.parameters(k).reference;
elseif slice_conf.parameters(k).type == SliceType.vRB
nvs_res_used(k) += total_alloc_RBs(k) / total_num_RBs;
else
assert(0, ["Illegal parameter type" num2str(slice_conf.parameters(k).type)]);
end
end
disp(["NVS used resources: " num2str(nvs_res_used) ", sum " num2str(sum(nvs_res_used))]);
end
if graphs
cc = "brkgmc";
% throughput per slice plot
figure
for k=1:length(sx)
hold on
plot (1:length(sx(k).thrpt), smooth(sx(k).thrpt,201), "color", cc(k))
end
ylim([0 inf]);
leg = legend(num2str([char(sx(1:length(sx)).id)]));
set(leg, "interpreter", "none");
title('throughput for slices in b/subframe')
% RB allocation per slice plot
figure
for k = 1:num_slices
x = [];
y = [];
s1 = RB_slice_alloc_save == k;
for i = 1:num_frames*10
for j = 1:num_RBs
if s1(i,j) == 1
x = [x, i];
y = [y, j];
end
end
end
hold on
scatter(x,y,5,cc(k),"filled");
end
ylim([0 num_RBs]);
leg = legend(num2str([char(sx(1:length(sx)).id)]));
set(leg, "interpreter", "none");
title('RB allocation for slices per subframe')
end
%disp(["delay slice 1: " num2str(delay_slice1)])
%disp(["delay slice 2: " num2str(delay_slice2)])
num_frames = 50;
num_RBs = 25;
slices = {"schedule_rr", "schedule_rr"};
%slice_strat = SliceStrategy.Static;
%static_weights = [0.5 0.5]; % for static slicing, should match number of slices
%slice_parameters = struct("strategy", slice_strat, "parameters", static_weights);
slice_strat = SliceStrategy.NVS;
% SliceType.Rate, normalize reserved/minimum to every TTI (i.e. val*1000 is bps)
% (should get around 4Mbps if CQI is high enough, otherwise scaled down)
nvs_parameters(1) = struct("type", 1, "reserved", 3000, "minimum", 3000);
% SliceType.vRB, 0.3*num_RBs*num_frames*10 = 1500 (should get 30% of all RBs)
nvs_parameters(2) = struct("type", 2, "reserved", 0.3, "minimum", 0);
slice_parameters = struct("strategy", slice_strat, "parameters", nvs_parameters);
user_slice_mask = [1 1 2 2]; %first two users are in slice 1, the other two in slice 2
num_users = length(user_slice_mask);
% packet delay budget for each Network Slice based on their QCI in LTE (70% of
% the time can be spent in buffer queue)
slice_max_packet_delay = [50,50]*0.7;
%slice_GBR_basic = [64,354,384]; % in Kbps
%slice_GBR_silver = [64,1500,384]*5; % in Kbps
%slice_GBR_gold = [64,1500,384]*10; % in Kbps
% bitrate for user: avg*8/IDT kbps per user!!
for i = 1:num_users
% bitrate for user: avg*8/IDT kbps per user!!
user_packet_size_funcs{i} = @() (500);
user_idt_funcs{i} = @(time) (time + 1);
end
clear CQI
CQI(1:num_users,1:num_frames*10) = 0;
traffic(1:num_users) = 0;
%subscription(1:max_num_of_active_users,1:num_slices) = 0;
CQI( 1,1:num_frames*10) = 26;
CQI( 2,1:num_frames*10) = 26;
CQI( 3,1:num_frames*10) = 26;
CQI( 4,1:num_frames*10) = 26;
% 1: continuous traffic for all
% 2: random traffic
% 3: Office Hours in a commercial place
% 4: Evening hours in residential area
traffic_condition = 1;
for i=1:num_users
switch traffic_condition
case 1 % continouos traffic
traffic(i) = 1;
case 2 % random traffic
traffic(i) = rand(1,1);
case 3 % office hours in commercial place
traffic(i_rand(i)) = rand_traffic_office(k, i, num_users);
case 4 % evening hours in residential place
traffic(i_rand(i)) = rand_traffic_residential(k, i, num_users);
end
% Randomly generating susbscriptions plans for users for every
% service
subscription(i) = randi([1,1]);
end
usf(num_RBs,
num_frames,
slice_parameters,
slices,
user_slice_mask,
CQI,
slice_max_packet_delay,
user_packet_size_funcs,
user_idt_funcs,
false); % graphs?
......@@ -701,44 +701,44 @@ void static_destroy(slice_info_t **si) {
free(*si);
}
pp_impl_param_t static_dl_init(module_id_t mod_id, int CC_id) {
slice_info_t *si = calloc(1, sizeof(slice_info_t));
DevAssert(si);
// pp_impl_param_t static_dl_init(module_id_t mod_id, int CC_id) {
// slice_info_t *si = calloc(1, sizeof(slice_info_t));
// DevAssert(si);
si->num = 0;
si->s = calloc(MAX_STATIC_SLICES, sizeof(slice_t));
DevAssert(si->s);
for (int i = 0; i < MAX_MOBILES_PER_ENB; ++i)
si->UE_assoc_slice[i] = -1;
// si->num = 0;
// si->s = calloc(MAX_STATIC_SLICES, sizeof(slice_t));
// DevAssert(si->s);
// for (int i = 0; i < MAX_MOBILES_PER_ENB; ++i)
// si->UE_assoc_slice[i] = -1;
/* insert default slice, all resources */
scn19_slice_param_t *dlp = malloc(sizeof(scn19_slice_param_t));
dlp->type="static";
dlp->typeid=1;
dlp->posLow = 0;
dlp->posHigh = to_rbg(RC.mac[mod_id]->common_channels[CC_id].mib->message.dl_Bandwidth) - 1;
default_sched_dl_algo_t *algo = &RC.mac[mod_id]->pre_processor_dl.dl_algo;
algo->data = NULL;
DevAssert(0 == addmod_static_slice_dl(si, 0, strdup("default"), algo, dlp));
const UE_list_t *UE_list = &RC.mac[mod_id]->UE_info.list;
for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id])
slicing_add_UE(si, UE_id);
// /* insert default slice, all resources */
// scn19_slice_param_t *dlp = malloc(sizeof(scn19_slice_param_t));
// dlp->type="static";
// dlp->typeid=1;
// dlp->posLow = 0;
// dlp->posHigh = to_rbg(RC.mac[mod_id]->common_channels[CC_id].mib->message.dl_Bandwidth) - 1;
// default_sched_dl_algo_t *algo = &RC.mac[mod_id]->pre_processor_dl.dl_algo;
// algo->data = NULL;
// DevAssert(0 == addmod_static_slice_dl(si, 0, strdup("default"), algo, dlp));
// const UE_list_t *UE_list = &RC.mac[mod_id]->UE_info.list;
// for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id])
// slicing_add_UE(si, UE_id);
pp_impl_param_t sttc;
sttc.algorithm = SCN19_SLICING;
sttc.add_UE = slicing_add_UE;
sttc.remove_UE = slicing_remove_UE;
sttc.move_UE = slicing_move_UE;
sttc.addmod_slice = addmod_static_slice_dl;
sttc.remove_slice = remove_static_slice_dl;
sttc.dl = static_dl;
// current DL algo becomes default scheduler
sttc.dl_algo = *algo;
sttc.destroy = static_destroy;
sttc.slices = si;
// pp_impl_param_t sttc;
// sttc.algorithm = SCN19_SLICING;
// sttc.add_UE = slicing_add_UE;
// sttc.remove_UE = slicing_remove_UE;
// sttc.move_UE = slicing_move_UE;
// sttc.addmod_slice = addmod_static_slice_dl;
// sttc.remove_slice = remove_static_slice_dl;
// sttc.dl = static_dl;
// // current DL algo becomes default scheduler
// sttc.dl_algo = *algo;
// sttc.destroy = static_destroy;
// sttc.slices = si;
return sttc;
}
// return sttc;
// }
pp_impl_param_t static_ul_init(module_id_t mod_id, int CC_id) {
slice_info_t *si = calloc(1, sizeof(slice_info_t));
......@@ -833,9 +833,6 @@ int addmod_scn19_slice_dl(slice_info_t *si,
char *label,
void *algo,
void *slice_params_dl) {
LOG_I(FLEXRAN_AGENT, "Begin addmod_static_slice_dl in Static Slicing Implementation\n");
scn19_slice_param_t *dl = slice_params_dl;
......@@ -1069,9 +1066,66 @@ if(dl->typeid==2){
return si->num - 1;
}
}
uint16_t get_slice_thrpt(module_id_t mod_id, UE_list_t *UE_list ){
uint16_t slice_thrpt=0;
for (int UE_id =UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) {
uint16_t thrpt=0;
int lcid=0;
for (lcid=NUM_MAX_SRB ; lcid < NUM_MAX_SRB + NUM_MAX_DRB; lcid++){
thrpt += flexran_get_pdcp_tx_bytes_w(mod_id, UE_id, lcid);
}
slice_thrpt += thrpt;
}
/* only calculate the DRBs */
return slice_thrpt;
}
#define randomss(x) (rand()%x)
int arr_max(const float arr[],int n,int con)
{
const float ESP= 10e-4;
int maxindex=0,count;
const float*p=arr;
for(count=1;count<n;count++)
{
if(*p<=arr[count])
{
// printf("%f \n",(arr[count]-*p));
if(arr[count]-*p>ESP){
//printf("%f \n",(arr[count]-*p));
p=&arr[count];
maxindex=count;
}
else{
/* 初始化随机数发生器 */
srand(count+con);
int swc = randomss(100);
//printf("%d \n",swc);
if(swc<=49){
p=&arr[count];
maxindex=count;
}
else{
continue;
}
}
}
}
return maxindex;
}
void scn19_dl(module_id_t mod_id,
int CC_id,
frame_t frame,
......@@ -1118,25 +1172,12 @@ void scn19_dl(module_id_t mod_id,
max_num_ue = 1;
break;
}
/** calculating the weight of ondemand and dynamic slices*/
float *aweight = (float *) malloc ( sizeof( float ) * s->num );
float *adweight = (float *) malloc ( sizeof( float ) * s->num );
/** calculating the weight of ondemand and dynamic slices*/
/**
* A. Based on the SLA of fixed slices, first allocate the dedicated requested
* resources.
......@@ -1147,19 +1188,29 @@ void scn19_dl(module_id_t mod_id,
// A. Based on the SLA of fixed slices, first allocate the dedicated requested resources
int static_n_rbg_sched = 0;
uint8_t static_rbgalloc_slice_mask[N_RBG_MAX];//1 -> allocate 0 -> none
memset(static_rbgalloc_slice_mask, 0, sizeof(static_rbgalloc_slice_mask));
for (int i = 0; i < s->num; ++i) {
aweight[i]=0;
scn19_slice_param_t *p = s->s[i]->algo_data;
if(p->typeid==1) {
aweight[i]=0;
if (s->s[i]->UEs.head < 0)
continue;
uint8_t rbgalloc_slice_mask[N_RBG_MAX];
memset(rbgalloc_slice_mask, 0, sizeof(rbgalloc_slice_mask));
scn19_slice_param_t *p = s->s[i]->algo_data;
if(p->typeid!=1) continue;
int n_rbg_sched = 0;
for (int rbg = p->posLow; rbg <= p->posHigh && rbg <= N_RBG; ++rbg) {
//LOG_I(FLEXRAN_AGENT, " slice id type %s posHigh %d posLow %d \n",p->type,s->s[i]->id,p->posHigh,p->posLow);
rbgalloc_slice_mask[rbg] = rbgalloc_mask[rbg];
static_rbgalloc_slice_mask[rbg] = 1;
n_rbg_sched += rbgalloc_mask[rbg];
static_n_rbg_sched += rbgalloc_mask[rbg];
}
s->s[i]->dl_algo.run(mod_id,
CC_id,
frame,
......@@ -1170,6 +1221,87 @@ void scn19_dl(module_id_t mod_id,
rbgalloc_slice_mask,
s->s[i]->dl_algo.data);
}
}
uint8_t srbgalloc_mask[N_RBG_MAX];
uint8_t remain_mask[N_RBG_MAX] ;//remains of static allocated
vrb_map = RC.mac[mod_id]->common_channels[CC_id].vrb_map;
memset(remain_mask, 0, sizeof(remain_mask));
int dynamic_n_rbg_sched=0;
for (int i = 0; i < N_RBG; i++) {
// calculate mask: init to one + "AND" with vrb_map:
// if any RB in vrb_map is blocked (1), the current RBG will be 0
srbgalloc_mask[i] = 1;
for (int j = 0; j < RBGsize; j++)
srbgalloc_mask[i] &= !vrb_map[RBGsize * i + j];
if(static_rbgalloc_slice_mask[i]==0){
remain_mask[i]=srbgalloc_mask[i];
}
}
for(int i=0;i<N_RBG_MAX;i++){
if(remain_mask[i]==1){
dynamic_n_rbg_sched+=remain_mask[i];
}
}
boolean_t dynamic_ues = false;
// B. Based on the SLA of dynamic slices, first allocate the dedicated requested resources
for (int i = 0; i < s->num; ++i) {
if (s->s[i]->UEs.head < 0)
continue;
scn19_slice_param_t *p = s->s[i]->algo_data;
if(p->typeid==2) {
dynamic_ues = true;
uint16_t inst = 0;
if(p->rbs > 0){//was scheduled last time
inst = get_slice_thrpt(mod_id,&s->s[i]->UEs)/8000;
p->eff=(1-BETA)*p->eff+BETA*inst/(p->rbs);
}
p->fexp=(1-BETA)*p->fexp+BETA*inst;
float_t rsv = p->kpsRequired* cmin(1,p->eff*RB_NUMS/p->kpsReference);
p->weight =1+ rsv / p->fexp;
aweight[i]=p->weight;
p->rbs=0;
}
}
int max_index = 0;
max_index = arr_max(aweight,s->num, subframe);
scn19_slice_param_t *p = s->s[max_index]->algo_data;
LOG_I(FLEXRAN_AGENT, " ---%.2f ---%.2f ---%.2f ---%.2f \n",aweight[0],aweight[1],aweight[2],aweight[3]);
if(p->typeid == 2 && dynamic_ues){
LOG_I(FLEXRAN_AGENT, "1254 %d static_n_rbg_sched %d dynamic_n_rbg_sched %.2f weight of slice %d \n",static_n_rbg_sched,dynamic_n_rbg_sched,aweight[max_index],max_index);
//LOG_I(FLEXRAN_AGENT, "1257 %d static_n_rbg_sched %d dynamic_n_rbg_sched \n",static_n_rbg_sched,dynamic_n_rbg_sched);
// LOG_I(FLEXRAN_AGENT, " %d static_n_rbg_sched %d dynamic_n_rbg_sched \n",static_n_rbg_sched,dynamic_n_rbg_sched);
if(dynamic_n_rbg_sched && s->s[max_index]->UEs.head >=0){
s->s[max_index]->dl_algo.run(mod_id,
CC_id,
frame,
subframe,
&s->s[max_index]->UEs,
max_num_ue, // max_num_ue
dynamic_n_rbg_sched,
remain_mask,
s->s[max_index]->dl_algo.data);
p->rbs = dynamic_n_rbg_sched;
}
}
free(aweight);
free(adweight);
// the following block is meant for validation of the pre-processor to check
// whether all UE allocations are non-overlapping and is not necessary for
......@@ -1216,6 +1348,46 @@ void scn19_dl(module_id_t mod_id,
}
pp_impl_param_t static_dl_init(module_id_t mod_id, int CC_id) {
slice_info_t *si = calloc(1, sizeof(slice_info_t));
DevAssert(si);
si->num = 0;
si->s = calloc(MAX_STATIC_SLICES, sizeof(slice_t));
DevAssert(si->s);
for (int i = 0; i < MAX_MOBILES_PER_ENB; ++i)
si->UE_assoc_slice[i] = -1;
/* insert default slice, all resources */
scn19_slice_param_t *dlp = malloc(sizeof(scn19_slice_param_t));
dlp->type="static";
dlp->typeid=1;
dlp->posLow = 0;
dlp->posHigh = to_rbg(RC.mac[mod_id]->common_channels[CC_id].mib->message.dl_Bandwidth) - 1;
default_sched_dl_algo_t *algo = &RC.mac[mod_id]->pre_processor_dl.dl_algo;
algo->data = NULL;
DevAssert(0 == addmod_static_slice_dl(si, 0, strdup("default"), algo, dlp));
const UE_list_t *UE_list = &RC.mac[mod_id]->UE_info.list;
for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id])
slicing_add_UE(si, UE_id);
pp_impl_param_t sttc;
sttc.algorithm = SCN19_SLICING;
sttc.add_UE = slicing_add_UE;
sttc.remove_UE = slicing_remove_UE;
sttc.move_UE = slicing_move_UE;
sttc.addmod_slice = addmod_static_slice_dl;
sttc.remove_slice = remove_static_slice_dl;
sttc.dl = scn19_dl;
// current DL algo becomes default scheduler
sttc.dl_algo = *algo;
sttc.destroy = static_destroy;
sttc.slices = si;
return sttc;
}
......
......@@ -31,7 +31,7 @@
#define __SLICING_H__
#include "openair2/LAYER2/MAC/mac.h"
#include "openair2/ENB_APP/flexran_agent_ran_api.h"
typedef struct slice_s {
/// Arbitrary ID
slice_id_t id;
......@@ -66,6 +66,7 @@ int slicing_get_UE_slice_idx(slice_info_t *si, int UE_id);
#define MAX_STATIC_SLICES 4
#define MAX_DYNAMIC_SLICES 10
#define RB_NUMS 25
#define BETA 0.01
typedef struct {
uint16_t posLow;
uint16_t posHigh;
......@@ -88,16 +89,18 @@ typedef struct {
uint16_t posHigh;
uint16_t kpsRequired;
uint16_t kpsReference;
uint16_t tmax;
uint16_t logdelta;
uint16_t tau;
uint16_t delay;
uint16_t typeid;
char *type;
uint16_t fexp;
uint16_t rbs;
uint16_t texp;
uint16_t eff;
uint16_t tau;
float delay;
float tmax;
float logdelta;
char *type;
float fexp;
float texp;
float eff;
float weight;
float dweight;
} scn19_slice_param_t;
......
#include "stdio.h"
#include "stdlib.h"
#include <time.h>
#define random(x) (rand()%x)
int arr_max(const float arr[],int n,int con)
{
const float ESP= 10e-4;
int maxindex=0,count;
const float*p=arr;
for(count=1;count<n;count++)
{
if(*p<=arr[count])
{
// printf("%f \n",(arr[count]-*p));
if(arr[count]-*p>ESP){
printf("%f \n",(arr[count]-*p));
p=&arr[count];
maxindex=count;
}
else{
/* 初始化随机数发生器 */
srand(count+con);
int swc = random(100);
printf("%d \n",swc);
if(swc<=49){
p=&arr[count];
maxindex=count;
}
else{
continue;
}
}
}
}
return maxindex;
}
int main(){
time_t t;
float a[4]={1.0,1.0,1.0,1.0};
float a1[4]={1.0,1.0,1.0,1.0};
float a2[4]={0.5,1.0,1.0,1.0};
int index1 = arr_max(a,4,((int)time(&t)));
int index2 = arr_max(a1,4,((int)time(&t))+1);
printf(" %d %d\n",index1,index2);
return 0;
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment