Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
hi,
I want to make an application that receive broadcast data from NSE in the form of packet, then i have found this data in hex format
04-20-00-01-01-20-1A-04-59-5A-2A-2A-31-32-33-00-40-00-05-3A-32-0D-5B-20-20-1C-28-40-28-03-02-F6-A7-24-00-80-C0-4C-01-22-90-34-20-A0-02-01-D2-00-64-0C-2B-D7-00-01-00-02-00-2C-4B-B9-00-00-2F-B7-2D-60-E1-45-40-0D-25-40-A5-59-40-46-7B-00-35-00-02-03-46-40-75-B2-40-E4-60-00-41-8E-2F-AD-A0-2E-01-86-5F-A8-00-04-7E-09-D8-5D-A3-00-A8-60-2E-1D-FB-5F-9E-00-0A-7E-00-71-5D-B7-41-DC-61-1D-83-40-2D-C1-BE-04-24-5D-C6-A1-1E-0F-A2-40-2D-CB-A0-EE-07-D2-40-2D-D0-BC-03-00-00-41-08-A8-B8-80-1F-10-2A-FC-E2-36-30-0C-40-0D-25-5D-C0-00-0C-01-2E-AE-0D-B2-83-4C-04-02-77-29-00-05-3C-DC-7E-01-88-40-11-08-83-4F-05-3B-DC-36-03-4C-40-D7-05-3C-B9-A2-2C-42-A7-05-3C-A0-C0-2D-AB-5D-87-C1-FD-11-40-2D-3C-C0-5D-04-40-2D-0F-DD-7D-00-2E-3D-68-C4-3D-0F-40-2D-9A-A0-5E-02-03-40-2D-CC-C0-5C-40-8E-3E-4E-C0-BD-1F-40-2D-80-DC-01-00-40-D3-83-A0-1F-D2-AC-40-9D-00-00-76-73-96-00-0D-6A-03-A7-05-7A-58-00-0E-09-D8-11-00-00-68-11-00-00-00-00-E0-FA-12-00-28-C2-42-7E-98-00-01-00-21-01-00-00-00-00-00-00-E2-00-06-00-01-00-00-00-D9-8B-41-7E-88-10-47-7E-80-00-00-00-28-FB-12-00-3C-C2-42-7E-E9-C1-42-7E-08-FC-12-00-98-00-01-00-00-00-00-00-00-00-00-00-01-00-00-00-00-00-00-00-F8-FA-12-00-00-00-04-60-24-FC-12-00-8F-04-44-7E-38-FB-12-00-01-B4-42-7E-D8-93-61-00-00-00-00-00-00-00-00-00-02-01-00-00-7C-FB-12-00-D4-13-73-74-B5-00-01-00-00-00-00-00-01-00-00-00-D9-13-73-74-00-00-00-00-00-E0-FD-7F-02-01-00-00-00-00-3D-00-B5-00-01-00-50-FB-12-00-01-6E-02-EE-C4-FB-12-00-A6-F1-75-74-E0-13-73-74-FF-FF-FF-FF-D9-13-73-74-72-B3-42-7E-00-00-00-00-01-00-00-00-18-FC-12-00-00-00-00-00-B4-FC-12-00
but main problem is that i don't know how to parse this data and how to know that what is the meaning of characters and how to convert this data in to useful manner , i have read out NSE document which tells that first char is tells data is compressed or not but i don't know that which of these is first and last, If any one can understand my problem and experience in these type of application please help me and suggest what i have to do so understand this string

please mail me at this e-mail id-
[EMail address removed]

Thanks in Advance
Abhishek Singh
Posted
Updated 24-Jan-17 19:40pm
v3
Comments
Goutam Patra 9-Dec-10 1:58am    
Dont post your email address to avoid spam. If anyone replies then you will get a email notification.
Dave Kreskowiak 9-Dec-10 10:19am    
It's not a string. It's an array of bytes. If the documentation says that the first byte is a compression type of some kind, that would probably be at offset 0, or index 0 in the byte array.
kkprocks123 5-Jul-11 7:53am    
You Have to use the LZO compression & decompression method .Hi can you send me the source code of your application.
kkprocks123 5-Jul-11 7:54am    
You Have to use the LZO compression & decompression method .Hi can you send me the source code of your application. MY email is kiran_pandey2001@yahoo.com
dewang123 5-Apr-19 0:40am    
Do you have a working solution for this?

*
 * File:   main.c
 * Author: root
 *
 * Created on May 17, 2011, 1:51 PM
 */

#include
#include
#include
#include
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "Include/lzo1z.h"

#define MAX_LEN 1024;

int main(int argc, char **argv)
{
    
    int sock;
    int flag_on = 1;
    struct sockaddr_in mc_addr;
    unsigned char recv_str[1024];
    int  recv_len;
    struct ip_mreq mc_req;
    char* mc_addr_str;
    unsigned short mc_port;
    struct sockaddr_in from_addr;
    unsigned int from_len;
    mc_addr_str = "233.1.1.11";
    mc_port     = 34330;
      
    if ((sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
    {
        perror("socket() failed");
        exit(1);
    }

    if ((setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &flag_on, sizeof(flag_on))) < 0)
    {
        perror("setsockopt() failed");
        exit(1);
    }
    
    memset(&mc_addr,0,sizeof(mc_addr));
    mc_addr.sin_family = AF_INET;
    mc_addr.sin_addr.s_addr = htonl(INADDR_ANY);
    mc_addr.sin_port = htons(mc_port);
    
    if((bind(sock,(struct sockaddr *) &mc_addr,sizeof(mc_addr))) < 0)
    {
        perror("bind() failed");
        exit(1);
    }
    
    mc_req.imr_multiaddr.s_addr = inet_addr(mc_addr_str);
    mc_req.imr_interface.s_addr = htonl(INADDR_ANY);
    
    if((setsockopt(sock,IPPROTO_IP,IP_ADD_MEMBERSHIP,(void*) &mc_req,sizeof(mc_req))) < 0)
    {
        perror("setsockopt() failed");
        exit(1);
    }
    
    
    for(;;)
    {
        memset(recv_str,0,sizeof(recv_str));
        from_len = sizeof(from_addr);
        memset(&from_addr,0,from_len);
        
       if((recv_len = recvfrom(sock, recv_str,1024,0,(struct sockaddr*)&mc_addr, &from_len))<0)                
        {
            perror("recvfrom() failed");
            exit(1);
        }
        short compLen=0;
        short NOP=0;
        memcpy(&compLen,recv_str+4,2);
        compLen = ntohs(compLen);
        if(compLen > 0)
        {
            memcpy(&NOP,recv_str+2,2);
            NOP=ntohs(NOP);
            int i=0;
           
            
            for(i=0;i<nop;i++)>
            {
                unsigned char src[compLen];
                memcpy(&src,recv_str+6,compLen);
                short src_len = compLen;
                unsigned int dst_len = 1024;
                unsigned char dst[1024];
                int rCode;
                unsigned int eCode=0;
                               
                
                rCode = lzo1z_decompress((lzo_bytep) src,(lzo_uint)src_len,(lzo_bytep) dst,(lzo_uintp)&dst_len,0);
                
               
            }
        }
    }
    
    if((setsockopt(sock, IPPROTO_IP, IP_DROP_MEMBERSHIP,(void*)&mc_req, sizeof(mc_req))) < 0)
    {
        perror("setsocketopt() failed");
        exit(1);
        
    }
    close(sock);
    return 0;
}</unistd.h></string.h></stdlib.h></stdio.h>
 
Share this answer
 
hi abhishek,
i am trying to listen nse multicast.when i set nse multicast group and port no data coming but if i change to a separate multicast group and port where i sending a test line from a simple multicast application my listener app getting that data.

so could you give sample code how to get data from nse broadcast.

Regards,
Abhirup
 
Share this answer
 
Comments
dewang123 5-Apr-19 0:40am    
Do you have a working solution for this?
neo100894 22-Apr-23 5:34am    
i too need working solution of this
please send me the code for how to get data frm NSE Broadcaster
 
Share this answer
 
Comments
dewang123 5-Apr-19 0:40am    
Do you have a working solution for this?
neo100894 22-Apr-23 5:34am    
i too need working solution of this

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900