%This code is written in MATLAB 2022. It is the main code that shows the physical layer skew and application layer clock skew is same. Physical layer skew is computed using mu.txt values and application layer skew is computed using app_clock_tx16.txt and app_clock_rx11.txt values clc clear all close all load mu.txt mu = mu.*0.2; mu_sig = mu'; phy_offset=[]; for sym_considered = 1010:1000:22000 mc = least_sq_phy(mu_sig(1:sym_considered-1)'); phy_offset(end+1) = mc(1)/2; end load app_clock_tx16.txt tx_clock = app_clock_tx16; load app_clock_rx11.txt rx_clock = app_clock_rx11; app_offset=[]; for timestamps_considered = 2:22 %length(tx_clock) off_clk = least_sq_app(tx_clock(1:timestamps_considered),rx_clock(1:timestamps_considered)); app_offset(end+1)=off_clk(1)-1; end x_axis =[2:22]; figure; plot(x_axis,phy_offset,'-b',x_axis,app_offset,'--r'); grid on; xlabel('Number of Timestamps'); ylabel('Frequency Offset'); title('Application & Physical layer clock offset computation using LS') legend('Physical layer offset','Application layer offset'); text(9,0.35*10^-5,['Physical layer offset = ' num2str(phy_offset(end))]) text(9,0.65*10^-5,['Application layer offset = ' num2str(app_offset(end))]) pp = ['Physical layer offset = ' num2str(phy_offset(end))]; pp = [pp 'Application layer offset = ' num2str(app_offset(end))]