IPTRACE | z/OS Mainframe
This program came from a project requirement to search for strings in packets from z/OS TCP/IP trace data - a feature that was missing from IBM's IPCS. This was made more challenging as the format of the CTRACE and IP blocks were not fully documented in IBM's manuals. As there is normally a large amount of data, it is read into a Dataspace and parsed, with the output being written to DD:SYSPRINT. A TSO/ISPF front end (not available) was developed to aid the end-user when searching for specific dates/text etc.
Download
History
Planned Changes
- None
Screenshots / Output
Description & Parameters
This program is used to process TCPIP Packet Trace data. All parameters are specified in DD:SYSIN - see the JCL Setup below.
PCAP creates a PCAP capture file in DD:SYSPRINT which can be downloaded and viewed in Wireshark - see below.
JCL Example
This example JCL is set up as follows:
//STEP1 EXEC PGM=IPTRACE,REGION=0M //STEPLIB DD DISP=SHR,DSN=YOUR.LOADLIB //SYSUT1 DD DISP=SHR,DSN=TCPIP.TRACE.DATA //SYSUT2 DD DISP=MOD,DSN=TCPIP.TRACE.DATA.LOG //SYSPRINT DD SYSOUT=*,OUTLIM=4000000 //LOG DD SYSOUT=* //SYSIN DD * FULL SHOW_TCP_HEADER SHOW_PROTOCOL_HEADER /*
Searching
The SEARCH parameter allows searching for mixed case arguments within the EBCDIC translation of the data. If you cannot find your search argument, specify ASCII_SEARCH and resubmit your JCL.
Redirecting DD:SYSPRINT to a Dataset
Normally DD:SYSPRINT is set to SYSOUT=* so it is available for online viewing. You can change this to write to a sequential dataset of RECFM=FB with LRECL=80.
The displays for FULL and SUMMARY are fixed at LRECL=105 whereas PCAP and DATASET_DETAIL are fixed at LRECL=80.
Creating PCAP Capture Files for Wireshark
IPTRACE can create PCAP version 2.4 files for use with Wireshark. The PCAP option creates the data in DD:SYSPRINT which should be written to a dataset and downloaded as binary to your PC. When you specify the PCAP option, some incompatible options will be turned off.
IBM record timestamps in the TCPIP packets as local time whereas the PCAP format specifies UTC with a time offset. Therefore you might notice that the timestamps are different when they are opened in Wireshark as it increments the time by the timezone offset. The packet data is not translated from EBCDIC to ASCII as Wireshark allows you to view the data as both. This makes it useful when MVS connects to a Unix system.
Wireshark may show some messages reporting cut short packets - this is due to the padding bytes on the Fixed Block 80-byte record at the end of the capture file - the capture file will still be processed correctly.
The PCAP capture file is created as follows with a Global Header, Record Header, Data, Record Header, Data etc…
Global Header
See https://www.tcpdump.org/linktypes.html.
Record (Packet) Header
Packet Data
The actual packet data will immediately follow the packet header as data of incl_len bytes.See https://wiki.wireshark.org/Development/LibpcapFileFormat for more details.
Abend or Error Codes
Environment
This program was written in z/OS HLASM Assembler and will run under z/OS 31bit. The code is re-entrant.
No additional authorisations are required.
This program was developed and tested under z/OS 1.12 up to z/OS 2.4.
Additional Macros
The program uses the STRING macro from https://gsf-soft.com/Freeware/STRING.html - I highly recommend this.IPTRACE also uses an internal macro, VERSION, which is included in the XMIT file.
Assemble & Link
The program contains multiple source members. Each member will compile into object files in a separate dataset. Member #BUILD will link these modules together. The JCL runs under JES3 so you will probably need to tailor it for your environment.
TCP and Protocol Headers are found in TCPIP.SEZACMAC(EZAAI03J/FMTIPPKT). These are not used as more meaningful names are used in the source.
FORMAT (Common Trace Element) = .-------------------------------------. |......|..........................|...| CTE | CTEDATA | CTELENE /------------------------ \ | PTHDR | IPH | HDR | DATA | '----------------|----------' TCP, UDP, OSPF, ICMPCTEs contain the CTE element and the CTEDATA contains the PTHDR, Internet Protocol Header, the Protocol Header (TCP, UDP, OSPF or ICMP) followed by the data. In the case of split buffers, only the PTHDR and DATA exist.
FORMAT (DATASPACE) = .-------------------------------------. |........|............................| LENGTH |PACKET | (2bytes) /---------------------------\ | PTHDR | IPH | HDR | DATA | '----------------|-----------' TCP, UDP, OSPF, ICMP
TCP/IP Tracing Setup
Setting up TCPIP tracing on MVS is quite simple. We run tracing 24x7 so we use a small GDG (7 generations) for the PTTCP data. When it is stopped hourly, we copy that GDG to another GDG (255 generations) - this allows DFHSM to migrate the second GDG when it's not in use.Create a task named PTTCP in the PROCLIB concatenation as below - we define the DD:TRCOUT01 as a GDG (as mentioned):
//PTTCP PROC //* //* TCPIP PACKET TRACE WRITER //* //IEFPROC EXEC PGM=ITTTRCWR //TRCOUT01 DD DSNAME=SYS0.IPTRACE(+1), // SPACE=(CYL,(150,130),RLSE),DISP=(NEW,CATLG),DSORG=PS
Start TCP/IP Tracing
To start tracing, issue the following commands (we have automated responses to the replies):
D TRACE,COMP=SYSTCPDA,SUB=(TCPIP)
- Display options (look for OPTIONS and WRITER)
TRACE CT,WTRSTART=PTTCP,WRAP
- Start CTRACE external writer
TRACE CT,ON,COMP=SYSTCPDA,SUB=(TCPIP)
- Connect the external writer to the TCPIP address space. Enter WTR=PTTCP,OPTIONS=(ALL),END to ITT006A message
D TRACE,COMP=SYSTCPDA,SUB=(TCPIP)
- Display options (look for OPTIONS and WRITER)
V TCPIP,,PKT,ON
- Start required TCPIP packet trace - add IP=xxx.xxx.xxx.xxx for specific tracing, SRCP=xxxx for source port and DEST=xxx for destination port
Issue TSO NETSTAT DEV and check IP address under Packet Trace Setting
Stop TCP/IP Tracing
To stop tracing, issue the following commands (we have automated the replies):
V TCPIP,,PKT,OFF
- Stop packet tracing
TRACE CT,OFF,COMP=SYSTCPDA,SUB=(TCPIP)
- Disconnect the external writer from the TCPIP address space
TRACE CT,WTRSTOP=PTTCP
- Stop CTRACE external writer
D TRACE,COMP=SYSTCPDA,SUB=(TCPIP)
- Display options (look for OPTIONS and WRITER)
After tracing has been stopped, use the DD:TRCOUT01 dataset as DD:SYSUT1 in the JCL example above.