[Spread-users] RE: TimeLag in Recognising Groups

Abhishek Sipani abhisheks at bsil.com
Mon Nov 29 00:50:48 EST 2004


Just looked into it with ur details..Actually its the difference between
SAFE_MESS and AGREED_MESS..when i receive with the service type set to
SAFE_MESS the lag is there. On change of the parameter of m_service_type to
AGREED_MESS that lag seems to disappear.But then i am calling a SP_receive
only once in a thread and based on the received parameters i am doing a
check and updating.Now i want to have my service type as SAFE_MESS when
transmitting messages. I can do with an AGREED_MESS during the join
issues(hence the flag in the code below)..Please tell me what is it that i
am missing here?
The code below gives a considerable time lag.Will be glad if some one can
help me in optimising the code as well.

int  Receive(char * out_Buffer, char* out_SenderName)
{
	//receives all messages-membership and regular message.
	char recv_mess[MESSAGE_LENGTH];
	int ret_val_receive;
	try
	{
		if(flag)//flag has been set to true in the constructor
		m_service_type=AGREED_MESS;
		else
		m_service_type=SAFE_MESS;
		ret_val_receive=SP_receive(m_Mbox, &m_service_type, m_Sender,
m_Max_Groups, &m_Num_Groups, m_TargetGroups, 							 &m_Mess_Type,
&m_Endian_Mismatch, sizeof(recv_mess), recv_mess);
		flag=FALSE;
		//check if the invalid receive was due to service_type error
		if(ret_val_receive<0)
		{
			//if the error in receive was due to short size of groups or buffer,
accept the truncated message

if((ret_val_receive==GROUPS_TOO_SHORT)||(ret_val_receive==BUFFER_TOO_SHORT))
			{
				m_service_type=DROP_RECV;
				ret_val_receive=SP_receive(m_Mbox, (service*)m_service_type, m_Sender,
m_Max_Groups, &m_Num_Groups, 							m_TargetGroups, &m_Mess_Type,
&m_Endian_Mismatch, sizeof(recv_mess), recv_mess);
			}
			else
			{
				return -1;
			}
		}
			//check for regular message types
			if(Is_regular_mess(m_service_type))
			{
				char * szSender_Name;
				szSender_Name=new char[100];
				char Delimiter1[2];
				char MachineName[100];
				//obtain the name of the sender from the received message
				sscanf(m_Sender,"%[#]%[^#]%[#]%s",&Delimiter1, _T(szSender_Name),
&Delimiter1, MachineName);
				strcpy(out_SenderName,szSender_Name);
				strcpy(out_Buffer,_T(recv_mess));
				out_Buffer[ret_val_receive]='\0';
				return 0;
			}
			//check for membership messages
			else if(Is_membership_mess(m_service_type))
			{
				//if the message is of regular membership type
				if(Is_reg_memb_mess(m_service_type))
				{
					char * vs_members;//to hold the name of the sender of the message
received in Spread format
					char  szSender_Name[100];//to hold the name of the sender of the
message received
					int num_bytes;
					group_id	*grp_id;
					int32		*num_vs;
					//takes the offset length from the message received by the spread
					num_bytes=SP_get_gid_offset_memb_mess();
					grp_id = (group_id *)&recv_mess[num_bytes];
					num_bytes += sizeof( group_id );
					num_bytes = SP_get_num_vs_offset_memb_mess();
					num_vs = (int32 *)&recv_mess[num_bytes];
					num_bytes += sizeof( int32 );
					num_bytes=SP_get_vs_set_offset_memb_mess();
					vs_members=&recv_mess[num_bytes];
					char Delimiter1[2];
					char MachineName[100];
					sscanf(vs_members,"%[#]%[^#]%[#]%s",&Delimiter1, _T(szSender_Name),
&Delimiter1, MachineName);
					strcpy(out_SenderName,szSender_Name);
					strcpy(out_Buffer,_T(m_Sender));
				 		if(Is_caused_join_mess(m_service_type))
						{
							return 1;
						}
						else if(Is_caused_leave_mess(m_service_type))
						{
							return 2;
						}
						else if(Is_caused_disconnect_mess(m_service_type))
						{
							return 3;
						}
						else if(Is_caused_network_mess(m_service_type))
						{
							return 4;
						}

				}
				else
				{
					return -1;
				}
		}//check for membership message ends
		else
		{
			return -1;
		}
	}//try ends
	catch(...)
	{
		ScopedGuardLock sglErrorMsg(m_ErrorMsgLock);
		char tempString[1024];
		sprintf(tempString, "%s. GetlastError(): %d.\0",
			"Caught an Exception!! Spread::Receive()",
			GetLastError());
		strcat(m_LastErrorMsg, tempString);
		return -1;
	}
}

Abhishek Sipani,
Blue Star Infotech.
Phone:(o)-91-22-569 56969
      (direct)-91-22-569 56966
      (m)    98204 51504
--------------------------------------------
"When Life offers you Lemons, Learn to make Lemonade"


-----Original Message-----
From: Ryan Caudy [mailto:rcaudy at gmail.com]
Sent: Friday, November 26, 2004 9:11 AM
To: abhisheks at bsil.com
Cc: jonathan at cnds.jhu.edu; spread-users at lists.spread.org
Subject: Re: TimeLag in Recognising Groups


This certainly doesn't sound usual... a Spread group is "recognized"
when it is created, by a join when the group doesn't exist.  This
simply requires delivery of one AGREED message.

What exactly are you doing to start up your Spread daemons and start
the clients?  What's the time between when you call SP_join, and when
you receive the CAUSED_BY_JOIN regular membership message?  What I
mean is something like:

struct timeval t1, t2;
gettimeofday(&t1, NULL);
SP_join(mbox, group_name);
SP_receive(/*ARGS*/);
/* Make sure it's the right CAUSED_BY_JOIN message. */
gettimeofday(&t2, NULL);
printf("Time to join: %f\n", t2.tv_sec - t1.tv_sec + (t2.tv_usec -
t1.tv_usec)/1000000);

If you have your Spread network up and running (i.e. with a regular
membership configuration installed) before you start the clients, the
time should be *very* short.

Cheers,
Ryan

On Thu, 25 Nov 2004 20:34:08 +0530, Abhishek Sipani <abhisheks at bsil.com>
wrote:
> Hi all,
> It seems am just running into problems daily with spread.As soon as i
almost
> finish fixing one a new one springs up.
> Here is the new problem :
> I have a config file which reads like
> Spread_Segment  233.1.1.1:4803 {
>
>         Ravikiran       192.168.11.97
>         HP187           192.168.11.77
>         Shabu           192.168.11.40
>         Sham            192.168.11.134
>         Abhishek        192.168.11.53
> }
> i also have an mfc client for communication . Now am trying to run one
> client on Shabu(192.168.11.40) and the same on another machine
> Abhishek(192.168.11.53). Both have private_group names similar to the
> machine names
> i.e. #Shabu#Shabu and #Abhishek#Abhishek..Now my problem is it takes an
> enormously long time for the spread daemon to recognise these groups and
no
> communication happens between these clients until it does that. Once done,
> there are no issues with commuincation.
> After this there are no apparent problems:
> ************************************
> Membership id is ( -1062728907, 1101394405)
> --------------------
> Configuration at Abhishek is:
> Num Segments 1
>         1       233.1.1.1         4803
>                 Abhishek                192.168.11.53
> ====================
> Membership id is ( -1062728920, 1101394677)
> --------------------
> Configuration at Abhishek is:
> Num Segments 1
>         2       233.1.1.1         4803
>                 Shabu                   192.168.11.40
>                 Abhishek                192.168.11.53
> ====================
> ++++++++++++++++++++++
> Num of groups: 1
> [1] group FirstGroupName with 2 members:
>         [1] #Abhishek#Abhishek
>         [2] #Shabu#Shabu
> ----------------------
> ****************************************************************
> Moreover if some other client joins in the process,it is joined in quickly
> and the communication happens smoothly again.Am using SAFE_MESS.Would like
> to add also here that if there are clients being added to the group(which
is
> same in all cases)and trying to connect to the spread daemon on the same
> machine, there are no time lags.Please advise.
> Abhishek Sipani,
> Blue Star Infotech.
> Phone:(o)-91-22-569 56969
>       (direct)-91-22-569 56966
>       (m)    98204 51504
> --------------------------------------------
> "When Life offers you Lemons, Learn to make Lemonade"
>
> -----Original Message-----
> From: Ryan Caudy [mailto:rcaudy at gmail.com]
> Sent: Thursday, November 25, 2004 9:54 AM
> To: abhisheks at bsil.com
> Cc: spread-users at lists.spread.org
> Subject: Re: [Spread-users] Small Help Needed
>
> I don't know the specific Spread library that your using... is it a
> wrapper around the C version, or a port?  Regardless, the maximum
> length of the private name associated with a Spread connection/mailbox
> is 10, without changing definitions in the daemon source code.
>
> Cheers,
> Ryan
>
> On Wed, 24 Nov 2004 19:23:23 +0530, Abhishek Sipani <abhisheks at bsil.com>
> wrote:
> > Hi,
> > I have been using spread for some research purpose. Would like to know
if
> > there is an upper limit on the UserName character length i provide..
> > i.e.
> > I do
> >         sprintf(Spread_name,"4803 at 192.168.11.40");
> >         int ret_val_connect;
> >         m_User.GetWindowText(User,80);
> >         ret_val_connect=sp.Connect(Spread_name,User);
> >         if(ret_val_connect<0)
> >                 AfxMessageBox("Unable to Connect");
> >         else
> >                 AfxMessageBox("Connected");
> >
> > this works fine..but if i provide a length more than 10 characters say
> > "ABCDEFGHIJKLM" as user name the call
> >         ret_val_connect= SP_connect(in_SpreadName, in_ConnectionName, 0,
> 1,
> > &m_Mbox, m_PrivateGroup );
> > returns m_PrivateGroup as "#ABCDEFGHIJ#SpreadMachineName"
> >
> > How do i prevent this from getting truncated?Have tried going through
the
> > enormous archives of discussions but of no avail. Please advice as i am
> > dealing with data that have names far greater than 10 characters. Am
> > relatively new to spread so some help here will be of immense help.
> >
> > Abhishek Sipani,
> > Blue Star Infotech.
> > Phone:(o)-91-22-569 56969
> >       (direct)-91-22-569 56966
> >       (m)    98204 51504
> > --------------------------------------------
> > "When Life offers you Lemons, Learn to make Lemonade"
> >
> > _______________________________________________
> > Spread-users mailing list
> > Spread-users at lists.spread.org
> > http://lists.spread.org/mailman/listinfo/spread-users
> >
>
> --
> ---------------------------------------------------------------------
> Ryan W. Caudy
> <rcaudy at gmail.com>
> ---------------------------------------------------------------------
> Bloomberg L.P.
> <rcaudy1 at bloomberg.net>
> ---------------------------------------------------------------------
> [Alumnus]
> <caudy at cnds.jhu.edu>
> Center for Networking and Distributed Systems
> Department of Computer Science
> Johns Hopkins University
> ---------------------------------------------------------------------
>
>


--
---------------------------------------------------------------------
Ryan W. Caudy
<rcaudy at gmail.com>
---------------------------------------------------------------------
Bloomberg L.P.
<rcaudy1 at bloomberg.net>
---------------------------------------------------------------------
[Alumnus]
<caudy at cnds.jhu.edu>
Center for Networking and Distributed Systems
Department of Computer Science
Johns Hopkins University
---------------------------------------------------------------------





More information about the Spread-users mailing list