⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 etherealparser2.asv

📁 用matlab写的以太网报头提取工具。它可以截获网络数据包并记录下它的时间戳、数据包长度和数据域等。
💻 ASV
📖 第 1 页 / 共 3 页
字号:


function IP3_Callback(hObject, eventdata, handles)
% hObject    handle to IP3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of IP3 as text
%        str2double(get(hObject,'String')) returns contents of IP3 as a double


% --- Executes during object creation, after setting all properties.
function IP3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to IP3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function IP4_Callback(hObject, eventdata, handles)
% hObject    handle to IP4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of IP4 as text
%        str2double(get(hObject,'String')) returns contents of IP4 as a double


% --- Executes during object creation, after setting all properties.
function IP4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to IP4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function nPkts_Callback(hObject, eventdata, handles)
% hObject    handle to nPkts (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of nPkts as text
%        str2double(get(hObject,'String')) returns contents of nPkts as a double


% --- Executes during object creation, after setting all properties.
function nPkts_CreateFcn(hObject, eventdata, handles)
% hObject    handle to nPkts (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in MACDestAddress.
function MACDestAddress_Callback(hObject, eventdata, handles)
% hObject    handle to MACDestAddress (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of MACDestAddress


% --- Executes on button press in TCPSourcePort.
function TCPSourcePort_Callback(hObject, eventdata, handles)
% hObject    handle to TCPSourcePort (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of TCPSourcePort


% --- Executes on button press in TCPSeqNumber.
function TCPSeqNumber_Callback(hObject, eventdata, handles)
% hObject    handle to TCPSeqNumber (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of TCPSeqNumber


% --- Executes on button press in TCPAckNumber.
function TCPAckNumber_Callback(hObject, eventdata, handles)
% hObject    handle to TCPAckNumber (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of TCPAckNumber


% --- Executes on button press in TCPHdrLength.
function TCPHdrLength_Callback(hObject, eventdata, handles)
% hObject    handle to TCPHdrLength (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of TCPHdrLength


% --- Executes on button press in TCPChecksum.
function TCPChecksum_Callback(hObject, eventdata, handles)
% hObject    handle to TCPChecksum (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of TCPChecksum


% --- Executes on button press in TCPSeqAck.
function TCPSeqAck_Callback(hObject, eventdata, handles)
% hObject    handle to TCPSeqAck (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of TCPSeqAck


% --- Executes on button press in TCPDestPort.
function TCPDestPort_Callback(hObject, eventdata, handles)
% hObject    handle to TCPDestPort (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of TCPDestPort


% --- Executes on button press in TCPFlags.
function TCPFlags_Callback(hObject, eventdata, handles)
% hObject    handle to TCPFlags (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of TCPFlags


% --- Executes on button press in TCPWindowSize.
function TCPWindowSize_Callback(hObject, eventdata, handles)
% hObject    handle to TCPWindowSize (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of TCPWindowSize


% --- Executes on button press in pbProcessFile.
function pbProcessFile_Callback(hObject, eventdata, handles)
% hObject    handle to pbProcessFile (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%% Open Ethereal Capture File and skip Capture ID Bytes
fullName=get(handles.filename,'String');
fid=fopen(fullName);

s=fseek(fid,24,'cof');

%% Initialize data variables
nPkts=str2num(get(handles.nPkts,'String'));
ts=zeros(nPkts,7);
len=zeros(nPkts,1);
IP(1)=str2num(get(handles.IP1,'String'));
IP(2)=str2num(get(handles.IP2,'String'));
IP(3)=str2num(get(handles.IP3,'String'));
IP(4)=str2num(get(handles.IP4,'String'));

% Set up empty arrays for selected Ethernet fields
bitfield=zeros(28,1);
nFields=0;
fieldNames=[];
% MAC fields
tv=get(handles.MACDestAddress,'Value');
if (tv==1)
    MACDestAddress=zeros(nPkts,6);
    bitfield(1)=1;
    nFields=nFields+1;
    fieldNames=[fieldNames 'MACDestAddress'];
end
tv=get(handles.MACSourceAddress,'Value');
if (tv==1)
    MACSourceAddress=zeros(nPkts,6);
    bitfield(2)=1;
    nFields=nFields+1;
    fieldNames=[fieldNames 'MACSourceAddress'];
end
tv=get(handles.MACType,'Value');
if (tv==1)
    MACType=zeros(nPkts,2);
    bitfield(3)=1;
    nFields=nFields+1;
    fieldNames=[fieldNames 'MACType'];
end

% IP Fields
tv=get(handles.IPVersion,'Value');
if (tv==1)
    IPVersion=zeros(nPkts,1);
    bitfield(4)=1;
    nFields=nFields+1;
    fieldNames=[fieldNames 'IPVersion'];
end
tv=get(handles.IPHdrLength,'Value');
if (tv==1)
    IPHdrLength=zeros(nPkts,1);
    bitfield(5)=1;
    nFields=nFields+1;
    fieldNames=[fieldNames 'IPHdrLength'];
end
tv=get(handles.IPDiffServeField,'Value');
if (tv==1)
    IPDiffServeField=zeros(nPkts,1);
    bitfield(6)=1;
    nFields=nFields+1;
    fieldNames=[fieldNames 'IPDiffServeField'];
end
tv=get(handles.IPTotalLength,'Value');
if (tv==1)
    IPTotalLength=zeros(nPkts,2);
    bitfield(7)=1;
    nFields=nFields+1;
    fieldNames=[fieldNames 'IPTotalLength'];
end
tv=get(handles.IPID,'Value');
if (tv==1)
    IPID=zeros(nPkts,2);
    bitfield(8)=1;
    nFields=nFields+1;
    fieldNames=[fieldNames 'IPID'];
end
tv=get(handles.IPFlags,'Value');
if (tv==1)
    IPFlags=zeros(nPkts,1);
    bitfield(9)=1;
    nFields=nFields+1;
    fieldNames=[fieldNames 'IPFlags'];
end
tv=get(handles.IPFragOffset,'Value');
if (tv==1)
    IPFragOffset=zeros(nPkts,1);
    bitfield(10)=1;
    nFields=nFields+1;
    fieldNames=[fieldNames 'IPFragOffset'];
end
tv=get(handles.IPTimeToLive,'Value');
if (tv==1)
    IPTimeToLive=zeros(nPkts,1);
    bitfield(11)=1;
    nFields=nFields+1;
    fieldNames=[fieldNames 'IPTimeToLive'];
end
tv=get(handles.IPProtocol,'Value');
if (tv==1)
    IPProtocol=zeros(nPkts,1);
    bitfield(12)=1;
    nFields=nFields+1;
    fieldNames=[fieldNames 'IPProtocol'];
end
tv=get(handles.IPHdrChecksum,'Value');
if (tv==1)
    IPHdrChecksum=zeros(nPkts,2);
    bitfield(13)=1;
    nFields=nFields+1;
    fieldNames=[fieldNames 'IPHdrChecksum'];
end
tv=get(handles.IPSourceAddress,'Value');
if (tv==1)
    IPSourceAddress=zeros(nPkts,4);
    bitfield(14)=1;
    nFields=nFields+1;
    fieldNames=[fieldNames 'IPSourceAddress'];
end
tv=get(handles.IPDestAddress,'Value');
if (tv==1)
    IPDestAddress=zeros(nPkts,4);
    bitfield(15)=1;
    nFields=nFields+1;
    fieldNames=[fieldNames 'IPDestAddress'];
end

% TCP Fields
tv=get(handles.TCPSourcePort,'Value');
if (tv==1)
    TCPSourcePort=zeros(nPkts,2);
    bitfield(16)=1;
    nFields=nFields+1;
    fieldNames=[fieldNames 'TCPSourcePort'];
end
tv=get(handles.TCPDestPort,'Value');
if (tv==1)
    TCPDestPort=zeros(nPkts,2);
    bitfield(17)=1;
    nFields=nFields+1;
    fieldNames=[fieldNames 'TCPDestPort'];
end
tv=get(handles.TCPSeqNumber,'Value');
if (tv==1)
    TCPSeqNumber=zeros(nPkts,4);
    bitfield(18)=1;
    nFields=nFields+1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -