Implement simple global constant identifiers

Assignment Help Computer Engineering
Reference no: EM13908689

Assignment 1:

Part A - Haskell

Complete the following Haskell function definitions. Unless stated otherwise do not use library functions that are not in the Haskell standard prelude. This constraint is so that you gain practice in simple Haskell recursive programming.

The Haskell 2010 standard prelude definition is available at

Place all definitions in a single file. Submit just this text file electronically as directed on the course Study Desk page. Use the specified function name as your code will be tested by a Haskell function expecting that function name.

The testing program may use many more test cases than the ones shown in the specification. So, please test your functions extensively to ensure that you maximise your marks.

1. Write the function insertAt :: Int -> a -> [a] -> [a]. insertAt n x xs will insert the element x into the list xs at position n items from the beginning of xs. In other words, skip n items in xs, then insert the new element.

You can assume that n will be a non-negative number. If n is greater than the length of the list xs then add it to the end of the list.

For example
insertAt 3 '-' "abcde" ⇒ "abc-de" insertAt 2 100 [1..5] ⇒ [1,2,100,3,4,5]

Hint: Use standard prelude functions ++ and splitAt.

2. Write a function uniq :: Eq a => [a] -> [a] that removes duplicate entries from a sorted (in ascending order) list. The resulting list should be sorted, and no value in it can appear elsewhere in the list.

For example:

uniq [1,2,2] ⇒ [1,2]
uniq [1,2,3] ⇒ [1,2,3]

3. Write a function

join :: Eq a => [(a,b)] -> [(a,c)] -> [(a,b,c)].

join takes two lists of pairs, and returns a single list of triples. A triple is generated only when there exists a member of both argument lists that have the same first element. The list elements are not sorted. This is the same semantics as the relational algebra natural join operation.

For example:
join [(2,"S"),(1,"J")] [(2,True),(3,False)]⇒ [(2,"S",True)]
join [(2,"S"),(1,"J")] [(2,1),(2,2),(3,4)] ⇒ [(2,"S",1),(2,"S",2)]
Hint: use list a comprehension.

4. This question extends the join function from question 3. Write the function

ljoin :: Eq a => [(a,b)] -> [(a,c)] -> [(a,b,Maybe c)].

This is the left outer join from relational algebra. If a tuple (database row) from the first (left) argument does not have a matching tuple from the second argument, include that tuple in the resulting tuple, but place a "null" value in place of the un-matched value. For this implementation we use a Maybe data type, and use the Nothing value to denote Null.

For example
ljoin [(2,"S"),(1,"J")] [(2,1),(2,2),(3,4)] ⇒ [(2,"S",Just 1),(2,"S",Just 2),(1,"J",Nothing)]

5. Consider the following definition for a binary tree.
data Tree a = Leaf a | Node (Tree a) (Tree a)

A binary tree is balanced if, at every node, the difference between the number of leaves appearing in the left and right subtree is at most one. (A tree which contains just one leaf is considered balanced.)

Write the function isBalanced :: Tree a -> Bool that decides if the tree is balanced. Hint: first write a function size::Tree a -> Int that counts leaves in a tree. isBalanced (Node (Node (Leaf 1)(Leaf 3)) (Leaf 2)) ⇒ True
isBalanced (Node (Node (Leaf 1)(Node (Leaf 1)(Leaf 3))) (Leaf 2))⇒ False

6. Write a function isNumber :: String -> Bool that tests if a string contains a valid number. A valid number is defined in EBNF as:
number → .digit+ | digit+ [ .digit∗]

For example, .5, 1.5, 1, 1. are all valid numbers. As usual, + signifies one or more
occurrences, and * denotes zero or more.

You may use the isDigit function from the Data.Char module.

Hint: you may wish to write functions someDigits, manyDigits :: String -> Bool to test for .digit+ and digit∗.

7. Write a function getElems :: [Int] -> [a] -> [Maybe a] which takes a list of integers signifying the position of an element in a list, and a list. It returns those elements that correspond to the positions specified. Because a position may be greater than the list size the returned element is a Maybe data type. If the position specified is greater the the maximum list position then Nothing is returned, else Just value.

For example
getElems [2,4] [1..10] ⇒ [Just 3,Just 5]
getElems [2,4] [1..4] ⇒ [Just 3,Nothing]

Part B - SPL -

You are required to make a number of modifications to the SPL compiler. The SPL laboratories provide an introduction to the implementation of SPL and the SPL Reference Manual supplies extra information.

The SPL source code and other resources are available at https://tau.usq.edu.au/courses/CSC8503/resources.html

Important: get a fresh copy of the SPL distribution before starting work as it has been modified slightly from earlier versions used in the tutorials.

Each of the following questions is independent in that they do not rely on any of the other modifications. In marking the assignment, they will be tested independently.

I will be compiling and running your SPL system so your code must compile and run. If you are unable to get some parts working and GCC or Bison compile errors exist, then comment out the error-producing code so that I can compile and execute what you do have working.

Make sure you include all necessary files including the Makefile. I should be able to just type ‘make' and your system will be compiled on my machine.

1. Implement an autoincrement operator for variables. The syntax for these new operations is described by the extended factor grammar rule factor → ++id | id++ | id | num | ( expression ) | - expression

These have the same semantics as the C operators of the same kind. The value of pre- increment expression ++x is the current value of x, plus one , while the value of post- increment expression x++ is the current value of x. Evaluation of both operators would increase the stored value of x by one. Consider the following program.

var a; { a := 1;
display a; display a++; display a; display ++a; display a;
}

On execution it should produce as output the sequence 1, 1, 2, 3, 3. You will need to modify the lexer lexer.c and the parser spl.y as follows:

• Create new token name (say) INC in spl.y, and modify lexer.c to recognise the corresponding ++ symbol. Look at the way two-character symbols like ‘>=' are handled.

Make sure that you update dispToken().

• Add grammar rules for the two new factor alternatives in spl.y.

• Generate the increment code for the two increment operators. Use the current rule for factor : IDENT as a basis. You will need to generate add and move operations. You'll probably need a new temporary register, whose number will be stored in a variable like reg, to store the operand ‘1'.

2. Implement a do ... until post-tested loop. The statement has syntax:

do statement+ until condition ;

Note that the body is a list of statements. This is different from the ‘while' loop whose body is a compound statement. Also note the trailing semicolon.

You will need to modify the lexer lexer.c and the parser spl.y as follows:

• Create new token name (say) UNTIL in spl.y, and modify lexer.c to recognise the corresponding until reserved word. Make sure that you update dispToken().

• Add the ‘until' loop grammar rule to spl.y.

• Add actions to the loop rule to generate corresponding code. Use the existing ‘while' code for guidance, but beware the semantics are different. Most importantly, the condition test follows the body of the loop, so the conditional jump address does not need to be backpatched into the jump instruction. Also, unlike the ‘while' loop, this loop terminates when the condition is true.

3. Implement simple global constant identifiers. (Do not implement procedure- local constants.) The declaration has the form

const id = num;

There may be zero or more constant declaration statements. For example you could declare const max = 100;.
You will need to do the following:

• Create new token name (say) CONST in spl.y, and modify lexer.c to recognise the corresponding const reserved word. Make sure that you update dispToken().

• Add grammar rules to spl.y for (1) a constant declaration and (2) a list of constant declarations; modify the program rule to include the constant declarations.

• Modify the symbol table to record the constant identifier's value. Modify st.h to add a new identifier class and add a ‘value' attribute to the attr structure. Modify list st in st.c so that the value and not the address of constant identifiers is displayed.

• Add actions to spl.y. You should

- Add a symbol table entry when a constant declaration is recognised.

- Generate the correct machine code instruction to load a constant value into a register when a constant IDENT in the factor rule is recognised.

Assignment 2

Question 1

USQ College has a campus in Toowoomba with 2 buildings. The computers in each building are linked to a switch and a router as shown. The network in each building is a (sub)network of its own. The diagram includes only 2 PCs for clarity. The 2 buildings are then linked, using serial cables, to another router R0 as shown in the logical network diagram below:

1586_Logical network diagram.png


Address scheme for the campus:

• All devices have both IPv4 and IPv6 addresses assigned.
• Building 1: all devices have IPv4 and IPv6 addresses in 200.200.1.0/24 and 2001:DB8:ACAD:1::/64
• Building 2: all devices have IPv4 and IPv6 addresses in 200.200.2.0/24 and 2001:DB8:ACAD:2::/64
• R0 has IPv4 and IPv6 addresses in 169.254.1.0/24, 169.254.2.0/24, 2001:DB8:FADE:1::/64 and 2001:DB8:FADE:2::/64
• R1 has IPv4 and IPv6 addresses in 169.254.1.0/24 and 2001:DB8:FADE:1::/64
• R2 has IPv4 and IPv6 addresses in 169.254.2.0/24 and 2001:DB8:FADE:2::/64 Implement the network using Packet Tracer. You must use router 2911, switch 2960 and
a) Static routes are used. Save your work as Q1_STATIC.pkt.
b) RIP version 2 and RIPng are used as the routing protocols. Save your work as Q1_RIP.pkt.
c) EIGRP is used as the routing protocols. Save your work as Q1_EIGRP.pkt.
d) OSPF V2 and OSPF v3 for single area are used as the routing protocols. Save your work as Q1_OSPF.pkt.
e) Explain the differences between next-hop static route, directly connected static route and a fully specified static route. Which one is better? Why? Put your answer in answer.txt.
f) What is the administrative distance for a directly connected staic route? Put your answer in answer.txt.
All PCs should be able to talk to each other using IPv4 and IPv6.

After 2 years of trial, USQ College decided to use the standard OSPF protocol for muti-area. Each building will be one area. The connecting router R0 will be the only device in the backbone area.

The logical network diagram of USQ College is shown below:

1661_Logical network diagram1.png

Address scheme for USQ College is the same as in Question 1.

Implement the network using Packet Tracer. You must use router 2911, switch 2960 and OSPF as the routing protocol. Save your work as Q2_OSPF_multi.pkt.
All PCs should be able to talk to each other using IPv4 and IPv6.

Question 3:

Given the following network topology:

2415_Logical network diagram2.png


All switches will be using fastethernet ports (bandwidth 100,000 Kbit) only.

The partial outputs of show interface command for each router are shown below:

R1#show int g0/0
GigabitEthernet0/0 is up, line protocol is up (connected) Internet address is 200.200.1.254/24
MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec,

R1#show int s0/0/0
Serial0/0/0 is up, line protocol is up (connected) Internet address is 200.200.2.1/24
MTU 1500 bytes, BW 64 Kbit, DLY 20000 usec,

R2#show int s0/0/1
Serial0/0/1 is up, line protocol is up (connected) Internet address is 200.200.2.2/24
MTU 1500 bytes, BW 64 Kbit, DLY 20000 usec,

R2#show int g0/0
GigabitEthernet0/0 is up, line protocol is up (connected) Internet address is 200.200.3.2/24
MTU 1500 bytes, BW 1000000 Kbit, DLY 10 usec,

R3#show int g0/0
GigabitEthernet0/0 is up, line protocol is up (connected) Internet address is 200.200.4.254/24
MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec,

R3#show int g0/1
GigabitEthernet0/1 is up, line protocol is up (connected) Internet address is 200.200.3.3/24
MTU 1500 bytes, BW 1000000 Kbit, DLY 10 usec,

a) In R1, the G0/0 interface is shown as having bandwidth 100,000 Kbit whereas in R2, G0/0 interface is shown as having bandwidth 1,000,000 Kbit. Explain why.

b) Calculate the EIGRP metric from R1 to network where PC2 is located. Explain and show how you derive at the values used in the calculation. Show detailed steps in arriving your answer.

c) Explain how the feasible condition can guararantee no loops will be created by the feasible successor. Put all your answers in answer.txt.

Question 4:

Download Q4.pkt. The network topology for Q4.pkt is shown below:

1039_Logical network diagram3.png

a) Explain under what circumstances can R1 became DR and R2 became BDR. Put your answer in answer.txt.
b) Make R3 as the DR and R4 as the BDR by changing the OSPF interface priority. Save your file as Q4ans.pkt.

Question 5:

Download Q5.pkt. The network topology of Q5.pkt is shown below:

2308_Logical network diagram4.png

a) Implement extended ACL for IPv4 to block LAN 11 and LAN 12 to access LAN 22 for web browsing at port 80. All other traffic including Ping should still be allowed

b) Implement ACL for IPv6 to block all traffic from LAN 11 and LAN 12 to access LAN 22. In both cases,
• LAN 21 can access LAN 22 without any restriction;
• LAN 11, LAN 12, and LAN 21 can freely access each other.

Your implementation should follow the "Three Ps" and guidelines for ACL placement. Save your answer as Q5ans.pkt.

Question 6:

USQ College has 4 campuses
1. Toowoomba;
2. Fraser Coast;
3. Springfield
4. Ipswich.
And each campus has more than 20 buildings, 200 subnets, and over 1,000 users. The routers used in USQ College are not supplied by Cisco.
RIP, EIGRP, OSPF are some of the common routing protocols used in Cisco routers. Which one would you use if you are the network administrator for USQ College?

Present your arguments:
• In less than two pages.
• Use dot point form and complete sentences.
• All reasons should be referenced.
• Draw your conclusion.

(e.g.
"Which one is better: Banana or Orange?"

Banana is better:
Banana has a cheaper price, around $2 per kg [Peter, 2001].
It is easy to peel [Paul, 2012] and would not make a mess during consumption [Pearson, 2010].
...

Orange is better:
Orange is available all year round [Mary, 1918].
It stay fresh much longer than Banana [Alice, 2015].
...

My conclusion is that Banana is better than orange because ... // a summary of reasons listed above that support your choice.

Reference:

Mary, K 1918 ‘Fruit production in Australia', Journal of Australian Fruit Industry Research and Marketing, Fruit Industry Australia, pp. 84-139.

Peter, D 2001, ‘Retail price changes for banana over the last 50 years.' Proceedings of the first annual conference, National Shoppers Association, Queensland, Australia, pp 109-128. ... )

Assignment 3

Assignment consists of five tasks. For each task, you have to submit a .cpp file and a documentation file

Task 1
Given:

class DateTime{ public:
DateTime(int y, int m, int d, int h = 0, int min = 0, int s = 0); void display();
protected:
string get_string_component(char option, tm* dateStruct); int get_year_days(tm* dateStruct);
struct tm DTstruct; private:
bool validate_data( int y, int m, int d, int h, int min, int s);
};

string DateTime::get_string_component(char component, tm* dateStruct){ char format[3];
format[0] = '%'; format[1] = component; format[2] = '\0';

char ans [80];
strftime(ans, 80, format, dateStruct); string strans(ans);
return strans;
}

int DateTime::get_year_days(tm* DTstruct){ return DTstruct->tm_yday;
}

Implement member functions

• DateTime(int y, int m, int d, int h = 0, int min = 0, int s = 0);
- Assign proper values to DTStruct members using the (default) arguments.
- y should be a four digit integer and DTstruct.tm_year is a two digit integer.
   E.g. user input 1994, DTstruct.tm_year is 94.
   E.g. user input 2015, DTstruct.tm_year is 15.
- m is from 1 to 12, but DTstruct.tm_mon is from 0 to 11.
- d and DTstruct.tm_mday have the same value.
- h and DTstruct.tm_hour have the same value.
- min and DTstruct.tm_min have the same value.
- s and DTstruct.tm_sec have the same value.
- DTstruct.tm_wday, DTstruct.tm_yday and DTstruct.tm_isdst will be set to 0 initially.
- Re-adjust values in DTstruct.
• void display();
- Display the local date and time of DTstruct.
• bool validate_data( int y, int m, int d, int h, int min, int s);
- return true if all parameter values are all valid;
- return false when one or more data are invalid;
- a false return will invoke the <cstdlib> exit(EXIT_FAILURE) function call and display the following error message:
"Incompatible data!"

- Validation criteria:

Name

Validation Criteria

y

1970 <= y <= 2020

m

1 <= m <= 12

d

1 <= d <= 31

h

0 <= h <= 23

min

0 <= min <= 59

s

0 <= s <= 59

We can retrieve any one of the date-time structure member using strftime(). Refer to Assignment 1 for options available.

You have to provide:

• a header file datetime.h with code to prevent multiple inclusion.
• an class implementation file datetime.cpp.
• a text file task_2_1.txt containing compilation messages and sample runs. Note:
• Do not modify the DateTime class public and protected sections. You may add private members (data/functions) only.
• There is no need to implement error exception.

You may use sample_DT_app.cpp to test your implementation. Expected output:

C:\>a
01/02/15 03:04:05
01/02/15 03:04:00
01/02/15 03:00:00
01/02/15 00:00:00

You should also use your own test cases to test for error inputs.

Task 2

Derive class WeekDay from class DateTime such that WeekDay::display() will display local date time using values from the parameters and the corresponding weekday. For a handy online weekday calculator: What Day is this Date? https://www.timeanddate.com/date/weekday.html

class WeekDay : public DateTime { public:
WeekDay(int y, int m, int d, int h = 0, int min = 0, int s = 0); void display();
};

Implement
• WeekDay(int y, int m, int d, int h = 0, int min = 0, int s = 0);
- Validate the parameter values the same ways as in DateTime().
• void display();
- display the local date time and the corresponding weekday.

You have to provide:
• a header file weekday.h with code to prevent multiple inclusion.
• an class implementation file weekday.cpp.
• a text file task_2_2.txt containing compilation messages and sample runs.

Note
• You have to include the code for class DateTime in weekday.h and weekday.cpp.
• Do not modify DateTime and WeekDay class public and protected sections. You may add private members (data/functions) only.
• There is no need to implement error exception.

You may use sample_WD_app.cpp to test your implementation. Expected output:

C:\>a
01/02/15 03:04:05 is Friday
01/02/15 03:04:00 is Friday
01/02/15 03:00:00 is Friday
01/02/15 00:00:00 is Friday

You should also use your own test cases to test for error inputs.

Task 3

Derive class Age from class DateTime such that Age::display() will display birthdate in local date time format using values from the parameters, the current time and the age.

class Age : public DateTime { public:
// Date supplied is birth date, should be earlier than current date Age(int y, int m, int d, int h = 0, int min = 0, int s = 0);
void display(); protected:
struct tm Astruct; // tm for current time private:
string int_2_string(int); void error_action(); string age;
};

string Age::int_2_string(int n){ ostringstream outstr;
if (n > 100000){
outstr << (n - 100000);
return outstr.str() + " days old.";
} else if (n > 1000){ outstr << (n - 1000);
return outstr.str() + " months old.";
} else {
outstr << n;
return outstr.str() + " years old.";
}
}

void Age::error_action(){
cout << "Birthday must be in the past!\n"; exit(EXIT_FAILURE);
}

Implement
• Age(int y, int m, int d, int h = 0, int min = 0, int s = 0);
- Validate parameter values the same way as in class DateTime.
- When calculating age, the unit can be day, month or year. To differentiate the units, add 1,000 to age in months, add 100,000 to age in days. When passed to int_2_string, we can convert the age to proper values and units.
• void display();
- Display the local date time created as birthdate; the current date and the age calculated using the birthdate and the current date.
You have to provide:

• a header file age.h with code to prevent multiple inclusion.
• an class implementation file age.cpp.
• a text file task_2_3.txt containing compilation messages and sample runs. Note
• You have to include the code for class DateTime in age.h and age.cpp.
• You may include the code for class WeekDay in age.h and age.cpp.

• Do not modify DateTime and Age class public and protected sections. You may add private members (data/functions) only.
• There is no need to implement error exception.

You may use sample_AGE_app.cpp to test your implementation. Expected output:

C:\>a
Birthday: 12/25/94 03:04:05 Current date: 04/15/15 15:17:15 Age is 22 years old.

Birthday: 12/25/94 03:04:00 Current date: 04/15/15 15:17:15 Age is 22 years old.

Birthday: 12/25/94 03:00:00 Current date: 04/15/15 15:17:15 Age is 22 years old.

Birthday: 12/25/94 00:00:00 Current date: 04/15/15 15:17:15 Age is 22 years old.

Birthday: 04/15/15 00:00:00 Current date: 04/15/15 15:17:15 Age is 1 days old.

Birthday: 04/01/15 00:00:00 Current date: 04/15/15 15:17:15 Age is 15 days old.

Birthday: 03/15/15 00:00:00 Current date: 04/15/15 15:17:15 Age is 2 months old.

Birthday: 12/25/14 00:00:00 Current date: 04/15/15 15:17:15 Age is 2 years old.

Birthday: 01/25/14 00:00:00 Current date: 04/15/15 15:17:15 Age is 2 years old.

You should also use your own test cases to test for error inputs.

Task 4

Derive class Days2Go from class DateTime such that Days2GoAge::display() will display birthdate in local date time format using values from the parameters and the number of days before your next birthday. The current date used in the sample run is assumed to be 15/04/2015.

class Days2Go : public Age { public:
Days2Go(int y, int m, int d, int h = 0, int min = 0, int s = 0); void display();
private:
int days;
};

Implement
• Days2Go(int y, int m, int d, int h = 0, int min = 0, int s = 0);
- 2016 is a leap year.
- Birth year may be a leap year. You have to consider 29 Feb.
• void display();
- Display the local date time created as birthdate; the current date and the age calculated using the birthdate and the current date.
You have to provide:

• a header file days2go.h with code to prevent multiple inclusion.
• an class implementation file days2go.cpp.
• a text file task_2_4.txt containing compilation messages and sample runs. Note
• You have to include the code for class DateTime and class Age in days2go.h and days2go.cpp.
• Do not modify class DateTime, Age and Days2Go public and protected sections. You may add private members (data/functions) only.
• There is no need to implement error exception.

You may use sample_DTG_app.cpp to test your implementation. Assuming the current date is 15/04/2015, expected output:

C:\>a
Birthday: 04/14/94 00:00:00 Current date: 04/15/15 15:32:15 Days before next birthday: 364

Birthday: 04/15/94 00:00:00 Current date: 04/15/15 15:32:15 Days before next birthday: 0

Birthday: 04/16/94 00:00:00 Current date: 04/15/15 15:32:15 Days before next birthday: 1

Birthday: 05/15/00 00:00:00 Current date: 04/15/15 15:32:15 Days before next birthday: 30

You should also use your own test cases to test for error inputs.

Task 5

Write a C++ program that stores information for date-time objects including DateTime, WeekDay, Age, and Days2Go objects. The program will display all the object information using the display() function provided by the objects.

Note

• Use a single vector to store information for all objects. Arrays, and other data structures are not allowed.
• When displaying information, the corresponding display() function of the object should be used.
- E.g. DateTime object will display local date time and Age object will display birthdate, current date and age.
• You may have to modify the class interface(s) to enable polymorphism.
• There is no need to implement error exception.
• Adjust current date to 15 Apr 2015.
• You have to submit date.h, date.cpp, task_2_5.cpp and task_2_5.txt containing compilation messages and sample runs.
• Dates to be stored:

DateTime: 1990, Jan, 7, 14:15:16
DateTime: 2000, Mar, 14, 14:15
DateTime: 2015, Apr, 15, 14 hour
DateTime: 2015, Apr, 10
DateTime: 2015, Feb, 16
DateTime: 2000, Feb, 16

WeekDay: 1990, Jan, 7, 14:15:16
WeekDay: 2000, Mar, 14, 14:15
WeekDay: 2015, Apr, 15, 14 hour
WeekDay: 2015, Apr, 10
WeekDay: 2015, Feb, 16
WeekDay: 2000, Feb, 16

Age: 1990, Jan, 7, 14:15:16
Age: 2000, Mar, 14, 14:15
Age: 2015, Apr, 15, 14 hour
Age: 2015, Apr, 10
Age: 2015, Feb, 16
Age: 2000, Feb, 16

Days2Go: 1990, Jan, 7, 14:15:16
Days2Go: 2000, Mar, 14, 14:15
Days2Go: 2015, Apr, 15, 14 hour
Days2Go:2015, Apr, 10
Days2Go: 2015, Feb, 16
Days2Go: 2000, Feb, 16

...
• Expected output: (current date is 15 Apr 2015)

01/07/90 14:15:16
03/14/00 14:15:00
04/15/14 14:00:00
04/10/14 00:00:00
02/16/14 00:00:00
02/16/00 00:00:00
01/07/90 14:15:16 is Sunday 03/14/00 14:15:00 is Tuesday 04/15/14 14:00:00 is Monday 04/10/14 00:00:00 is Wednesday 02/16/14 00:00:00 is Saturday 02/16/00 00:00:00 is Wednesday Birthday: 01/07/90 14:15:16 Current date: 04/15/15 10:21:59 Age is 26 years old.

Birthday: 03/14/00 14:15:00 Current date: 04/15/15 10:21:59 Age is 16 years old.
Birthday: 04/15/15 14:00:00 Current date: 04/15/15 10:21:59 Age is 1 days old.
Birthday: 04/10/15 00:00:00 Current date: 04/15/15 10:21:59 Age is 6 days old.
Birthday: 02/16/15 00:00:00 Current date: 04/15/15 10:21:59 Age is 3 months old.
Birthday: 02/16/00 00:00:00 Current date: 04/15/15 10:21:59 Age is 16 years old.
Birthday: 01/07/90 14:15:16 Current date: 04/15/15 10:21:59 Days before next birthday: 267

Birthday: 03/14/00 14:15:00 Current date: 04/15/15 10:21:59 Days before next birthday: 333

Birthday: 04/15/15 14:00:00 Current date: 04/15/15 10:21:59 Days before next birthday: 0

Birthday: 04/10/15 00:00:00 Current date: 04/15/15 10:21:59 Days before next birthday: 360

Birthday: 02/16/15 00:00:00 Current date: 04/15/15 10:21:59 Days before next birthday: 307

Birthday: 02/16/00 00:00:00 Current date: 04/15/15 10:21:59 Days before next birthday: 307

You should also use your own test cases to test for error inputs.

Assignment 4:

Question 1:

An important service provided by any system is the ability to run a pro- cess on a predetermined schedule without human intertention. The "au- tomation" of tasks can reduce the workload of the system administrator significantly. Unfortunately Linux currently offers not one service but potentially three-cron, anacron, and systemd timer units.

In about a page compare and contrast all three systems. Illustrate your discussion by using the system files /etc/anacron and /etc/crontab and by constructing equivalent systemd service and timer files.

Notes:

a. It says "compare" and "contrast"-so explain how they are the same and how they are different.
b. Your answers must be written in your own words.
c. Please use the specified system files to explain how scheduling is defined do not invent your own.
d. Any technical term used must be explained.
e. Do not discuss the package systemd-cron. Write and test the systemd service and timer files yourself.
f. One way to test a crontab file or a anacrontab file, or sys- temd service and timer files is to use the date command as the command ultimately to be run the output from the command ef- fectively timestamps when it was run by your scheduler.
g. Some sources of information: Cron:
• The text book
• man 5 crontab
Anacron:
• The text book
• man 5 anacrontab
Systemd timer unit:
• https://wiki.archlinux.org/index.php/Systemd/ Timers
• https://www.certdepot.net/rhel7-use-systemd-timers/
h. List all resources used in answering the question.

Question 2:

The web administrator of your organisation needs to login remotely to the machine that is running the organisation's public web site.

You tell her that the only way to login is via The Secure Shell-which she knows nothing about! Assuming she is logging in via a Linux box write a help document for her containing the following-

a. A short introduction to SSH, explaining why it is the preferred way of logging into a remote machine-this explanation will need to discuss symmetric and asymmetric key encryption.

b. A discussion of the contents of the file
~/.ssh/known_hosts.

Your discussion should include (but not be limitted to):
• how the file is populated,
• how the keys in the file are used by SSH,
• a discussion of "man-in-the-middle" attacks,
• why the hostnames in the file are "hashed", and
• how individual keys can be deleted by ssh-keygen.

c. A description how to configure access so that no pass- words are needed-that is by using user asymmetric keys. This will require a discussion (with examples) of the command ssh- keygen, the file ~/.ssh/authorized_keys, passphrase pro- tected keys and the commands ssh-agent and ssh-add.

Notes:

a. Any technical term used must be explained.

b. Your virtual Debian has the SSH dæmon installed and running by default-so you can SSH to it from the host system or from a second virtual machine.

c. Your virtual machine has two network interfaces configured-a host only interface and a NAT interface. To bring the host only network "up" study the man pages interfaces(5), ifup(8) and ifdown(8).

d. You must show the relevant changes/parts of any files discussed.

e. This is a help document so you must explain (in your own words) the purpose of every file and command mentioned (plus any com- mand line options).

f. Be very clear which key (public or private) is stored on which machine (remote or local)

g. Port forwarding, SSH tunnels and firewalls need not be discussed- they will be covered later in the course.

Question 3:

a. In about a page explain in your own words what a Logical Volume Manager is, its purpose and why it is useful.
b. Illustrate your explanation by using the Linux Log- ical Volume Manager to combine the two spare disks available on the Virtual Debian distribution. Combine the two disks into one logical volume. Format the new logical disk and modify the /etc/fstab file to mount the new disk at boot.
c. Document and explain in your own words the purpose of every command you use (plus any command line options) and any configuration files or scripts you modify or create.

Notes:

a. Be certain to explain the meaning of any tehnical terms you may use-for example, what is a "physical volume", a "volume group", &c.
b. Make use of the utilities pvdisplay, vgdisplay, &c. to show the results of commands and that they have worked.

Question 4:

A user comes to you requesting that you create and implement a backup policy for his desktop machine. What he wants, is to be able to place a blank DVD in his Single-Sided DVD-burner at the end of the working day on a Friday and have all the files he has been working on for the week backed up automatically that evening to the DVD!

After a bit more questioning you find out that:
• He frequently creates/deletes and changes files on a daily basis.
• He wants to be able to recover files for any given day.
• He only wants his home directory backed up.
• His home directory contains about 2Gbytes of data.
• His desktop machine has a spare disk (mounted as /spare) that has plenty of free space for temporary storage.

Tasks that need to be done:
a. Using the information above design a backup policy. Give a detailed description and justification of your backup-policy.
b. Using tar, a shell script or scripts and systemd timer and service files to implement your backup policy.

Notes:

a. Explain in your own words each operation you needed to perform to implement your backup policy. Your descriptions of each oper- ation need to show you understand the purpose of the operation.

b. Use /spare as a temporary storage for backup files until they are burnt to the DVD on Friday.

c. "Temporary Storage" means just that-cleanup /spare after a successful burn.

d. A Single-sided DVD can only hold 4.2GiB (4.2×1024×1024×1024 bytes) of data.

e. The ISO9660 file-system-is the file-system used on Optical disks.

f. To write data to an optical disk a complete ISO9660 disk image file containing the data, must be created on the local hard disk and then burnt to the optical disk.

g. You will need utilities for creating ISO9660 images and burning DVDs, have a look at the following packages dvd+rw-tools, genisoimage, wodim.

h. List all resources used in answering the question.

Reference no: EM13908689

Questions Cloud

Write a function uniq that removes duplicate entries : Write the function insertAt :: Int -> a -> [a] -> [a]. insertAt n x xs will insert the element x into the list xs at position n items from the beginning of xs. In other words, skip n items in xs, then insert the new element.
Is the betting market at roulette an efficient market : Is the betting market at roulette an efficient market? You have just become convinced that whenever the president of a company retires, an excess return can be made by buying the stock. Design a study to test this hypothesis.
How would you judge effectiveness of your regression model : If you were to run a regression with dog weight as the dependent variable, choose an appropriate set of independent variables and report your proposed regression equation. How would you judge the effectiveness of your regression model
What value would you assign to the company : Furthermore, at the end of the five years, she expects the company's payout rate to increase from its present 30% up to 50%. What value would you assign to the company?
Implement simple global constant identifiers : Implement simple global constant identifiers - Generate the correct machine code instruction to load a constant value into a register when a constant IDENT in the factor rule is recognised.
Write down the forecast of next periods earnings : Write down the forecast of next period's earnings if Earnings are a mean reverting process with no trend or cycle and Earnings are a mean reverting process with a trend but not a cycle.
Boss company standard cost accounting system recorded : Boss Company's standard cost accounting system recorded this information from its December operations.
How earnings be forecast if there was a strong relationship : How would earnings be forecast if there was a strong relationship between the firm's earnings and the industry's and economy's earnings?
Kryll company set the following standard unit costs : Kryll Company set the following standard unit costs for its single product.

Reviews

Write a Review

 

Computer Engineering Questions & Answers

  Define the use of contractions, slang and icons

Does the use of contractions, slang and icons in text messaging and email signal the development of a new communication style, or just the death of appreciation of written language.

  Create a sql query that returns the names of the students

Write down a SQL query that returns the names of the students (lname, fname), and the major of the major with most students. If more than one major is tied for most students, then list all the names of the students from both majors (as well as the..

  Write a program to apply combination of transformation

Write a program to apply combination of transformation, rotation, reflection and shearing) on the following objects.

  There are many property crimes but onlynbsp4 property

there are many property crimes but onlynbsp4 property crimesnbspare listed by the ucr asnbspindex crimes.these are the

  Define the dangers of the sequence of statements

Write down three SQL statements: the first statement should add the pending amounts to the appropriate accounts, the second statement must subtract the pending amounts from the appropriate accounts, and the third statement should delete the pending..

  1nbspunder the von neumann architecture a program and its

1.nbspunder the von neumann architecture a program and its data are both stored in memory. it is therefore possible for

  Show the resulting binary search tree that is created

Based on the 2-3-4 tree you created, flag the same 4 numbers in the previous problem for deletion. Then, traverse the 2-3-4 tree in order to get the remaining numbers (i.e. identify in order, the numbers that are not marked for deletion).

  Define session as part of the project termination process

As a project manager, you are asked to facilitate a lessons learned session as part of project termination process. How would you facilitate this session and what are some guidelines you would use? How would you incorporate and document the inform..

  Implementation of type data structures

How can string and word variable type data structures be implemented?

  Explain why is a flowchart useful in developing and

q1. why is a flowchart useful in developing and documenting software? why is the interactive visual logic flowchart

  The aim of this project is to exercise and test your

the aim of this project is to exercise and test your ability to read and understand descriptions of data formats and to

  Developing uml sequence diagram for uploading document

For the existing Blackboard system, a system utilized for virtual classroom, grades, messages, and announcements, develop ONE UML Sequence Diagram for uploading the document to Blackboard.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd