802.11 frame transmission route and used addresses - frame

I have a WiFi System that consists of two Access Points AP1 and AP2 with the addresses MAC_AP1 and MAC_AP2.
There are two stations in the BSS of AP1, STA1 and STA2 with the addresses MAC_STA1 and MAC_STA2.
There is one station in the BSS of AP2, STA3 with the adress MAC_STA3.
Also there is a server on the distribution system with the adress MAC_SERVER.
Here is a drawing
]
Question 1: If STA1 sends a frame to STA2, which which way does it go?
My guess is that it is like the purple Arrows shows. STA1 sends it to AP1 and AP1 to STA2.
Question 2: Which addresses are necessary on the wireless interface and why?
My thoughts so far, assuming I got the path right:
DA Field = MAC_STA2
SA Field = MAC_STA1
RA Field = MAC_AP1
TA Field = MAC_STA1
So I would need the addresses of MAC_STA1, MAC_STA2, and MAC_AP1 correct?
Question 3: Same as above, but this time the frame is sent from the Server to STA3.
DA Field = MAC_STA3
SA Field = MAC_SERVER
RA Field = MAC_AP2
TA Field = MAC_SERVER
So I would need the addresses of MAC_STA3, MAC_SERVER, and MAC_AP2 correct?
Question 3.1: Name all used addresses on the distribution system.
I would give the same answer as to the previous question, which is probably wrong.
I appreciate your help, thank you.

Question 1: Your are right
Question 2 & 3:
Addressing in 80211 will not contain all 4 addresses always. Most of the cases it contains only 3. Below are the corresponding addresses:
Question 2: Addr1 = MAC_AP1; Addr2 = MAC_STA1; Addr3 = MAC_STA2
Question 3:
Here the SERVER sends the packet to AP2 over Ethernet as an Ethernet frame. AP2 in turn will extract layer 3 data (IP) from Ethernet frame and encapsulate it inside 80211 header. The address fields in this header are as below:
Addr1 = MAC_STA3; Addr2 = MAC_AP2; Addr3 = MAC_SERVER

Related

Match a column against an offline list of strings, then return the first match from the string list

I'm trying to build a query that looks through a string column and compares it to a list of strings I have in a text file to see if any of the strings in the list are contained within the text of the string column. I then want to grab the first occurrence of a match and return it.
For further context, I have a list of app names in a text file that look like ('app 1', 'app 2', etc). These all belong to one device (let's call that 'device_1').
Separately, I have a database table called "reports" with a 3 columns:
report_id
device
report_title
1
device_1
title string 1
2
device_1
title string 2
3
device_1
title string 3
I'm filtering the reports table for only device = 'device_1'. The "report_title" column will hold a long string of text that may or may not contain an app name. Using a sql query, I want to check each report title string to see if it contains one of the app names in my text file, and if so, return that app name for the first match (there SHOULD only ever be one match per title string if there is one).
The final output that I'm trying to get would be something like the below:
report_id
device
app_name
1
device_1
app 1
2
device_1
app 2
3
device_1
app 1
4
device_1
app 3
I was originally trying to do this somehow by creating a temporary local table to hold the text file strings, but I'm getting error messages when trying to create a table due to not having the appropriate permissions (unless I'm doing it wrong).
Would this be better done by converting the text file into an array somehow?
I think something like this should do it
SELECT TOP (1) report_title
FROM reports
WHERE device = 'device_1';

Splunk Host header overrides host key from log messages

How can I stop Splunk considering hostname "host" more important than "host" key?
Let's suppose that I have the following logs:
color = red ; host = localhost
color = blue ; host = newhost
The following query works fine:
index=myindex | stats count by color
but the following doesn't:
index=myindex | stats count by host
because instead of considering "host" being the key from the log, it sees the Host header as "host".
How can I deal with this?
When there are two fields with the same name one of them has to "win". In this case, it's the one Splunk defines before it processes the event itself. As you probably know, every event is given 4 fields at input time: index, host, source, and sourcetype. Data from the event won't override these unless specifically told to do so in the config files.
To override the settings, put this in your transforms.conf file
[sethost]
REGEX = host\s*=\s*(\w+)
DEST_KEY = MetaData:Host
FORMAT = host::$1
You'll also need to reference the transform in your props.conf file
[mysourcetype]
TRANSFORMS-host = sethost
I would have thought this solution would be more prominent, but I found it buried deep in the Splunk docs.
https://docs.splunk.com/Documentation/Splunk/8.2.6/Metrics/Search
You can use reserved fields such as "source", "sourcetype", or "host" as dimensions. However, when extracted dimension names are reserved names, the name is prefixed with "extracted_" to avoid name collision. For example, if a dimension name is "host", search for "extracted_host" to find it.
So, in your case:
index=myindex | stats count by extracted_host

HL7 ORU sending edits

I use HL7 ORU message to send clinical notes. At present, I just send notes as they are created and saved. But now I need to support edit and delete of the notes and convey the same to the receiving system.
How can I achieve edit / delete with this? I use ORU^R01 structure and use OBR and multiple OBX segments for my information. Thanks.
You will need to confirm with the receiving system how they want edits and deletes conveyed to them. But it is common to use the result status code in OBR-25 and/or the observation result status code in OBX-11.
For example, if the clinical note is edited (aka. corrected or modified) send a C in OBR-25. If the clinical note is deleted send a X in OBR-25. Ultimately you will need to coordinate with the receiving system.
FWIW, I commonly see these values in OBR-25:
P = preliminary
F = final
C = corrected / modified
X = cancelled / deleted / in-error

Finding a string embedded with several strings in a single cell

Working on a large macro to automate an end of day email process that involves sending emails to different customers. Everything is working fairly well except in the several instances that some firms have different emails for different employees. It would be simple if these employees were the only ones that would be sent to that email, but that is of course not the case.
I'm struggling to find a solution to finding the names and referencing the email. But referencing multiple names without knowing how many names it could be ahead of time (meaning in the future a firm could have 10 employees with the same email confirmation and some may have as little as 1 (for those that require separate emails per employee)). Would I use an array for this and test against the array? I would also need to store the employee names in order to ensure duplicates aren't created. See Text example and code below:
The names are stored in a sheet named emailMaster in this format say starting in cell(1,3) (Joe GoodGuy; James Johanson; Jimmy TheHat (All encapsulated in one cell)) and the email they correspond to is found at .Offset(0,1). To clarify, these gentlemen may work for the firm "CodersUnited", but their may be another group from the firm "CodersUnited", who require a different email address for their end of day receipts and they could be in cell(1,5) (Jimmy John; Franky TwoToes; Jimmy Hendrix) and their corresponding email found in .Offset(0,1).
Row ____________________C____________________ __D___ ___________________E____________________ __F__
1 Joe GoodGuy; James Johanson; Jimmy TheHat Emails Jimmy John; Frank TwoToes; Jimmy Hendrix Email
The solution below only works if their is one name corresponding to one email. There needs to be multiple names corresponding to one email.
'Gets firm name
If firmName = emailMaster.Cells(emrow_num, 1) Then
continue = False
cFirm = firmName
iFirm = emailMaster.Cells(emrow_num, 2)
If IsEmpty(emailMaster.Cells(emrow_num, 4)) = True Then
firmEmail = emailMaster.Cells(emrow_num, 3)
'Tests for separate employee emails
ElseIf emailMaster.Cells(emrow_num, 4) = "Yes" Then
empSeparate = True
'Captures separate emp email
Set empTestFinder = emailMaster.Rows(emrow_num).Find(empName)
empFinder = empTestFinder.Address
firmEmail = emailMaster.Range(empFinder).Offset(0, 1)
Else
MsgBox ("Firm designated as different emails for employees. Either change designation of firm or add employee. Contact dev for more assistance.")
Exit Sub
End If
End If
In my view you are mixing three tasks:
modelling your data
determining a convenient method of holding that data in Excel
determining a convenient method of holding that data in VBA variables
You need to tackle these tasks in sequence but be willing to revert to a previous task if you encounter problems attempting the current task..
Below is a data model which I have deduced from your question. This model does not conform to any standard modelling notation but, if you are not a data modeller, I think you will find this notation easier to understand.
You need to send emails to all your customers. I have shown three example customers. At Customer1 there is only one person you send emails to who has there own email address. At Customer2, there are three people to whom you send emails who each have their own email address. Customer3 is more complicated. Person13 has their own address but the other contacts share addresses. For example, EmailAddr5 is shared by Person5, Person6 and Person7.
Customer1────EmailAddr1────Person1
Customer2─┬──EmailAddr2────Person2
├──EmailAddr3────Person3
└──EmailAddr4────Person4
Customer3─┬──EmailAddr5─┬──Person5
│ ├──Person6
│ └──Person7
├──EmailAddr6─┬──Person8
│ ├──Person9
│ ├──Person10
│ ├──Person11
│ └──Person12
└──EmailAddr7────Person13
Is this a correct representation of your data? I would summarise this as:
There are 1 or many PERSONs per EMAILADDR
There are 1 or many EMAILADDRs per CUSTOMER
If you are not familiar with modelling data, this may be confusing at first but I believe that with a little study it will become clear.
The question you need to answer is: “Is this a complete description of my data?” Only when you are convinced there are no special cases not covered by this model can you proceed to Task 2.
Unless your final model is much more complicated than mine, I do not believe you will need two or more worksheets to hold this data. So, task 2 is to map your data model onto an Excel worksheet.
During task2, the person to consider is the user who will create and maintain this data. For example, I would have thought holding multiple people in a single cell would be awkward to maintain. How does this data arrive? Does Acme Supplies tell you to contact John Smith whose email address is Sales#AcmeSuppliers.Com or do they tell you use Sales#AcmeSuppliers.Com to contact any of: Angela Brown, Cherry White and John Smith? If data arrives as “name – address”, the model above may be correct but inconvenient. Would this be a convenient arrangement of the data for the user to maintain?
Acme Supplies | Brown, Angela | Sales#AcmeSuppliers.Com
Acme Supplies | Chester, Neal | Admin#AcmeSuppliers.Com
Acme Supplies | Smith, John | Sales#AcmeSuppliers.Com
Acme Supplies | White, Cherry | Sales#AcmeSuppliers.Com
With this arrangement, there is a row per person per company.
If you really think your data model is correct, how about:
Acme Supplies|Admin#AcmeSuppliers.Com|Chester, Neal|Sales#AcmeSuppliers.Com|Brown, Angela|Smith, John|White, Cherry|
where I am using vertical lines to represent cell boundaries.
What I done is take:
Customer3─┬──EmailAddr5─┬──Person5
│ ├──Person6
│ └──Person7
├──EmailAddr6─┬──Person8
│ ├──Person9
│ ├──Person10
│ ├──Person11
│ └──Person12
└──EmailAddr7────Person13
and arrange it as:
Customer3|EmailAddr5|Person5|Person6|Person7|EmailAddr6|Person8|Person9| and so on
This could work because every address contains the symbol “#” while no name contains this symbol.
As you develop the mapping from the data model to Excel, you may need to revise the data model. Your original model may be technically correct but implementation in Excel may be inconvenient. Provided your revised model can handle any combination of company, address and name you can envisage and providing that revised model maps cleanly to Excel you will be all right.
Lastly, task 3 is to map the Excel worksheet to VBA variables. This depends on how you need to process the data. For example, you might have a list like:
CompanyA, PersonZ
CompanyB, PersonY
CompanyB, PersonX
: :
With this it might be easier to leave the data in the worksheet and have code like this:
For each line of list
Search for Person
If not found
Report “No such person”
Else
Record row on which first Person found
Do While True
If Person belongs to Company Then
Generate email
Exit Do
End If
Search for next Person
If row for Person is the row for the first Person Then
Report “No such person”
Exit Do
End If
Loop
End If
Next
I think the above is as much as I can offer because there is too much uncertainty about your requirement. This may be enough for you to solve your own problem. If not, you need update your question clarify your requirement.
Perhaps you would like a function like the below:
Function FoundEMail(groupArray As Variant, emailArray As Variant) As Boolean
Dim PersonInGroup As Variant, PersonInEMail As Variant, PersonFound As Boolean
For Each PersonInGroup In groupArray
PersonFound = False
For Each PersonInEMail In emailArray
PersonFound = StrConv(Trim(PersonInGroup), vbUpperCase) = StrConv(Trim(PersonInEMail), vbUpperCase)
If PersonFound Then Exit For
Next PersonInEMail
If Not PersonFound Then Exit Function
Next PersonInGroup
FoundEMail = True
End Function
So instead of If firmName = emailMaster.Cells(emrow_num, 1) Then you might have something like If FoundEMail(Split(firmName,";"),Split(emailMaster.Cells(emrow_num, 1),";")) Then

What would be the best way to parse this file?

I was just wondering if anyone knew of a good way that I could parse the file at the bottom of the post.
I have a database setup with the correct tables for each section eg Refferal Table,Caller Table,Location Table. Each table has the same columns that are show in the file below
I would really like something that is fairly genetic so if the file layout changes it won't mess me around to much. At the moment I am just reading the file in a line at a time and just using a case statement to check which section i'm in.
Is anyone able to help me with this?
PS. I am using VB but C# or anything else will be fine, also the x's in the document are just personal info I have blanked
Thanks,
Nathan
File:--->
DIAL BEFORE YOU DIG
Call 1100, Fax 1300 652 077
PO Box 7710 MELBOURNE, VIC 8004
Utilities are requested to respond within 2 working days and reference the Sequence number.
[REFFERAL DETAILS]
FROM= Dial Before You Dig - Web
TO= Technical Services
UTILITY ID= xxxxxx
COMPANY= {Company Name}
ENQUIRY DATE= 02/10/2008 13:53
COMMENCEMENT DATE= 06/10/2008
SEQUENCE NO= xxxxxxxxx
PLANNING= No
[CALLER DETAILS]
CUSTOMER ID= 403552
CONTACT NAME= {Name of Contact}
CONTACT HOURS= 0
COMPANY= Underground Utility Locating
ADDRESS= {Address}
SUBURB= {Suburb}
STATE= {State}
POSTCODE= 4350
TELEPHONE= xxxxxxxxxx
MOBILE= xxxxxxxxxx
FAX TYPE= Private
FAX NUMBER= xxxxxxxxxx
PUBLIC ADDRESS= xxxxxxxxxx
PUBLIC TELEPHONE=
EMAIL ADDRESS= {Email Address}
[LOCATION DETAILS]
ADDRESS= {Location Address}
SUBURB= {Location Suburb}
STATE= xxx
POSTCODE= xxx
DEPOSITED PLAN NO= 0
SECTION & HUNDRED NO= 0
PROPERTY PHONE NO=
SIDE OF STREET= B
INTERSECTION= xxxxxx
DISTANCE= 0-200m B
ACTIVITY CODE= 15
ACTIVITY DESCRIPTION= xxxxxxxxxxxxxxxxxx
MAP TYPE= StateGrid
MAP REF= Q851_63
MAP PAGE=
MAP GRID 1=
MAP GRID 2=
MAP GRID 3=
MAP GRID 4=
MAP GRID 5=
GPS X COORD=
GPS Y COORD=
PRIVATE/ROAD/BOTH= B
TRAFFIC AFFECTED= No
NOTIFICATION NO= 3082321
MESSAGE= entire intersection of Allora-Clifton rd , Hillside
rd and merivale st
MOCSMESSAGE= Digsafe generated referral
Notice: Please DO NOT REPLY TO THIS EMAIL as it has been automatically generated and replies are not monitored. Should you wish to advise Dial Before You Dig of any issues with this enquiry, please Call 1100
(See attached file: 3082321_LLGDA94.GML)
Google has the answers, once you know that the file-format is called '.ini'
Edit: That is, it's an .ini plus some extra leading/trailing gunk.
You could read each line of the file sequentially. Each line is essentially a name value pair. Place each value in a map (hash table) keyed by name. Use a map for each section. When done parsing the file you'll have maps containing all the name value pairs. Iterate over each map and populate your database tables.
I would head to Python for any type of string parsing like this. I'm not sure how much of this information you want to retain, but I would perhaps use Python's split() function to split on = to get rid of the equals sign, then strip the whitespace out of the second piece of the pie.
First, I would mask out the header/footer info I know I don't need, then do something akin to the following:
Let's take a chunk and save it in test1.txt:
ADDRESS= {Location Address}
SUBURB= {Location Suburb}
STATE= xxx
POSTCODE= xxx
DEPOSITED PLAN NO= 0
SECTION & HUNDRED NO= 0
PROPERTY PHONE NO=
Here's a small python snippet:
>>> f = open("test1.txt", "r")
>>> l = f.readlines()
>>> l = [line.split('=') for line in l]
>>> for line in l:
print line
['ADDRESS', '{Location Address}']
['SUBURB', '{Location Suburb}']
['STATE', 'xxx']
['POSTCODE', 'xxx']
['DEPOSITED PLAN NO', '0']
['SECTION & HUNDRED NO', '0']
['PROPERTY PHONE NO', '']
This would essentially give you a [Column, Value] tuple you could use to insert the data into your database (after escaping all strings, etc etc, SQL Injection warning).
This is assuming the email input and your DB will have the same column names, but if they didn't, it'd be fairly trivial to set up a column mapping using a dictionary. On the flip side, if the email and columns are in sync, you don't need to know the names of the columns to get the parsing down.
You could iterate through the pseudo-dictionary and print out each key-value pair in the right spot in your parameterized sql string.
Hope this helps!
Edit: While this is in Python, C#/VB.net should have the same/similar abilities.
Using f As StreamReader = File.OpenText("sample.txt")
Dim g As String = "undefined"
Do
Dim s As String = f.ReadLine
If s Is Nothing Then Exit Do
s = s.Replace(Chr(9), " ")
If s.StartsWith("[") And s.EndsWith("]") Then
g = s.Substring("[".Length, s.Length - "[]".Length)
Else
Dim ss() As String = s.Split(New Char() {"="c}, 2)
If ss.Length = 2 Then
Console.WriteLine("{0}.{1}={2}", g, Trim(ss(0)), Trim(ss(1)))
End If
End If
Loop
End Using