KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > net > ntp > NtpV3Packet


1 package org.apache.commons.net.ntp;
2 /*
3  * Copyright 2001-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 import java.net.DatagramPacket JavaDoc;
19
20 /**
21  * Interface for a NtpV3Packet with get/set methods corresponding to the fields
22  * in the NTP Data Message Header described in RFC 1305.
23  *
24  * @author Naz Irizarry, MITRE Corp
25  * @author Jason Mathews, MITRE Corp
26  * @version $Revision: 165675 $ $Date: 2005-05-02 15:09:55 -0500 (Mon, 02 May 2005) $
27  */

28 public interface NtpV3Packet
29 {
30
31     /**
32      * Standard NTP UDP port
33      */

34     public static final int NTP_PORT = 123;
35
36     public static final int LI_NO_WARNING = 0;
37     public static final int LI_LAST_MINUTE_HAS_61_SECONDS = 1;
38     public static final int LI_LAST_MINUTE_HAS_59_SECONDS = 2;
39     public static final int LI_ALARM_CONDITION = 3;
40
41     /* mode options */
42     public static final int MODE_RESERVED = 0;
43     public static final int MODE_SYMMETRIC_ACTIVE = 1;
44     public static final int MODE_SYMMETRIC_PASSIVE = 2;
45     public static final int MODE_CLIENT = 3;
46     public static final int MODE_SERVER = 4;
47     public static final int MODE_BROADCAST = 5;
48     public static final int MODE_CONTROL_MESSAGE = 6;
49     public static final int MODE_PRIVATE = 7;
50
51     public static final int NTP_MINPOLL = 4; // 16 seconds
52
public static final int NTP_MAXPOLL = 14; // 16284 seconds
53

54     public static final int NTP_MINCLOCK = 1;
55     public static final int NTP_MAXCLOCK = 10;
56
57     public static final int VERSION_3 = 3;
58     public static final int VERSION_4 = 4;
59
60     /* possible getType values such that other time-related protocols can
61      * have its information represented as NTP packets
62      */

63     public static final String JavaDoc TYPE_NTP = "NTP"; // RFC-1305/2030
64
public static final String JavaDoc TYPE_ICMP = "ICMP"; // RFC-792
65
public static final String JavaDoc TYPE_TIME = "TIME"; // RFC-868
66
public static final String JavaDoc TYPE_DAYTIME = "DAYTIME"; // RFC-867
67

68     /**
69      * @return a datagram packet with the NTP parts already filled in
70      */

71     public DatagramPacket JavaDoc getDatagramPacket();
72
73     /**
74      * Set the contents of this object from the datagram packet
75      */

76     public void setDatagramPacket(DatagramPacket JavaDoc dp);
77
78     /**
79      * @return leap indicator as defined in RFC-1305
80      */

81     public int getLeapIndicator();
82
83     /**
84      * Set leap indicator.
85      * @param li - leap indicator code
86      */

87     public void setLeapIndicator(int li);
88
89     /**
90      * @return mode as defined in RFC-1305
91      */

92     public int getMode();
93
94     /**
95      * @return mode as human readable string; e.g. 3=Client
96      */

97     public String JavaDoc getModeName();
98
99     /**
100      * Set mode as defined in RFC-1305
101      */

102     public void setMode(int mode);
103
104     /**
105      * @return poll interval as defined in RFC-1305.
106      * Field range between NTP_MINPOLL and NTP_MAXPOLL.
107      */

108     public int getPoll();
109
110     /**
111      * Set poll interval as defined in RFC-1305.
112      * Field range between NTP_MINPOLL and NTP_MAXPOLL.
113      */

114     public void setPoll(int poll);
115
116     /**
117      * @return precision as defined in RFC-1305
118      */

119     public int getPrecision();
120
121     /**
122      * @return root delay as defined in RFC-1305
123      */

124     public int getRootDelay();
125
126     /**
127      * @return root delay in milliseconds
128      */

129     public double getRootDelayInMillisDouble();
130
131     /**
132      * @return root dispersion as defined in RFC-1305
133      */

134     public int getRootDispersion();
135
136     /**
137      * @return root dispersion in milliseconds
138      */

139     public long getRootDispersionInMillis();
140
141     /**
142      * @return root dispersion in milliseconds
143      */

144     public double getRootDispersionInMillisDouble();
145
146     /**
147      * @return version as defined in RFC-1305
148      */

149     public int getVersion();
150
151     /**
152      * Set version as defined in RFC-1305
153      */

154     public void setVersion(int mode);
155
156     /**
157      * @return stratum as defined in RFC-1305
158      */

159     public int getStratum();
160
161     /**
162      * Set stratum as defined in RFC-1305
163      */

164     public void setStratum(int stratum);
165
166     /**
167      * @return the reference id string
168      */

169     public String JavaDoc getReferenceIdString();
170
171     /**
172      * @return the reference id (32-bit code) as defined in RFC-1305
173      */

174     public int getReferenceId();
175
176     /**
177      * Set reference clock identifier field.
178      * @param refId
179      */

180     public void setReferenceId(int refId);
181
182     /**
183      * @return the transmit timestamp as defined in RFC-1305
184      */

185     public TimeStamp getTransmitTimeStamp();
186
187     /**
188      * @return the reference time as defined in RFC-1305
189      */

190     public TimeStamp getReferenceTimeStamp();
191
192     /**
193      * @return the originate time as defined in RFC-1305
194      */

195     public TimeStamp getOriginateTimeStamp();
196
197     /**
198      * @return the receive time as defined in RFC-1305
199      */

200     public TimeStamp getReceiveTimeStamp();
201
202     /**
203      * Set the transmit timestamp given NTP TimeStamp object.
204      * @param ts - timestamp
205      */

206     public void setTransmitTime(TimeStamp ts);
207
208     /**
209      * Set the reference timestamp given NTP TimeStamp object.
210      * @param ts - timestamp
211      */

212     public void setReferenceTime(TimeStamp ts);
213
214     /**
215      * Set originate timestamp given NTP TimeStamp object.
216      * @param ts - timestamp
217      */

218     public void setOriginateTimeStamp(TimeStamp ts);
219
220     /**
221      * Set receive timestamp given NTP TimeStamp object.
222      * @param ts - timestamp
223      */

224     public void setReceiveTimeStamp(TimeStamp ts);
225
226     /**
227      * Return type of time packet. The values (e.g. NTP, TIME, ICMP, ...)
228      * correspond to the protocol used to obtain the timing information.
229      *
230      * @return packet type string identifier
231      */

232     public String JavaDoc getType();
233
234 }
235
Popular Tags