Feat: extended rate parsing#142
Conversation
add basic MCS Decoding test: add additional station info test case with MCS attributes feat: add support for VHT MCS indexes in StationInfo and related parsing logic feat: enhance StationInfo with detailed rate information and VHT support
expose Interface create subtypes that implement the interface
d82f780 to
c608a43
Compare
|
I have added several testcases in |
|
Thanks, I'll try and get to this soon. Maybe @nickgarlis would also like to take a look. |
| func modulationAttributes(rateInfo RateModulationInfo) (attr []netlink.Attribute) { | ||
| // attr = append(attr, netlink.Attribute{Type: unix.NL80211_RATE_INFO_BITRATE, Data: nlenc.Uint16Bytes(uint16(bitrateAttr(s.ReceiveBitrate)))}) | ||
| // attr = append(attr, netlink.Attribute{Type: unix.NL80211_RATE_INFO_BITRATE32, Data: nlenc.Uint32Bytes(bitrateAttr(s.ReceiveBitrate))}) | ||
| switch ri := rateInfo.(type) { |
There was a problem hiding this comment.
Could the RateModulationInfo interface also implement a marshal and unmarshal function so that this becomes a bit easier to read ?
| type BaseModulationInfo struct { | ||
| MCS int | ||
| NSS int | ||
| IwDescription string |
There was a problem hiding this comment.
Can IwDescription be built by the Description function instead ?
This would mean that it'd have to be implemented on each type that implements BaseModulationInfo. If you also turned those attributes into their own types, you could use their String methods.
Personally, I prefer to keep the deserialization/serialization logic focused on fields returned/sent from/to the kernel.
| iwDescription += fmt.Sprintf(" VHT-MCS %d", vhtModulationInfo.MCS) | ||
| case unix.NL80211_RATE_INFO_40_MHZ_WIDTH: | ||
| channelWidth = ChannelWidth40 | ||
| iwDescription += " 40MHz" |
There was a problem hiding this comment.
ChannelWidth implements a String function which seems to be returning the same values. Can it be reused ?
| vhtModulationInfo.ShortGI = true | ||
| iwDescription += " Short GI" | ||
| case unix.NL80211_RATE_INFO_VHT_NSS: | ||
| vhtModulationInfo.NSS = int(nlenc.Uint8(a.Data)) |
There was a problem hiding this comment.
Could there be a custom type (just like ChannelWidth) for NSS, MCS etc. ? If so then the type could implement a String function too.
There was a problem hiding this comment.
Actually, NVM. This would be an overkill given that the values are not fixed.
|
|
||
| // parseRateInfo parses a rateInfo from netlink attributes. | ||
| func parseRateInfo(b []byte) (*rateInfo, error) { | ||
| func parseRateInfo(b []byte) (*RateInfo, error) { |
There was a problem hiding this comment.
I realize that parseRateInfo returned a pointer of *rateInfo before but I am wondering whether this could be changed to RateInfo now since it's being dereferenced downstream.
This Pull Request makes the RateInfo available for the user.
I am looking for feedback (@SuperQ ?)on the API-Design for the User of this Library. If nobody objects, I will add in testcases and cleanup the documentation before un-drafting this Pull Request.
My Usecase
I want to access the MCS-Index and the number of Spacial Stream (NSS) for RX and TX of the current Connection together with a string description similar to the one provided by the
iw wlan0 linkcommand (i.e.rx bitrate: 173.3 MBit/s VHT-MCS 8 short GI VHT-NSS 2).Changes
RateModulationInfowith the following Methodes:GetMCS() intGetNSS() intDescription() stringWifiGeneration() stringHTModulationInfo,VHTModulationInfo,HEModulationInfoandEHTModulationInforateInfofromclient_linux.gotowifi.goand make it publicRateModulationInfoInterface to theRateInfostruct. Also addChannelWidthandModulationTypeparseRateInfo(b []byte) (*RateInfo, error)function to populate the new fieldsRateInfo(for Rx and Tx) to theStationInfoStructCaveats
RateInfoStruct. If user wants to use parts of the types that are not in the Interface, they have type-cast the concrete struct to the desired type. MCS. NSS, Description and WiFiGeneration are available for all TypesDescription()can differ from theiwoutput (i.e. in my real-world testcase the "shortGI" string is placed at the End of the string not in-between MCS and NSS as in theiwoutput)Station Infothere is now duplicate Information (the bitrate itself) is available directly viaStationInfo.ReceiveBitrateand is also Part of the RateInfo TypeStationInfo.ReceiveRateInfo.Bitrate. This keeps the API of Station Info backwards-compatible but also groups it with the rest of the rate and modulation info.The program was tested solely for our own use cases, which might differ from yours.
Lukas Raffelt < lukas.raffelt@mercedes-benz.com > on behalf of Mercedes-Benz Tech Innovation GmbH, Provider Information
Licensed under MIT