מעבר לתוכן


תמונה

מועד ב קבלת החלטות


  • Please log in to reply
6 replies to this topic

#1 iDPWF

iDPWF

    משתמש טרי

  • רשומים
  • 17 הודעות:

פורסם 13/02/2010 - 16:06

מישהו יכול לפרסם פה פתרונות לתרגילים ו/או שחזורים?
אפשר גם במייל idpwf1 at gmail.com או בפרטי...

תודה!

It is by will alone I set my mind in motion. It is by the juice of Sapho that thoughts acquire speed, the lips acquire stains, the stains become a warning. It is by will alone I set my mind in motion.

Peter de Vries, Mentat of House Harkonnen


#2 אורח - אורח

אורח - אורח
  • אורחים

פורסם 14/02/2010 - 21:56

מישהו יכול לפרסם פה פתרונות לתרגילים ו/או שחזורים?
אפשר גם במייל idpwf1 at gmail.com או בפרטי...

תודה!


מצטרף לבקשה. אשמח אם משהו יוכל לתת קצת פרטים על מה היה בבחינה ואיך כדאי להתכונן אליה בזמן שנותר.

#3 אורח - אורח

אורח - אורח
  • אורחים

פורסם 06/06/2010 - 02:14

אתה בטוח ?

#4 אורח - אורח

אורח - אורח
  • אורחים

פורסם 06/06/2010 - 02:23

//#include "stdafx.h"
#include <string.h>

#define VALID 1
#define INVALID 0
#define A 0
#define B 1
#define ARR_SIZE 25

typedef struct
{
char cmdArr[ARR_SIZE];
int source;
}cmd_s;
typedef struct
{
char cmdArr[ARR_SIZE];
int size;
}cmd3_s;

//Global variables
cmd_s Cmd;
cmd3_s Cmd3;
static int stateOfProcess = 1;

//check the direction of the packet if the command and the request size
int checkPacket(int source, char * command, int commandSize, int *statePtr, int destinationState)
{
if(Cmd.source == source)
{
if(strncmp(Cmd.cmdArr, command, commandSize) == 0)
{
*statePtr = destinationState;
return VALID;
}
}
*statePtr = 1;
return INVALID;
}

void saveCmd3(const char sourceArr[], const int commandSize)
{
fillArr(Cmd3.cmdArr, sourceArr, commandSize);
Cmd3.size = commandSize - 1;
}

int checkState3(int *statePtr)
{
int status = (checkPacket(A, "LIST", sizeof("LIST"), statePtr, 4));

if(status == INVALID)
status = (checkPacket(A, "EXIT ", sizeof("EXIT "), statePtr, 5));
else
saveCmd3("LIST", sizeof("LIST"));

return status;
}

//check the length of the command
int getCmdLen()
{
int counter = 0;
int i;

for(i = 0; i < ARR_SIZE; i++)
{
if(Cmd.cmdArr[i] != '\0')
counter++;
}

return counter;
}

void fillArr(char destArr[], const char sourceArr[], const int commandSize)
{
memset(destArr, 0, ARR_SIZE);
memcpy(destArr, sourceArr, commandSize);
}

//check the validation of the command at the edges and the validation of the message
int checkState4(int *statePtr)
{
int commandSize = getCmdLen();
int cmd3Sise = Cmd3.size;
int secondIndex = commandSize - cmd3Sise;
char charCommand;
int i;

*statePtr = 1;

//check the validation of command at the edges
if(strncmp(&Cmd.cmdArr[0], Cmd3.cmdArr, cmd3Sise) != 0)
return INVALID;
if(strncmp(&Cmd.cmdArr[secondIndex], Cmd3.cmdArr, cmd3Sise) != 0)
return INVALID;

//check if the middle command is longer than one
if(commandSize < cmd3Sise*2 + 2)
return INVALID;

//check the validation of the message
for(i = cmd3Sise + 1; i <= secondIndex - 2 ; i++)
{
charCommand = Cmd.cmdArr[i];
if( !((charCommand >='a') && (charCommand <='z')) | ((charCommand >='0') && (charCommand <='9')) )
return INVALID;
}

*statePtr = 3;
return VALID;
}

int handleCmd()
{
//switch by choosing the current state
switch(stateOfProcess)
{
case 1:
return (checkPacket(A, "OPEN_CONNECTION", sizeof("OPEN_CONNECTION"),
&stateOfProcess, 2));
case 2:
return (checkPacket(B, "OPEN_CONNECTION_ACKED", sizeof("OPEN_CONNECTION_ACKED"),
&stateOfProcess, 3));

case 3:return (checkState3(&stateOfProcess));
case 4:return (checkState4(&stateOfProcess));
case 5:
return (checkPacket(B, "EXIT_ACKED", sizeof("EXIT_ACKED"),
&stateOfProcess, 1));

default: return INVALID;
}
}

void main()
{
//try to open conection between A and B
Cmd.source = A;
fillArr(Cmd.cmdArr, "OPEN_CONNECTION", sizeof("OPEN_CONNECTION"));
handleCmd();

Cmd.source = B;
fillArr(Cmd.cmdArr, "OPEN_CONNECTION_ACKED", sizeof("OPEN_CONNECTION_ACKED"));
handleCmd();

Cmd.source = A;
fillArr(Cmd.cmdArr, "LIST", sizeof("LIST"));
handleCmd();

Cmd.source = B;
fillArr(Cmd.cmdArr, "LIST 6575 LIST", sizeof("LIST 6575 LIST"));
handleCmd();

}
============================================================================================
// dr.cpp : Defines the entry point for the console application.
//

// stateMachine.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include <string.h>

#define VALID 1
#define INVALID 0
#define A 0
#define B 1
#define ARR_SIZE 25

typedef struct
{
char cmdArr[ARR_SIZE];
int source;
}commandStruct;
typedef struct
{
char cmdArr[ARR_SIZE];
int size;
}commandEdgesStruct;

//Global variables
commandStruct Command;
commandEdgesStruct commandEdges;
static int stateOfProcess = 1;

void fillArr(char destArr[], const char sourceArr[], const int commandSize)
{
memset(destArr, 0, ARR_SIZE);
memcpy(destArr, sourceArr, commandSize);
}

//check the direction of the packet if the command and the request size
int checkPacket(int source, char * command, int commandSize, int *statePtr, int destinationState)
{
if(Command.source == source)
{
if(strncmp(Command.cmdArr, command, commandSize) == 0)
{
*statePtr = destinationState;
return VALID;
}
}
*statePtr = 1;
return INVALID;
}

//check and save the edges command
int checkState3(int *statePtr)
{
int status = (checkPacket(A, "LIST", sizeof("LIST"), statePtr, 4));

if(status == INVALID)
status = (checkPacket(A, "EXIT ", sizeof("EXIT "), statePtr, 5));
else
{
int commandSize = sizeof("LIST");
fillArr(commandEdges.cmdArr, "LIST", commandSize);
commandEdges.size = commandSize - 1;
}

return status;
}

//check the validation of the command at the edges and the validation of the message
int checkState4(int *statePtr)
{
int commandSize = strlen(Command.cmdArr);
int cmd3Sise = commandEdges.size;
int secondIndex = commandSize - cmd3Sise;
char charCommand;
int i;

*statePtr = 1;

//check the validation of command at the edges
if(strncmp(&Command.cmdArr[0], commandEdges.cmdArr, cmd3Sise) != 0)
return INVALID;
if(strncmp(&Command.cmdArr[secondIndex], commandEdges.cmdArr, cmd3Sise) != 0)
return INVALID;

//check if the middle command is longer than one
if(commandSize < ((cmd3Sise * 2) + 2))
return INVALID;

//check the validation of the message
for(i = cmd3Sise + 1; i <= secondIndex - 2 ; i++)
{
charCommand = Command.cmdArr[i];
if( !((charCommand >='a') && (charCommand <='z')) | ((charCommand >='0') && (charCommand <='9')) )
return INVALID;
}

*statePtr = 3;
return VALID;
}

int handleCmd()
{
//switch by choosing the current state
switch(stateOfProcess)
{
case 1:
return (checkPacket(A, "OPEN_CONNECTION", sizeof("OPEN_CONNECTION"),
&stateOfProcess, 2));
case 2:
return (checkPacket(B, "OPEN_CONNECTION_ACKED", sizeof("OPEN_CONNECTION_ACKED"),
&stateOfProcess, 3));

case 3:return (checkState3(&stateOfProcess));
case 4:return (checkState4(&stateOfProcess));
case 5:
return (checkPacket(B, "EXIT_ACKED", sizeof("EXIT_ACKED"),
&stateOfProcess, 1));

default: return INVALID;
}
}

void main()
{
Command.source = A;
fillArr(Command.cmdArr, "OPEN_CONNECTION", sizeof("OPEN_CONNECTION"));
handleCmd();

Command.source = B;
fillArr(Command.cmdArr, "OPEN_CONNECTION_ACKED", sizeof("OPEN_CONNECTION_ACKED"));
handleCmd();

Command.source = A;
fillArr(Command.cmdArr, "LIST", sizeof("LIST"));
handleCmd();

Command.source = B;
fillArr(Command.cmdArr, "LIST 6575 LIST", sizeof("LIST 6575 LIST"));
handleCmd();

}
=============================================================================================
#include "stdafx.h"
#include <string.h>

# 1 define VALID
#define INVALID 0

#define D_A 0
#define D_B 1

#define ARR_SIZE 25

typedef struct{
char cmdArr[ARR_SIZE];
bool AorB;
}cmd_s;

typedef struct{
char cmdArr[ARR_SIZE];
int size;
}cmd3_s;


/* Global Variables */
cmd_s Cmd;
cmd3_s Cmd3;


void fillArr(char destArr[], const char sourceArr[], const int size)
{
memset(destArr, 0, ARR_SIZE);
memcpy(destArr, sourceArr, size);
}

bool isCmd(const char * cmd_t, const int size)
{
if(strncmp(Cmd.cmdArr, cmd_t, size) == 0)
{
return 1;
}
return 0;
}

int checkCmd(bool drction, char * cmd_t, int size, int *statePtr, int dest_state)
{
if(Cmd.AorB == drction )
{
if(isCmd(cmd_t, size))
{
*statePtr = dest_state;
return VALID;
}
}

*statePtr = 1;
return INVALID;
}

void saveCmd3(const char sourceArr[], const int size)
{
fillArr(Cmd3.cmdArr, sourceArr, size);
Cmd3.size = size - 1; //don't count the '/0'
}

int checkState3(int *statePtr)
{
int status = (checkCmd(D_A,
"LIST", sizeof("LIST"),
statePtr, 4));

saveCmd3("LIST", sizeof("LIST"));

// other possible commands ...

if(status == INVALID)
{

status = (checkCmd(D_A,
"EXIT ", sizeof("EXIT "),
statePtr, 5));
}

return status;

}

int getCmdLen()
{
int i=0;
int cnt=0;

for(i=0; i<ARR_SIZE; i++)
{
if(Cmd.cmdArr[i] != '\0')
cnt++;
}

return cnt;
}

int checkCh(char ch)
{
if((ch >='a') && (ch <='z'))
return VALID;

if((ch >='0') && (ch <='9'))
return VALID;

return INVALID;

}

int checkState4(int *statePtr)
{
int cmdSize = getCmdLen();
int cmd3Sise = Cmd3.size;
int SecondIdx = cmdSize - cmd3Sise;
int i;

*statePtr = 1;

if(cmdSize < cmd3Sise*2 + 2)
return INVALID;

if(strncmp(&Cmd.cmdArr[0], Cmd3.cmdArr, cmd3Sise) != 0)
return INVALID;

if(strncmp(&Cmd.cmdArr[SecondIdx], Cmd3.cmdArr, cmd3Sise) != 0)
return INVALID;
// check the msg
for(i = cmd3Sise+1; i<= SecondIdx-2 ; i++ )
{
if(checkCh(Cmd.cmdArr[i]) == INVALID)
return INVALID;
}

*statePtr = 3;
return VALID;

}

int handleCmd()
{
static int stat_state = 1;

switch(stat_state)
{
case 1:
return (checkCmd(D_A,
"OPEN_CONNECTION", sizeof("OPEN_CONNECTION"),
&stat_state, 2));
case 2:
return (checkCmd(D_B,
"OPEN_CONNECTION_ACKED", sizeof("OPEN_CONNECTION_ACKED"),
&stat_state, 3));

case 3:return (checkState3(&stat_state));
case 4:return (checkState4(&stat_state));
case 5:
return (checkCmd(D_B,
"EXIT_ACKED", sizeof("EXIT_ACKED"),
&stat_state, 1));

default: return INVALID;

}
}

int _tmain(int argc, _TCHAR* argv[])
{
// init
memset(&Cmd, 0, sizeof(Cmd) );
memset(&Cmd3, 0, sizeof(Cmd3));

Cmd.AorB = D_A;
fillArr(Cmd.cmdArr, "OPEN_CONNECTION", sizeof("OPEN_CONNECTION"));
handleCmd();

Cmd.AorB = D_B;
fillArr(Cmd.cmdArr, "OPEN_CONNECTION_ACKED", sizeof("OPEN_CONNECTION_ACKED"));
handleCmd();

Cmd.AorB = D_A;
fillArr(Cmd.cmdArr, "LIST", sizeof("LIST"));
handleCmd();

Cmd.AorB = D_B;
fillArr(Cmd.cmdArr, "LIST 6575 LIST", sizeof("LIST 6575 LIST"));
handleCmd();


return 0;
}

קבצים מצורפים



#5 אורח - אורח

אורח - אורח
  • אורחים

פורסם 25/07/2010 - 08:05

לממש פרוטוקול ולידאציה ע"י ממוש פונקציה שמקבלת STRUCT ובוא טקסט text וכיוון השליחה A ל B או ולהחזיר האם ההודעה היא VALID או INVALID לפי ה FINAL STATE MACHINE הבא :

מצב1 :
אם הכיוון הוא אי ל- בי
ו ההודעה היא OPEN_CONECTION
עבור למצב 2 (וכמובן החזר VALID)
אחרת השאר במצב 1 (וכמובן החזר INVALID)

מצב2:
אם הכיוון הוא בי לאיי
ו ההודעה היא OPEN_CONECTION_ACKED
עבור למצב 3 ( החזר VALID)
אחרת עבור למצב 1 ( החזר INVALID)

מצב3:
אם הכיוון הוא אי לביי
ו ההודעה היא LIST,GETLIFE,LISTEN,GETALL,SAVEALL,SAVE,SAVETHEQUEEN...
יש שאני לא זוכר...
עבור למצב 4 ( החזר VALID)
אם זה EXIT עבור למצב 5 ( החזר VALID)
אחרת עבור למצב 1 ( החזר INVALID)

מצב4:
אם הכיוון הוא בי לאיי
ו ההודעה היא המילה שהתקבלה במצב 3 כאשר היא מופיעה פעמיים כאשר יש רק שני רווחים בין המילים או שני רווחים ובינהם מחרוזת המורכבת מאותיות קטנות לדוגמא : LIST LIST, SAVE fddf444542@@d SAVE

עבור למצב 3 ( החזר VALID)
אחרת עבור למצב 1 ( החזר INVALID)

מצב5:
אם ההודעה היא EXIT_ACKED ובכוון מB לA
עבור למצב 1 ( החזר VALID)
אחרת עבור למצב 1( החזר VALIDIN)

//#include "stdafx.h"
#include <string.h>

#define VALID 1
#define INVALID 0
#define A 0
#define B 1
#define ARR_SIZE 25


enum compass_direction
{
north,
east,
south,
west
};

typedef struct
{
char cmdArr[ARR_SIZE];
int source;
}commandStruct;
typedef struct
{
char cmdArr[ARR_SIZE];
int size;
}commandEdgesStruct;

//Global variables
commandStruct Command;
commandEdgesStruct commandEdges;
enum compass_direction my_direction;

fillArr(char destArr[], const char sourceArr[], const int commandSize)
{
memset(destArr, 0, ARR_SIZE);
memcpy(destArr, sourceArr, commandSize);
}

//check the direction of the packet if the command and the request size
checkPacket(int source, char * command, int commandSize, int *statePtr, int destinationState)
{
if(Command.source == source)
{
if(strncmp(Command.cmdArr, command, commandSize) == 0)
{
*statePtr = destinationState;
return VALID;
}
}
*statePtr = 1;
return INVALID;
}

//check and save the edges command
checkState3(int *statePtr)
{
int status;
int commandSize;

if (Command.cmdArr == *my_direction(0))
status=2;


switch (my_direction) {
case 'List':
status = (checkPacket(A, "LIST", sizeof("LIST"), statePtr, 4));
commandSize = sizeof("LIST");
fillArr(commandEdges.cmdArr, "LIST", commandSize);
commandEdges.size = commandSize - 1;
return status;
break;
case 'EXIT':
return status = (checkPacket(A, "EXIT", sizeof("EXIT"), statePtr, 5));
break;
default :
*statePtr = 1;
return INVALID;
}
}

/*//check and save the edges command
checkState3(int *statePtr)
{

int status = (checkPacket(A, "LIST", sizeof("LIST"), statePtr, 4));

if(status == INVALID)
status = (checkPacket(A, "EXIT ", sizeof("EXIT "), statePtr, 5));
else
{
int commandSize = sizeof("LIST");
fillArr(commandEdges.cmdArr, "LIST", commandSize);
commandEdges.size = commandSize - 1;
}

return status;
}*/

//check the validation of the command at the edges and the validation of the message
checkState4(int *statePtr)
{
int commandSize = strlen(Command.cmdArr);
int cmd3Sise = commandEdges.size;
int secondIndex = commandSize - cmd3Sise;
char charCommand;
int i;

*statePtr = 1;

//check the validation of command at the edges
if(strncmp(&Command.cmdArr[0], commandEdges.cmdArr, cmd3Sise) != 0)
return INVALID;
if(strncmp(&Command.cmdArr[secondIndex], commandEdges.cmdArr, cmd3Sise) != 0)
return INVALID;

//check if the middle command is longer than one
if(commandSize < ((cmd3Sise * 2) + 2))
return INVALID;

//check the validation of the message
for(i = cmd3Sise + 1; i <= secondIndex - 2 ; i++)
{
charCommand = Command.cmdArr[i];
if( !((charCommand >='a') && (charCommand <='z')) | ((charCommand >='0') && (charCommand <='9')) )
return INVALID;
}

*statePtr = 3;
return VALID;
}

handleCmd()
{
static int stateOfProcess = 1;

fillArr(Command.cmdArr, "OPEN_CONNECTION_ACKED", sizeof("OPEN_CONNECTION_ACKED"));
return (checkPacket(B, "OPEN_CONNECTION_ACKED", sizeof("OPEN_CONNECTION_ACKED"),


//switch by choosing the current state
switch(stateOfProcess)
{
case 1:
fillArr(Command.cmdArr, "OPEN_CONNECTION", sizeof("OPEN_CONNECTION"));
return (checkPacket(A, "OPEN_CONNECTION", sizeof("OPEN_CONNECTION"),
&stateOfProcess, 2));
case 2:
fillArr(Command.cmdArr, "OPEN_CONNECTION_ACKED", sizeof("OPEN_CONNECTION_ACKED"));
return (checkPacket(B, "OPEN_CONNECTION_ACKED", sizeof("OPEN_CONNECTION_ACKED"),
&stateOfProcess, 3));

case 3:return (checkState3(&stateOfProcess, "List"));
case 4:return (checkState4(&stateOfProcess));
case 5:
return (checkPacket(B, "EXIT_ACKED", sizeof("EXIT_ACKED"),
&stateOfProcess, 1));

default: return INVALID;
}
}

main(int argc, char *argv[])
{
memset(&Command, 0, sizeof(Command) );
memset(&commandEdges, 0, sizeof(commandEdges));

Command.source = A;

handleCmd();

Command.source = B;

handleCmd();

Command.source = A;
fillArr(Command.cmdArr, "LIST", sizeof("LIST"));
handleCmd();

Command.source = B;
fillArr(Command.cmdArr, "LIST 6575 LIST", sizeof("LIST 6575 LIST"));
handleCmd();

}

קבצים מצורפים



#6 אורח - אורח

אורח - אורח
  • אורחים

פורסם 25/07/2010 - 08:11

1-MY IP -IFCONFIG
2-CN TO SERVER-FTPֹ IPOF TESERVER
3-LS-SHOW THE FILES
4-GET FILENAME
5-SEND TO SERVER- PUT FILE NAME

#7 omeriko9

omeriko9

    למישהו יש אש?

  • רשומים+
  • 2175 הודעות:

פורסם 25/07/2010 - 16:00

היה היום מבחן בצ'ק פוינט? :unsure:

You're not lost, just misplaced
"הדברים החשובים באמת, סמויים מן העין"
Quidquid latine dictum sit, altum viditur.
"פתחו קובץ אקסל. בצד שמאל כתבו את כל המטלות שיש לכם ובצד ימין את כל השניות ביממה..."





0 משתמשים קוראים נושא זה

0 משתמשים, 0 אורחים, 0 משתמשים אנונימיים