icmp
icmp - configure the ICMP parameters for a port on a card on a chassis
SYNOPSIS
icmp sub-command options
DESCRIPTION
The icmp command is used to configure the ICMP-specific information used when building ICMP-type packets. Note that stream get must be called before this command's get sub-command.
STANDARD OPTIONS
checksum
Read-only Value of the checksum in the valid icmp stream. Valid only if the stream set is performed.
code
Code for each type of message. (default = 0)
id
ID for each ping command; that is, for the echoRequest. (default = 0)
sequence
Sequence number for each ping command (sequence number for the echoRequest) (default = 0)
type
Read-only The type of ICMP message to be sent. Options are:
Option |
Value |
Usage |
---|---|---|
echoReply |
0 |
(default) when echo message is received (when IP address is valid and receiving side supports the requested functions) |
destUnreachable |
3 |
when a datagram cannot reach its destination |
sourceQuench |
4 |
when gateway does not have the buffer space needed to queue the datagrams |
redirect |
5 |
when the gateway and the host identified by the internet source address of the datagram are on the same network |
echoRequest |
8 |
when network connection is to be tested (by ping command test the validity of IP address) |
timeExceeded |
11 |
when time to live field is 0 |
parameterProblem |
12 |
when there is a problem with the header parameters |
timeStampRequest |
13 |
to request the timestamp of the receipt at the other end |
timeStampReply |
14 |
to get the timestamp when the datagram began its return |
infoRequest |
15 |
when host needs to find out the number of the network it is on. |
infoReply |
16 |
when infoRequest is received |
maskRequest |
17 |
to get the subnet address mask from the router |
maskReply |
18 |
when maskRequest is received |
COMMANDS
The icmp command is invoked with the following sub-commands. If no sub-command is specified, returns a list of all sub-commands available.
icmp cget option
Returns the current value of the configuration option given by option. Option may have any of the values accepted by the icmp command.
icmp config option value
Modify the ICMP configuration options of the port. If no option is specified, returns a list describing all of the available ICMP options (see STANDARD OPTIONS) for port.
icmp decode capFrame [chasID cardID portID]
Decodes a captured frame in the capture buffer and updates TclHal. icmp cget option command can be used after decoding to get the option data. Specific errors are:
- No connection to a chassis
- Invalid port number
- The captured frame is not a valid Icmp frame
icmp get chasID cardID portID
Gets the current ICMP configuration of the port with id portID on card cardID, chassis chasID. Note that stream get must be called before this command's get sub-command. Call this command before calling icmp cget option value to get the value of the configuration option. Specific errors are:
- No connection to a chassis
- Invalid port number
icmp set chasID cardID portID
Sets the ICMP configuration of the port with id portID on card cardID, chassis chasID by reading the configuration option values set by the icmp config option value command. Specific errors are:
- No connection to a chassis
- Invalid port number
- The port is being used by another user
- The configured parameters are not valid for this port
icmp setDefault
Sets to IxTclHal default values for all configuration options.
EXAMPLES
package require IxTclHal
# In this example we'll send an echo response message from a port
# back to itself and decode the received packet
set host 400-031561
set username user
# Check if we're running on UNIX - connect to the TCL Server
# which must be running on the chassis
if [isUNIX] {
if [ixConnectToTclServer $host] {
ixPuts "Could not connect to $host"
return 1
}
}
# Now connect to the chassis
if [ixConnectToChassis $host] {
ixPuts $::ixErrorInfo
return 1
}
# Get the chassis ID to use in port lists
set chas [ixGetChassisID $host]
# Assume card to be used is in slot 1
set card 1
set port 1
set portList [list [list $chas $card $port]]
# Login before taking ownership
if [ixLogin $username] {
ixPuts $::ixErrorInfo
return 1
}
# Take ownership of the ports we'll use
if [ixTakeOwnership $portList] {
ixPuts $::ixErrorInfo
return 1
}
# Some defines for IP setup
set portMAC {00 00 00 01 01 01}
set portIP {192.168.18.1}
set portMask {255.255.255.0}
set destMAC {00 00 00 01 01 02}
set destIP {192.168.18.2}
set destMask {255.255.255.0}
# Put the port in loopback mode
port setFactoryDefaults $chas $card $port
port setDefault
port config -loopback true
# Stream: 1 packet at 1%
stream setDefault
stream config -numFrames 1
stream config -dma stopStream
stream config -rateMode usePercentRate
stream config -percentPacketRate 1
# set protocol to IP
protocol setDefault
protocol config -name ip
protocol config -ethernetType ethernetII
# Set up IP: icmp with 46 byte packet
ip setDefault
ip config -ipProtocol icmp
ip config -totalLength 46
ip config -sourceIpAddr $portIP
ip config -sourceIpMask $portMask
ip config -sourceClass classC
ip config -destIpAddr $destIP
ip config -destIpMask $destMask
ip config -destClass classC
ip set $chas $card $port
# Send an echo reply with some data in id and sequence
icmp setDefault
icmp config -type echoReply
icmp config -code 0
icmp config -id 3
icmp config -sequence 42
icmp set $chas $card $port
stream set $chas $card $port 1
port set $chas $card $port
# Set up the port
ixWritePortsToHardware portList
# Start capture and send the packet
after 1000
ixStartPortCapture $chas $card $port
ixStartPortTransmit $chas $card $port
# Stop port capture
after 1000
ixStopPortCapture $chas $card $port
# Get the capture buffer
captureBuffer get $chas $card $port
if {[captureBuffer cget -numFrames] == 0} {
ixPuts "No packets received"
} else {
# Get the frame
captureBuffer getframe 1
set data [captureBuffer cget -frame]
# And decode the data
icmp decode $data $chas $card $port
ixPuts -nonewline "Received packet: code = "
ixPuts -nonewline [icmp cget -code]
ixPuts -nonewline ", id = "
ixPuts -nonewline [icmp cget -id]
ixPuts -nonewline ", sequence = "
ixPuts [icmp cget -sequence]
}
# Let go of the ports that we reserved
ixClearOwnership $portList
# Disconnect from the chassis we're using
ixDisconnectFromChassis $host
# If we're running on UNIX, disconnect from the TCL Server
if [isUNIX] {
ixDisconnectTclServer $host
}