Friday Ppt New

download Friday Ppt New

of 48

  • date post

    09-Apr-2015
  • Category

    Documents

  • view

    172
  • download

    4

Embed Size (px)

Transcript of Friday Ppt New

Prepared by R.NARENDRANATH REDDY 08H61D5515

IEEE Paper complainty Now a days all home appliances are becoming multi-

functional and the system that control these functions is also becoming larger . y Time synchronization for these multi functional A/V devices is becoming a key requirement especially in the cases of event management. y To realize a desired stable time base system various methods can be adopted like 1.RTC incorporated in a Micro Processor unit . 2. Radio controlled Clock 3. Global Positioning System(GPS) 4. A method of obtaining time data from an upper level SNTP server.

Structure of sntp for home use

y For the radio wave clock, the number of transmitting

stations and the regions that can receive the service from certain stations are limited, and further, radio waves can be received only at or near a window. y For GPS(global positioning system), the system will work only in places at which three or more GPS satellites are visible in the open sky, and thus it does not suit general domestic applications. y So above two methods cannot be used, a communication tool to connect to the Internet is supplied in order to obtain the time data from an upper level SNTP server.

Structure of SNTP for this projectAudio video system Target Board

Sntp client LAN Event manager Event

Sntp server

internet

Remote NTP server

SNTPy Simple

network time protocol is used to synchronize computer clock with standard time(UTC(universal co-ordinated time) via internet is application layer protocol dedicated for time synchronization . and it is

y SNTP

TCP/IP modelApplication layer (SNTP) Transport layer (UDP) Network layer (IP) Data Link layer Physical layer

(my project)

these layers implemented in Linux -2.6 kernel

PROJECT MODULES1.Event Management Program . 2.SNTP client . 3.SNTP server . 3.Porting movie media player to target board.

DEVELOPMENT ENVIRONMENTy y y y y y

1.Programming Language : C. 2.Operating System: LINUX. 3. LINUX Kernel Version: 2.6. 4.Compiler : ARM-LINUX-GCC for target board. 5.Debugging Tools :arm-linux-gdb (Gnu Debugger). 6.Target Board : Mini S3c 2440A(friendly arm board) .

.

SNTP TIME STAMP FORMATy Sntp uses two fixed point time stamp formats

1.long format(64 bit) with integer(decimal)between bits 31 or 32 2.short format(32 bit) with with decimalbetween bits 15 and 16.

For that 64 bit we use following structure typedef struct { union { unsigned long int Xl_ui; long int Xl_i; } Ul_i; union { unsigned long int Xl_uf; long int Xl_f; } Ul_f; }l_fp; y For 32 bit format we just select unsigned long int root delay. unsigned long int root_dispersion.

SNTP MESSAGE FORMAT

SNTP message format is in big-endian mode that is network byte order for this we have htonl(),htons(),ntohl(),ntohs() funtions which converts host byte order(little Endian) to network byte order(big Endian mode) and vice versa.Big Endian modeA C A C B D B D

Little EndianB D B D A C A C

Description of LI fieldy LI

Value Meaning ------------------------------------------------------00 0 no warning 01 1 last minute has 61 seconds 10 2 last minute has 59 seconds 11 3 alarm condition y Leap Indicator (LI): This is a two-bit code warning of an impending leap second to be inserted/deleted in the last minute of the current day, with bit 0 and bit 1, respectively, coded as above

Mode FieldMode: This is a three-bit integer indicating the mode, with values defined as follows: Mode Meaning -------------------------------------------------0 reserved 1 symmetric active 2 symmetric passive 3 client 4 server 5 broadcast 6 reserved for NTP control message 7 reserved for private use

Stratum Fieldy Stratum: This is a eight-bit unsigned integer indicating the

stratum level of the local clock, with values defined as follows: Stratum Meaning ---------------------------------------------0 ------------> unspecified or unavailable 1 -----------> primary reference (e.g., radio clock) 2-15 ------------> secondary reference (via NTP or SNTP) 16-255 -----------> reserved

Hierarchical layered systemStratum 2 to 15National standard time (Radio clock) NTP Secondary server 1 NTP Secondary server 2

stratum1SNTP server

SNTP client

y Reference Identifier: This is a 32-bit bitstring identifying the particular y

y

y

y

reference source Root Dispersion: This is a 32-bit unsigned fixed-point number indicating the nominal error relative to the primary reference source, in seconds with fraction point between bits 15 and 16. Root Delay: This is a 32-bit signed fixed-point number indicating the total roundtrip delay to the primary reference source, in seconds with fraction point between bits 15 and 16. Precision: This is an eight-bit signed integer indicating the precision of the local clock, in seconds to the nearest power of two. The values that normally appear in this field range from -6 for mains-frequency clocks to -20 for microsecond clocks found in some workstations. Poll Interval: This is an eight-bit signed integer indicating the maximum interval between successive messages, in seconds to the nearest power of two. The values that can appear in this field presently range from 4 (16 s) to 14 (16284 s); however, most applications use only the sub-range 6 (64 s) to 10 (1024 s).

y Reference Timestamp: This is the time at which the local clock was last set or corrected, in 64-bit timestamp format. y Originate Timestamp: This is the time at which the request departed the client for the server, in 64-bit timestamp format. y Receive Timestamp: This is the time at which the request arrived at the server, in 64-bit timestamp format. y Transmit Timestamp: This is the time at which the reply departed the server for the client, in 64-bit timestamp format. y Authenticator (optional): When the NTP authentication scheme is implemented, the Key Identifier and Message Digest fields contain the message authentication code (MAC)

Flow chart for SNTP clientEMP Set the RTC start Get the offset and delay

enter input options

Is p==0

Send request to server Extract user entered input Is it valid Poll the sntp server

user input from command line is in the form sntpdate [-dvqgh] [-p poll-time] [-t timeout] server [...] -d Enable the debugging mode. Information useful for general debugging will be printed. Be verbose print current version of SNTP. samples: Specify the number of poll-times to be acquired from each server as the integer samples. The default is 5. Query only - don't set the clock. Normally, the client ignore a server if the offset exceeds a 1000 s sanity limit. This option overrides this limit and allows the offset to be any value without restriction, by it this mode is on.

-v -p -q -g

-t

timeoutSpecify the maximum time waiting for a server response as the value timeout, in seconds. The default is 1 second, a value suitable for polling across a LAN. -h Print usage and this is for help to user how to enter inputs.

y A number of poll-times are obtained from

server is specified. An average of the offsets is obtain and local date and time are set using settimeofday() according to this average . y Input options are parsed and extracted by getopt() function which returns character after operator and optarg gives that character and optind gives string after this character. y Host ( SNTP server)is found by getaddrinfo() funtion. y Keep Polling the server with sending request to server until poll times reaches zero. So accuracy and reliability depends on poll times.

y Initially send request with all zeros except li ,mode,Vn

and transmit time stamp. y Initially li field is 0x3 and version no is 4 and mode is 3 for SNTP client and transmit time stamp contains time when request is sent. y SNTP Server copies this transmit time field to originate time stamp field, and sends transmit time stamp field with time when it sent and also sends receive time stamp field with time when it is received. y As soon as SNTP client receives reply from SNTPserver it will generate destination time stamp with time when it is received reply from SNTP server. with this we can calculate offset and round trip delay.

SNTP CLIENT AND SERVER OPERATIONS

Timestamp Name ID When Generated -----------------------------------------------------------Originate Timestamp T1 time request sent by client Receive Timestamp T2 time request received by server Transmit Timestamp T3 time reply sent by server Destination Timestamp T4 time reply received by client The roundtrip delay (d) and local clock offset (t )are defined as d = (T4 - T1) - (T2 - T3) t = ((T2 - T1) + (T3 - T4)) / 2.

ROUNDTRIP DELAY AND LOCAL CLOCK OFFSET CALCULATIONS in client

y For exampleSNTP client SNTP server

send request at 8.00 received request at 9.00 (T1=28800 seconds) (T2=32400 seconds) reply received at reply send at (T4=28840 seconds) (T3=32420 seconds) d=(28840 28800)-(32400 -32420)=60 seconds t=((32400-28800)+(32420-28840))/2=3590. so client will add (3590 +60) seconds to client side current RTC so client RTC is same as server RTC.

y So we calculate average offset and delay for poll-times and

these are added to current client side RTC ,current RTC is given by gettimeofday() funtion.y With New corrected time we can set the RTC by using

settimeofday() funtion. if we are a super user . Super user mode is found by getuid() funtion.

Event management program(EMP)y Time base event management program deals with the

playing the events based on the user requirements. y In this project we have 3 events like 1 audiofile,1 video files, buzzer. So, time base event management pro