📄 phyhd.m
字号:
function phy_header = phyhd(frame_data,seed,band,datarate,modulation)
%Use the paramaters to create a 24bits PHY header contain important
%informations
% frame_data - the data should be transfered, i.e. MAC data
% seed - seed identifier
% band - high or low
% datarate - transfer data rate
% modulation - type of modulation i.e. 4BOK or BPSK
phy_header=zeros(1,24);%PHY HEADER is 3 octets
seed_id=[0 0;0 1;1 0;1 1];%seed identifier, 4 seeds to generate scrambler.
fec_type=[0 0 0; 0 0 1;0 1 0;0 1 1;1 0 0;1 0 1;1 1 0; 1 1 1];
% FEC type, 3 bits: 0-no FEC;
% 1-k=6, rate 1/2
% 2-k=6, rate 3/4
% 3-k=4, rate 1/2
% 4-k=4, rate 3/4
% 5,6-for furture use
% 7-I define here(not appear in standard rate 1)
intx_type=[0,1];%Interleaver Type:0-convolutional bit interleaver
%1-for further use
code_length=[ 0 0 0; 0 0 1;0 1 0;0 1 1;1 0 0;1 0 1;1 1 0; 1 1 1];
%Payload code length,3 bits: 0 - length 24
% 1 - length 12
% 2 - length 6
% 3 - length 4
% 4 - length 3
% 5 - length 2
% 6 - length 1
% 7 - for furture use
mod_type=[0 0; 0 1;1 0;1 1];
% Modulation Type: 0 - BPSK
% 1 - 4-BOK natural coding
% 2 - 4-BOK Gray coding
% 3 - for furture use
frame_length = zeros(1,13);
templ=length(frame_data);
for i=1:13
frame_length(i)=floor(templ/2^(13-i));
templ=templ-frame_length(i)*2^(13-i);
end
switch modulation
case 'BPSK'
modtype=1;
switch band
case 'low'
switch datarate
case 28
fec=fec_type(1,:);
codelength=code_length(1,:);
case 55
fec=fec_type(1,:);
codelength=code_length(2,:);
case 110
fec=fec_type(1,:);
codelength=code_length(3,:);
case 220
fec=fec_type(1,:);
codelength=code_length(5,:);
case 500
fec=fec_type(2,:);
codelength=code_length(6,:);
case 660
fec=fec_type(8,:);
codelength=code_length(6,:);
case 1000
fec=fec_type(2,:);
codelength=code_length(7,:);
case 1320
fec=fec_type(8,:);
codelength=code_length(7,:);
end
case 'high'
switch datarate
case 28
error('No 28Mbps in High band!');
return;
case 55
fec=fec_type(1,:);
codelength=code_length(1,:);
case 110
fec=fec_type(1,:);
codelength=code_length(2,:);
case 220
fec=fec_type(1,:);
codelength=code_length(3,:);
case 500
fec=fec_type(2,:);
codelength=code_length(4,:);
case 660
fec=fec_type(8,:);
codelength=code_length(4,:);
case 1000
fec=fec_type(2,:);
codelength=code_length(6,:);
case 1320
fec=fec_type(8,:);
codelength=code_length(6,:);
end
end
case '4BOK'
modtype=2;
switch band
case 'low'
switch datarate
case 110
fec=fec_type(1,:);
codelength=code_length(2,:);
case 220
fec=fec_type(1,:);
codelength=code_length(3,:);
case 500
fec=fec_type(2,:);
codelength=code_length(4,:);
case 660
fec=fec_type(8,:);
codelength=code_length(4,:);
case 1000
fec=fec_type(2,:);
codelength=code_length(6,:);
case 1320
fec=fec_type(8,:);
codelength=code_length(6,:);
end
case 'high'
switch datarate
case 220
fec=fec_type(1,:);
codelength=code_length(2,:);
case 660
fec=fec_type(2,:);
codelength=code_length(3,:);
case 1000
fec=fec_type(2,:);
codelength=code_length(4,:);
case 1320
fec=fec_type(8,:);
codelength=code_length(4,:);
end
end
end
% create the header
switch seed
case 00
si=1;
case 01
si=2;
case 10
si=3;
case 11
si=4;
end
phy_header(1:2)=seed_id(si,:);
phy_header(3:5)=fec;
phy_header(6)=intx_type(1);
phy_header(7:9)=codelength;
phy_header(10:11)=mod_type(modtype,:);
phy_header(12:24)=frame_length;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -