MoonGen
 All Files Functions Variables Pages
ptp.lua File Reference

Precision time protocol (PTP) utility. More...

Go to the source code of this file.

Functions

function ptpHeader setMessageType (mt)
 Set the message type. More...
 
function ptpHeader getMessageType ()
 Retrieve the message type. More...
 
function ptpHeader getMessageTypeString ()
 Retrieve the message type. More...
 
function ptpHeader setVersion (v)
 Set the version. More...
 
function ptpHeader getVersion ()
 Retrieve the version. More...
 
function ptpHeader getVersionString ()
 Retrieve the version. More...
 
function ptpHeader setLength (l)
 Set the length. More...
 
function ptpHeader getLength ()
 Retrieve the length. More...
 
function ptpHeader getLengthString ()
 Retrieve the length. More...
 
function ptpHeader setDomain (d)
 Set the domain. More...
 
function ptpHeader getDomain ()
 Retrieve the domain. More...
 
function ptpHeader getDomainString ()
 Retrieve the domain. More...
 
function ptpHeader setReserved (uint8)
 Set the reserved field. More...
 
function ptpHeader getReserved ()
 Retrieve the reserved field. More...
 
function ptpHeader getReservedString ()
 Retrieve the reserved field. More...
 
function ptpHeader setFlags (f)
 Set the flags. More...
 
function ptpHeader getFlags ()
 Retrieve the flags. More...
 
function ptpHeader getFlagsString ()
 Retrieve the flags. More...
 
function ptpHeader setCorrection (c)
 Set the correction field. More...
 
function ptpHeader getCorrection ()
 Retrieve the correction field. More...
 
function ptpHeader getCorrectionString ()
 Retrieve the correction field. More...
 
function ptpHeader setReserved2 (uint32)
 Set the reserved2 field. More...
 
function ptpHeader getReserved2 ()
 Retrieve the reserved2 field. More...
 
function ptpHeader getReserved2String ()
 Retrieve the reserved2 field. More...
 
function ptpHeader setOui (int)
 Set the oui. More...
 
function ptpHeader getOui ()
 Retrieve the oui. More...
 
function ptpHeader getOuiString ()
 Retrieve the oui. More...
 
function ptpHeader setUuid (int)
 Set the uuid. More...
 
function ptpHeader getUuid ()
 Retrieve the Uuid. More...
 
function ptpHeader getUuidString ()
 Retrieve the Uuid. More...
 
function ptpHeader setNodePort (p)
 Set the node port. More...
 
function ptpHeader getNodePort ()
 Retrieve the node port. More...
 
function ptpHeader getNodePortString ()
 Retrieve the node port. More...
 
function ptpHeader setSequenceID (s)
 Set the sequence ID. More...
 
function ptpHeader getSequenceID ()
 Retrieve the sequence ID. More...
 
function ptpHeader getSequenceIDString ()
 Retrieve the sequence ID. More...
 
function ptpHeader setControl (c)
 Set the control field. More...
 
function ptpHeader getControl ()
 Retrieve the control field. More...
 
function ptpHeader getControlString ()
 Retrieve the control field. More...
 
function ptpHeader setLogMessageInterval (l)
 Set the log message interval. More...
 
function ptpHeader getLogMessageInterval ()
 Retrieve the log message interval. More...
 
function ptpHeader getLogMessageIntervalString ()
 Retrieve the log message interval. More...
 
function ptpHeader fill (args, pre)
 Set all members of the ip header. More...
 
function ptpHeader get (pre)
 Retrieve the values of all members. More...
 
function ptpHeader getString ()
 Retrieve the values of all members. More...
 
function ptpHeader resolveNextHeader ()
 Resolve which header comes after this one (in a packet). More...
 
function ptpHeader setDefaultNamedArgs (pre, namedArgs, nextHeader, accumulatedLength)
 Change the default values for namedArguments (for fill/get). More...
 

Variables

local ptp = {}
 Ptp protocol constants.
 
local ptpHeader = {}
 Module for ptp_header struct (see headers.lua).
 
pkt getPtpPacket = packetCreate("eth", "ptp")
 Cast the packet to a layer 2 Ptp packet.
 
pkt getUdpPtpPacket = packetCreate("eth", "ip4", "udp", "ptp")
 Cast the packet to a Ptp over Udp (IP4) packet.
 

Detailed Description

Precision time protocol (PTP) utility.

Utility functions for the ptp_header struct defined in headers.lua .
Includes:

  • PTP constants
  • PTP header utility
  • Definition of PTP packets

Definition in file ptp.lua.

Function Documentation

function ptpHeader fill ( args  ,
pre   
)

Set all members of the ip header.

Per default, all members are set to default values specified in the respective set function. Optional named arguments can be used to set a member to a user-provided value.

Parameters
argsTable of named arguments. Available arguments: MessageType, Version, Length, Domain, Reserved, Flags, Correction, Reserved2, Oui, Uuid, NodePort, SequenceID, Control, LogMessageInterval
preprefix for namedArgs. Default 'ptp'.
fill() --- only default values
fill{ ptpLenght=123, ipTTL=100 } --- all members are set to default values with the exception of ptpLength
function ptpHeader get ( pre  )

Retrieve the values of all members.

Parameters
preprefix for namedArgs. Default 'ptp'.
Returns
Table of named arguments. For a list of arguments see "See also".
See Also
ptpHeader:fill
function ptpHeader getControl ( )

Retrieve the control field.

Returns
Control field as 8 bit integer.
function ptpHeader getControlString ( )

Retrieve the control field.

Returns
Control field in string format.
function ptpHeader getCorrection ( )

Retrieve the correction field.

Returns
Correction field as table two 32 bit integers { high, low }.
function ptpHeader getCorrectionString ( )

Retrieve the correction field.

Returns
Correction field in string format.
function ptpHeader getDomain ( )

Retrieve the domain.

Returns
Domain as 8 bit integer.
function ptpHeader getDomainString ( )

Retrieve the domain.

Returns
Domain in string format.
function ptpHeader getFlags ( )

Retrieve the flags.

Returns
Flags as 16 bit integer.
function ptpHeader getFlagsString ( )

Retrieve the flags.

Returns
Flags in string format.
function ptpHeader getLength ( )

Retrieve the length.

Returns
Length as 16 bit integer.
function ptpHeader getLengthString ( )

Retrieve the length.

Returns
Length in string format.
function ptpHeader getLogMessageInterval ( )

Retrieve the log message interval.

Returns
Log message interval as 8 bit integer.
function ptpHeader getLogMessageIntervalString ( )

Retrieve the log message interval.

Returns
Log message interval in string format.
function ptpHeader getMessageType ( )

Retrieve the message type.

Returns
Message type as 8 bit integer.
function ptpHeader getMessageTypeString ( )

Retrieve the message type.

Returns
Message type in string format.
function ptpHeader getNodePort ( )

Retrieve the node port.

Returns
Node port as 16 bit integer.
function ptpHeader getNodePortString ( )

Retrieve the node port.

Returns
Node port in string format.
function ptpHeader getOui ( )

Retrieve the oui.

Returns
Oui as 24 bit integer.
function ptpHeader getOuiString ( )

Retrieve the oui.

Returns
Oui in string format.
function ptpHeader getReserved ( )

Retrieve the reserved field.

Returns
Reserved field as 8 bit integer.
function ptpHeader getReserved2 ( )

Retrieve the reserved2 field.

Returns
Reserved2 field as 32 bit integer.
function ptpHeader getReserved2String ( )

Retrieve the reserved2 field.

Returns
Reserved2 field in string format.
function ptpHeader getReservedString ( )

Retrieve the reserved field.

Returns
Reserved field in string format.
function ptpHeader getSequenceID ( )

Retrieve the sequence ID.

Returns
Sequence ID as 16 bit integer.
function ptpHeader getSequenceIDString ( )

Retrieve the sequence ID.

Returns
Sequence ID in string format.
function ptpHeader getString ( )

Retrieve the values of all members.

Returns
Values in string format.
function ptpHeader getUuid ( )

Retrieve the Uuid.

Returns
Uuid as table of two integers { high, low }, high is an 8 bit integer, low 32 bit integer.
function ptpHeader getUuidString ( )

Retrieve the Uuid.

Returns
Uuid in string format.
function ptpHeader getVersion ( )

Retrieve the version.

Returns
Version as 8 bit integer.
function ptpHeader getVersionString ( )

Retrieve the version.

Returns
Version in string format.
function ptpHeader resolveNextHeader ( )

Resolve which header comes after this one (in a packet).

For instance: in tcp/udp based on the ports. This function must exist and is only used when get/dump is executed on an unknown (mbuf not yet casted to e.g. tcpv6 packet) packet (mbuf)

Returns
String next header (e.g. 'udp', 'icmp', nil)
function ptpHeader setControl ( )

Set the control field.

Parameters
cControl field as 8 bit integer.
function ptpHeader setCorrection ( )

Set the correction field.

Parameters
cCorrection field as table of two 32 bit integers { high, low }.
Todo:
find something better for this, 64 bit seems to be trouble for lua? c = { high32bit, low32bit }
function ptpHeader setDefaultNamedArgs ( pre  ,
namedArgs  ,
nextHeader  ,
accumulatedLength   
)

Change the default values for namedArguments (for fill/get).

This can be used to for instance calculate a length value based on the total packet length. See proto/ip4.setDefaultNamedArgs as an example. This function must exist and is only used by packet.fill.

Parameters
preThe prefix used for the namedArgs, e.g. 'ptp'
namedArgsTable of named arguments (see See Also)
nextHeaderThe header following after this header in a packet
accumulatedLengthThe so far accumulated length for previous headers in a packet
Returns
Table of namedArgs
See Also
ptpHeader:fill
function ptpHeader setDomain ( )

Set the domain.

Parameters
dDomain as 8 bit integer.
function ptpHeader setFlags ( )

Set the flags.

Parameters
fFlags as 16 bit integer.
function ptpHeader setLength ( )

Set the length.

Parameters
lLength as 16 bit integer.
function ptpHeader setLogMessageInterval ( )

Set the log message interval.

Parameters
lLog message interval as 8 bit integer.
function ptpHeader setMessageType ( mt  )

Set the message type.

Parameters
mtMessage type as 8 bit integer.
function ptpHeader setNodePort ( )

Set the node port.

Parameters
pNode port as 16 bit integer.
function ptpHeader setOui ( int  )

Set the oui.

Parameters
intOui as 24 bit integer.
function ptpHeader setReserved ( uint8  )

Set the reserved field.

Parameters
uint8Reserved as 8 bit integer.
function ptpHeader setReserved2 ( uint32  )

Set the reserved2 field.

Parameters
uint32Reserved2 as 32 bit integer.
function ptpHeader setSequenceID ( )

Set the sequence ID.

Parameters
sSequence ID as 16 bit integer.
function ptpHeader setUuid ( int  )

Set the uuid.

Parameters
intUuis as table of two integers { high, low }, high as 8 bit integer and low as 32 bit integer.
Todo:
same problem as with correction field c = { high8bit, low32bit }
function ptpHeader setVersion ( )

Set the version.

Parameters
vVersion as 8 bit integer.