#!/bin/sh
#
# $Id: dag37gestart 1534 2005-06-02 02:08:16Z sfd $
#
# Startup and capture script for Dag3.7ge cards
#
#
# First load the driver
#
# sudo dagload

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

#
# Upload the latest Xilinx FPGA images
#
dagrom -d dag0 -vryp -f /usr/local/share/dag/xilinx/dag37gepci-terf.bit

#
# Set PHY defaults.
#
dagthree -d dag0 default

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

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

#
# Apply PHY changes, as needed.
#
#dagthree -d dag0 1000

#
# For Dag-Dag synchronization enable Dag0 -> Dag1 PPS output
#
#dagclock -d dag0 none overout

#
# 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)

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 dag0 -r 1g -o /one/capture

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

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

#
# Analysis with tcpdump
#
#dagconvert -T erf:pcap </one/$stime-0 | tcpdump -nr -	# no DNS name lookup
#or
#dagconvert -T erf:pcap </one/$stime-0 | tcpdump -r -	# DNS lookup, may hang at times
