IP数据包分析

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class aa1 extends JFrame implements ActionListener
{
JDialog dlg = new JDialog(this);
JLabel tip,tip1,tip2;
JTextField txt,txt1;
JTextArea txt2;
JButton submit,submit1;
public aa1(){

JFrame jf = new JFrame("信息填入");
Container cp = jf.getContentPane();

tip = new JLabel("源地址:");


tip1 = new JLabel("目的地址:");
tip2 = new JLabel("数据内容:");
submit = new JButton("TCP发送");
submit1 = new JButton("UDP发送");
jf.setSize(250,250);
cp.setLayout(null);

cp.add(tip);
cp.add(tip1);
cp.add(tip2);

txt=new JTextField ("210.45.165.12");
txt.setEditable(false);

txt1=new JTextField (14);
txt2=new JTextArea (5,14);

cp.add(txt);
cp.add(txt1);
cp.add(txt2);

cp.add(submit);
cp.add(submit1);

submit.addActionListener(this);
submit1.addActionListener(this);


tip.setBounds(10,10,80,40);
tip1.setBounds(10,30,80,40);
tip2.setBounds(10,50,80,40);
txt.setBounds(100,20,120,20);
txt1.setBounds(100,40,120,20);
txt2.setBounds(10,80,200,40);
submit.setBounds(10,150,100,20);
submit1.setBounds(120,150,100,20);

jf.setVisible(true);
}



public static void main(String args[]) {
aa1 dd=new aa1();

}

public void actionPerformed(ActionEvent ae) {


if(ae.getActionCommand().equals("TCP发送"))
{

JTextField t1 = new JTextField("4");
t1.setEditable(false);
JTextField t2 = new JTextField("5");
t2.setEditable(false);
JTextField t3 = new JTextField("0");
t3.setEditable(false);
JTextField t4 = new JTextField("28");
t4.setEditable(false);
JTextField t5 = new JTextField("1");
t5.setEditable(false);
JTextField t6 = new JTextField("0");
t6.setEditable(false);
JTextField t7 = new JTextField("0");
t7.setEditable(false);
JTextField t8 = new JTextField("4");
t8.setEditable(false);
JTextField t92 = new JTextField("17");
t92.setEditable(false);

JTextField t10 = new JTextField("首部检验和");
t10.setEditable(false);
JTextField t11 = new JTextField(txt.getText());
JTextField t12 = new JTextField(txt1.getText());
JTextArea t13 = new JTextArea(txt2.getText());

t1.setBounds(0,0,40,20);
t2.setBounds(40,0,40,20);
t3.setBounds(80,0,80,20);
t4.setBounds(160,0,160,20);
t5.setBounds(0,20,160,20);
t6.setBounds(160,20,40,20);
t7.setBounds(200,20,120,20);
t8.setBounds(0,40,80,20);
t92.setBounds(80,40,80,20);
t10.setBounds(160,40,160,20);
t11.setBounds(0,60,320,20);
t12.setBounds(0,80,320,20);
t13.setBounds(0,100,320,40);

dlg.setLayout(null);


dlg.setSize(320,250);
dlg.setTitle("信息发送");

dlg.add(t1);
dlg.add(t2);
dlg.add(t3);
dlg.add(t4);
dlg.add(t5);
dlg.add(t6);
dlg.add(t7);
dlg.add(t8);
dlg.add(t92);
dlg.add(t10);
dlg.add(t11);
dlg.add(t12);
dlg.add(t13);



JButton d1=new JButton("发送");
d1.setBounds(120,160,80,40);

d1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {

JLabel a1 = new JLabel("应用层");
JLabel a2 = new JLabel("运输层");
JLabel a3 = new JLabel("网络层");
JLabel a4 = new JLabel("数据链路层");

JTextField s1 = new JTextField("首部");
s1.setEditable(false);
JTextField s2 = new JTextField("首部");
s2.setEditable(false);
JTextField s3 = new JTextField("首部");
s3.setEditable(false);
JTextField s4 = new JTextField("首部");
s4.setEditable(false);
JTextField s5 = new JTextField(txt2.getText());
JTextField s6 = new JTextField(s1.getText()+txt2.getText());
JTextField s7 = new JTextField(s2.getText()+s1.getText()+txt2.getText());
JTextField s8 = new JTextField(s3.getText()+s2.getText()+s1.getText()+txt2.getText());

JDialog dlg1 = new JDialog();

dlg1.setLayout(null);
dlg1.setSize(600,400);
dlg1.setTitle("发送中");

a1.setBounds(0,0,60,20);
a2.setBounds(0,60,60,20);
a3.setBounds(0,120,60,20);
a4.setBounds(0,180,100,20);

s1.setBounds(120,20,40,20);
s5.setBounds(160,20,320,20);
s2.setBounds(80,80,40,20);
s6.setBounds(120,80,320,20);
s3.setBounds(40,140,40,20);
s7.setBounds(80,140,320,20);
s4.setBounds(0,200,40,20);
s8.setBounds(40,200,320,20);


dlg1.add(a1);
dlg1.add(a2);
dlg1.add(a3);
dlg1.add(a4);
dlg1.add(s1);
dlg1.add(s2);
dlg1.add(s3);
dlg1.add(s4);
dlg1.add(s5);
dlg1.add(s6);
dlg1.add(s7);
dlg1.add(s8);

JButton d2=new JButton("确定");
d2.setBounds(160,270,80,40);

d2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
JLabel q = new JLabel("发送成功");
q.setFont(new Font("黑体",Font.BOLD,30));
q.setBounds(100,50,240,50);

JDialog dlg2 = new JDialog();

dlg2.setLayout(null);
dlg2.setSize(320,200);
dlg2.setTitle("发送成功");
dlg2.add(q);
dlg2.setLocation(250,0);
dlg2.setVisible(true);

}
});

dlg1.a

dd(d2);
dlg1.setLocation(250,0);
dlg1.setVisible(true);
}
});
dlg.add(d1);
dlg.setLocation(250,0);
dlg.setVisible(true);

}
else if(ae.getActionCommand().equals("UDP发送")){

JTextField t1 = new JTextField("4");
t1.setEditable(false);
JTextField t2 = new JTextField("5");
t2.setEditable(false);
JTextField t3 = new JTextField("0");
t3.setEditable(false);
JTextField t4 = new JTextField("28");
t4.setEditable(false);
JTextField t5 = new JTextField("1");
t5.setEditable(false);
JTextField t6 = new JTextField("0");
t6.setEditable(false);
JTextField t7 = new JTextField("0");
t7.setEditable(false);
JTextField t8 = new JTextField("4");
t8.setEditable(false);
JTextField t91 = new JTextField("6");
t91.setEditable(false);

JTextField t10 = new JTextField("10001011 10111100");
t10.setEditable(false);
JTextField t11 = new JTextField(txt.getText());
JTextField t12 = new JTextField(txt1.getText());
JTextArea t13 = new JTextArea(txt2.getText());

t1.setBounds(0,0,40,20);
t2.setBounds(40,0,40,20);
t3.setBounds(80,0,80,20);
t4.setBounds(160,0,160,20);
t5.setBounds(0,20,160,20);
t6.setBounds(160,20,40,20);
t7.setBounds(200,20,120,20);
t8.setBounds(0,40,80,20);
t91.setBounds(80,40,80,20);
t10.setBounds(160,40,160,20);
t11.setBounds(0,60,320,20);
t12.setBounds(0,80,320,20);
t13.setBounds(0,100,320,40);

dlg.setLayout(null);
dlg.setSize(320,250);
dlg.setTitle("信息发送");

dlg.add(t1);
dlg.add(t2);
dlg.add(t3);
dlg.add(t4);
dlg.add(t5);
dlg.add(t6);
dlg.add(t7);
dlg.add(t8);
dlg.add(t91);
dlg.add(t10);
dlg.add(t11);
dlg.add(t12);
dlg.add(t13);

JButton d1=new JButton("发送");
d1.setBounds(120,160,80,40);

d1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
JLabel a1 = new JLabel("应用层");
JLabel a2 = new JLabel("运输层");
JLabel a3 = new JLabel("网络层");
JLabel a4 = new JLabel("数据链路层");

JTextField s1 = new JTextField("首部");
s1.setEditable(false);
JTextField s2 = new JTextField("首部");
s2.setEditable(false);
JTextField s3 = new JTextField("首部");
s3.setEditable(false);
JTextField s4 = new JTextField("首部");
s4.setEditable(false);
JTextField s5 = new JTextField(txt2.getText());
JTextField s6 = new JTextField(s1.getText()+txt2.getText());
JTextField s7 = new

JTextField(s2.getText()+s1.getText()+txt2.getText());
JTextField s8 = new JTextField(s3.getText()+s2.getText()+s1.getText()+txt2.getText());

JDialog dlg1 = new JDialog();

dlg1.setLayout(null);
dlg1.setSize(600,400);
dlg1.setTitle("发送中");

a1.setBounds(0,0,60,20);
a2.setBounds(0,60,60,20);
a3.setBounds(0,120,60,20);
a4.setBounds(0,180,100,20);

s1.setBounds(120,20,40,20);
s5.setBounds(160,20,320,20);
s2.setBounds(80,80,40,20);
s6.setBounds(120,80,320,20);
s3.setBounds(40,140,40,20);
s7.setBounds(80,140,320,20);
s4.setBounds(0,200,40,20);
s8.setBounds(40,200,320,20);


dlg1.add(a1);
dlg1.add(a2);
dlg1.add(a3);
dlg1.add(a4);
dlg1.add(s1);
dlg1.add(s2);
dlg1.add(s3);
dlg1.add(s4);
dlg1.add(s5);
dlg1.add(s6);
dlg1.add(s7);
dlg1.add(s8);

JButton d2=new JButton("确定");
d2.setBounds(160,270,80,40);

d2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
JLabel q = new JLabel("发送成功");
q.setFont(new Font("黑体",Font.BOLD,30));
q.setBounds(100,50,240,50);

JDialog dlg2 = new JDialog();

dlg2.setLayout(null);
dlg2.setSize(320,200);
dlg2.setTitle("发送成功");
dlg2.add(q);
dlg2.setLocation(250,0);
dlg2.setVisible(true);
}
});

dlg1.add(d2);
dlg1.setLocation(250,0);
dlg1.setVisible(true);
}
});

dlg.add(d1);
dlg.setLocation(250,0);
dlg.setVisible(true);
}









}
}

相关文档
最新文档