ibm midrange - Give some examples of TCP Connection Status in JT400 - JAVA -


i'm tried as400 tcp connection status. i'm failed :( can me this. i'm new jt400 java development. please me friends.

  1. i want ip address of job
  2. i want tcp connection status using (1) ip address.

please me thank you!

edit :

i got class

com.ibm.as400.util.commtrace.tcpheader 

it's return informations

getackflag() getacknum() getchecksum() getcwrflag() getdataoffset() getdstport() ..etc 

now want informations. mean, how tcp status using class.

please me

thank you

the commtrace classes not real-time. use trace file created on ibm server @ earlier time. in order create trace file, see javadoc com.ibm.as400.util.commtrace.commtrace need run ibm commands strcmntrc, endcmntrc , dmpcmntrc. use commtrace.commtrace create trace file formatted other commtrace classes can read it.

edit: add code snippet commtrace.format javadoc

import java.util.*; import com.ibm.as400.access.*; import com.ibm.as400.util.commtrace.*;  public class testcommtrace {     public static void main(string[] args) {  try {  format f = new format("/buck/linetrace");   formatproperties fmtprop = new formatproperties();  f.setfilterproperties(fmtprop); // sets filtering properties format   f.formatprolog(); // format prolog  prolog pro = f.getprolog();      system.out.println(pro.tostring());   if(!pro.invaliddata()) { // not valid trace          frame rec;           while((rec=f.getnextrecord())!=null) { // records                 system.out.print("frame " + rec.getrecnum().tostring()); // print out frame number                 system.out.println(" time " + rec.gettime().tostring()); // print out time                 ippacket p = rec.getpacket(); // records packet                 header h = p.getheader(); // first header                 if(p.gettype()==ippacket.ip4) { // if ip4 ippacket                         if(h.gettype()==header.ip4) { // if ip4 header                                 ip4header ip4 = (ip4header) h; // cast ip4 can access methods                                 system.out.println(h.getname()); // print name                                 system.out.println("ip4 src:"+ip4.getsrcaddr() + " dst:" + ip4.getdstaddr());                                 system.out.println(ip4.printhexheader()); // print header hex                                  // print string representation of header.                                 system.out.println(ip4.tostring()); // hex string                                 //system.out.println(ip4.tostring(fmtprop)); // detailed                                 while((h=h.getnextheader())!=null) { // rest of headers                                         if(h.gettype()==header.tcp) { // if tcp header                                                 tcpheader tcp = (tcpheader) h; // cast can access methods                                                 system.out.println("tcp src:" + tcp.getsrcport() + " dst:" + tcp.getdstport() + " checksum:" + tcp.getchecksum());                                                  system.out.println(tcp.tostring());  // hex string                                                 //system.out.println(tcp.tostring(fmtprop));  // detailed                                          } else if(h.gettype()==header.udp) { // if udp header                                                 udpheader udp = (udpheader) h; // cast can access methods                                                 system.out.println("udp src:" + udp.getsrcport() + " dst:" + udp.getdstport());                                                  system.out.println(udp.tostring());                                         }                                 }                         }                 }          }    f.close();  }           } catch (exception e) {       e.printstacktrace();     } }  } 

edit: more detailed information

1) on ibm system, special permission must run strcmntrc , collect communications trace information. trace file contains of tcp packets flowed between ibm system , outside world. example, if trace runs hour, collect every packet system sent , received during hour. trace data stored in format special , can not directly read.

2) make trace data readable, use dmpcmntrc command. create flat text stream file out of trace data. data needs pc com.ibm.as400.util.commtrace classes can work on it.

3) on pc, run com.ibm.as400.util.commtrace.commtrace. create file in simple text form com.ibm.as400.util.commtrace can process. put mine in /buck/linetrace. important understand there hundreds or thousands of packets in log, , every 1 of them has information ask in question. there not 1 single ack flag, there many hundreds of them. in order understand happening, program need read packet, header, status, data , read next packet, , next , next, way through them all.

4) in order filter ip address, can either use setfilterproperties() or have code check ip addresses in each packet header , process headers want to.

it important understand 'status' looking not property of ip address, property of tcp packet. there no way ask system ack flag of ip address because there no such property returned. way these things record them @ instant packet read or written system.

i surprised if need these flags; no 1 does. usually, 'connection status' means way determine if machine running or not. ping typical way answer question, not machines answer ping. machines, best way try connect machine , port want test.


Comments