#!/bin/sh
#
# $Id: dag38start 918 2004-12-09 02:57:11Z sfd $
#
# Startup and capture script for Dag3.8 cards
#
#
# First load the driver
#
# sudo dagload

#
# Make sure the Dag is in reset state
#
dagreset -d /dev/dag0

#
# Upload the latest Xilinx FPGA images
#
dagrom -d /dev/dag0 -vryp </usr/local/share/dag/xilinx/dag38pcix-erf.bit
dagld -d /dev/dag0 -x /usr/local/share/dag/xilinx/dag38pp-erf.bit

#
# Configure PHY layer settings
#
dagthree -d /dev/dag0 oc3 pos

#
# Alternative for ATM OC12c
#
#dagthree -d /dev/dag0 oc12 atm

#
# Set capture (snap) length
#
# First option, full packet capture
#
dagthree -d /dev/dag0 slen=1536

#
# Second otion, emulate classic header capture
# with fixed 64 byte records
#
#dagthree -d /dev/dag0 slen=48 novarlen

#
# For fibre chaining - SONET facility loopback on the card
#
#dagthree -d /dev/dag0 fcl

#
# For Dag-Dag synchronization enable Dag0 -> Dag1 PPS output
#
#dagclock -oo

#
# Synchronize system time with NTP server, as required
#
#sudo ntpdate -b ntpserver.company.com

#
# Ready for capture
#

ver=-v

stime=$(date +%Y%m%d-%H%M%S)

#
# The DAG 3.8 captures both interface ports into one file, here under /one.
# It may be a good idea to have software raid0 enabled on a set of
# 2-3 drives each, see raidtools (man 8 mkraid).
#
dagsnap -d /dev/dag0 $ver $dur -o /one/$stime-0

#
# Stopping the capture when running
#
# Option 1: foreground: hit Control-C
# Option 2: background: killall -9 dagsnap

#
# For longer trace files and machines with 2GB file limit,
# split trace into 1GB files. Names will be /one/capture0001.erf,
# /one/capture0002.erf etc
#
#dagconvert $ver -d /dev/dag0 -r 1g -o /one/capture

#
# To record libpcap format files as read by tcpdump, ethereal etc,
# use dagconvert.
#
# dagconvert $ver -d /dev/dag0 -Tdag:pcap -o /one/capture.pcap 

#
# Inspecting a trace file
#
#dagbits -vvc print </one/$stime-0
