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";
......
This diff is collapsed.
This diff is collapsed.
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;
This diff is collapsed.
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
This diff is collapsed.
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");
This diff is collapsed.
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?
This diff is collapsed.
......@@ -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 typeid;
uint16_t rbs;
uint16_t tau;
uint16_t delay;
uint16_t typeid;
float delay;
float tmax;
float logdelta;
char *type;
uint16_t fexp;
uint16_t rbs;
uint16_t texp;
uint16_t eff;
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